# Where is size of block determined?

• 07-13-2011, 12:24 PM
Stefan.
Where is size of block determined?
I am having troubles finding the part of the below code that determines the size of the block, i am hoping someone can point this out - thanks in advanced

Code:

```public class BlockSnow extends Block {     protected BlockSnow(int i, int j)     {         super(i, j, Material.snow);         setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);         setTickOnLoad(true);     }     public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)     {         int l = world.getBlockMetadata(i, j, k) & 7;         if(l >= 3)         {             return AxisAlignedBB.getBoundingBoxFromPool((double)i + minX, (double)j + minY, (double)k + minZ, (double)i + maxX, (float)j + 0.5F, (double)k + maxZ);         } else         {             return null;         }     }     public boolean isOpaqueCube()     {         return false;     }     public boolean renderAsNormalBlock()     {         return false;     }     public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int i, int j, int k)     {         int l = iblockaccess.getBlockMetadata(i, j, k) & 7;         float f = (float)(2 * (1 + l)) / 16F;         setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);     }     public boolean canPlaceBlockAt(World world, int i, int j, int k)     {         int l = world.getBlockId(i, j - 1, k);         if(l == 0 || !Block.blocksList[l].isOpaqueCube())         {             return false;         } else         {             return world.getBlockMaterial(i, j - 1, k).getIsSolid();         }     }     public void onNeighborBlockChange(World world, int i, int j, int k, int l)     {         func_314_h(world, i, j, k);     }     private boolean func_314_h(World world, int i, int j, int k)     {         if(!canPlaceBlockAt(world, i, j, k))         {             dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));             world.setBlockWithNotify(i, j, k, 0);             return false;         } else         {             return true;         }     }     public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l)     {         int i1 = Item.snowball.shiftedIndex;         float f = 0.7F;         double d = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;         double d1 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;         double d2 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;         EntityItem entityitem = new EntityItem(world, (double)i + d, (double)j + d1, (double)k + d2, new ItemStack(i1, 1, 0));         entityitem.delayBeforeCanPickup = 10;         world.entityJoinedWorld(entityitem);         world.setBlockWithNotify(i, j, k, 0);         entityplayer.addStat(StatList.mineBlockStatArray[blockID], 1);     }     public int idDropped(int i, Random random)     {         return Item.snowball.shiftedIndex;     }     public int quantityDropped(Random random)     {         return 0;     }     public void updateTick(World world, int i, int j, int k, Random random)     {         if(world.getSavedLightValue(EnumSkyBlock.Block, i, j, k) > 11)         {             dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));             world.setBlockWithNotify(i, j, k, 0);         }     }     public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l)     {         if(l == 1)         {             return true;         } else         {             return super.shouldSideBeRendered(iblockaccess, i, j, k, l);         }     } }```
• 07-13-2011, 12:48 PM
sunde887
Since I don't really know what a Block is, I'm gonna guess that it's the I and j which are passed into the constructor and consequently are passed into the super constructor.
• 07-13-2011, 01:17 PM
JosAH
@OP: please don't double post; I've deleted your other (identical) thread in the New to Java forum section.

kind regards,

Jos
• 07-13-2011, 02:08 PM
Stefan.
sorry its not block, block snow is what i am talking about
What i am trying to do is create a new block type that has equal size dimesions as the snowblock(first post) but all other properties are equal to a wool block(code/class file below)
Code:

```public class BlockCloth extends Block {     public BlockCloth()     {         super(35, 64, Material.cloth);     }     public int getBlockTextureFromSideAndMetadata(int i, int j)     {         if(j == 0)         {             return blockIndexInTexture;         } else         {             j = ~(j & 0xf);             return 113 + ((j & 8) >> 3) + (j & 7) * 16;         }     }     protected int damageDropped(int i)     {         return i;     }     public static int func_21034_c(int i)     {         return ~i & 0xf;     }     public static int func_21035_d(int i)     {         return ~i & 0xf;     } }```
• 07-13-2011, 04:27 PM
Norm
Quote:

Where is size of block determined?
Does the Block class have a size property?
Can you look in the Block class code to see what a Block object's size is or how it is determined?

What are the first two args to the super() call?

Most of your posted code has no meaning whatsoever.
func_21035_d what does this method do?

Code:

``` protected int damageDropped(int i)     {         return i;  //<<<<<<<< Returns the passed argument ???```
• 07-13-2011, 04:38 PM
Stefan.
The function methods are not relative for that code, i am sorry i didn't mention this; their actual function is to act as a trigger when a set task has been completed.
I was wondering if you can see any relationships between the two codes that could indicate a size of some sort.
Unfortunately I searched through the other class files to no avail.
• 07-13-2011, 04:42 PM
Norm
First define what a "size" is? Some examples of sizes: 44 inches, 2 cubic feet, 50 pounds, ???
Then show in your code where the variables are stored that define a size for an object.
Is the size of an object stored in a variable or are there sub parts that must be run thru an expression to get the size.
For example a cubic size would require: width*length*height.

Does the Block class have a size property?
• 07-13-2011, 04:59 PM
Stefan.
Well..the block must have a size property as the snowblock is an 8th of the size of the wool block. The unit of size that i forgot to mention earlier is in fact pixels however it is unknown to me where he variables (if any) are stored because i have failed to locate any line of code that could represent block size
• 07-13-2011, 05:05 PM
Norm
Quote:

it is unknown to me where he variables (if any) are stored
How can anyone help you if you can't read the code for the Block class and find the values?

Is size a rectangle with width and height?

What do you want to do when you find the size property of a block?
• 07-13-2011, 05:13 PM
Stefan.
All i need is for someone to determine the location of the code which represents size of the snowblock so i would then be able to use that code snippet to alter the size of the wool block.
I have brought it down to a conclusion that the size code must include 3 variables, this is because the block is of 3 dimensions. If this is true then the variables are either "i, k and k" or the "setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F)"
• 07-13-2011, 05:22 PM
Norm
Quote:

someone to determine the location of the code
Is this a guessing game?
You have not posted the code for the Block class. How can anyone determine the location of code in what we don't see?

Where and how is the "size" of any object observable? When you run the program is there a GUI display that you look at and see the "size" of something?
If you think you have found a method that will change your object's size, try putting in different values to see if the shown object changes size. If it does then you will have found out how to change the size.
• 07-13-2011, 06:10 PM
JosAH
Quote:

Originally Posted by Norm
Is this a guessing game?

Nope, we're supposed to be psychic, remember? The OP dumps irrelevant code at us and we're supposed to give the perfect answer.

kind regards,

Jos ;-)