Results 1 to 12 of 12
  1. #1
    Stefan. is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default 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

    Java 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);
            }
        }
    }

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    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.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,778
    Blog Entries
    7
    Rep Power
    21

    Default

    @OP: please don't double post; I've deleted your other (identical) thread in the New to Java forum section.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Stefan. is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    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)
    Java 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;
        }
    }

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    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?

    How about this method:
    Java Code:
     protected int damageDropped(int i)
        {
            return i;  //<<<<<<<< Returns the passed argument ???

  6. #6
    Stefan. is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    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.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    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.

    You forgot to answer this:
    Does the Block class have a size property?

  8. #8
    Stefan. is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    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

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    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?

  10. #10
    Stefan. is offline Member
    Join Date
    Jul 2011
    Posts
    10
    Rep Power
    0

    Default

    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)"

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    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.

  12. #12
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,778
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    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 ;-)
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. block url
    By thedevilz in forum New To Java
    Replies: 1
    Last Post: 09-16-2010, 11:55 PM
  2. Try/catch block
    By swati.jyoti in forum New To Java
    Replies: 5
    Last Post: 07-02-2009, 03:32 PM
  3. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 05:37 PM
  4. Variable name determined by another variable's value
    By Lumpkabob in forum New To Java
    Replies: 5
    Last Post: 04-14-2009, 09:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •