Posted November 11, 201410 yr Good days I'm new to modding and I been experimenting with meta blocks I have this Metablock with 6 subBlocks and want each subBlock to have different Bounds. so far and done so is to place the bounds in the constructor creating a public variable with the metadata then defines the bounds whit a if else chain, works but the limits of the subBlocks get mixed and change wen i put a new block on the world. then i place the bounds if else in public iicon getIcon (int side, int meta) using the meta value for the icons i get the same trouble that whith the contructor. copy the method from the Block wall.class and put there the if else meta ending whith the same results //################################################################## @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { Meta=meta; //System.out.println("Block bounds meta="+Meta); // x y z x y z //this.setBlockBounds(0F,0F,0F,1.0F,1.0F,1.0F); //full block if (Meta==0){this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);} if (Meta==1){this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);} if (Meta==2){this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);} if (Meta==3){this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);} if (Meta==4){this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);} if (Meta==5){this.setBlockBounds(0F,0.5F,0F,0.5F,1.0F,1.0F);} if (Meta >5){this.setBlockBounds(0F,0F,0F,1.0F,1.0F,1.0F);} //System.out.println("side="+side+" meta="+meta); int tex=(meta*6)+(side); //System.out.println("side="+side+" meta="+meta+" tex="+tex); if (tex < icons.length ){return icons[tex];} else{return icons[0];} } // fin de IIcon getIcon //################################################################## public void setBlockBoundsBasedOnState (IBlockAccess p_149719_1_, p_149719_2_ int, int p_149719_3_, int p_149719_4_){ //System.out.println("Block bounds meta="+Meta); // x y z x y z //this.setBlockBounds(0F,0F,0F,1.0F,1.0F,1.0F); //full block if (Meta==0){this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);} if (Meta==1){this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);} if (Meta==2){this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);} if (Meta==3){this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);} if (Meta==4){this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);} if (Meta==5){this.setBlockBounds(0F,0.5F,0F,0.5F,1.0F,1.0F);} if (Meta >5){this.setBlockBounds(0F,0F,0F,1.0F,1.0F,1.0F);} } //##################################################################
November 11, 201410 yr Author Do not know thah methods i dont find it in eclipse. what block use this method Exmple please?
November 11, 201410 yr There's also setBlockBoundsBasedOnState, which has the entire point of returning different bounds based on metadata. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
November 11, 201410 yr On 11/11/2014 at 3:06 PM, diesieben07 said: @Draco: Nope. Check where it's called from. My bad. I'd only remembered seeing the function before and its javadoc ("Updates the blocks bounds based on its current state. Args: world, x, y, z") Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
November 11, 201410 yr Author ñaaa i been triying before the public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) the trouble whit tath metod is, well there is no metadata data in the parameters entry so a have to generated or take it from other method like public IIcon getIcon(int side, int meta) { but hass the same trouble like when i put it in getIcon i must put this if else metada bounds cicle in the method who generates the metadata data and that is //############################################################## public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase steve, ItemStack p_149689_6_){ int meta=util.meta(world, steve); System.out.println("util.meta(world, steve)="+meta); //x if (meta==5){this.setBlockBounds(0.0F,0F,0F,0.5F,1.0F,1.0F);}//cara 5 if (meta==4){this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);}//cara 4 //y if (meta==1){this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);}//cara 1 if (meta==0){this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);}//cara 0 //z if (meta==2){this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);}//cara 2 if (meta==3){this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);}//cara 3 world.setBlock(x, y, z, modBlocks.puertaMercenaria , meta, 4); } //############################################################## and Nop it dont fix the issue when i put a block in the world all the metablocks change bounds ending exactly the same actualy i think this dont gona work I'll gonna end up creating 6 different metablocks each with a different setbounds and a very long piece of code to define their behavior
November 11, 201410 yr On 11/11/2014 at 4:34 PM, diesieben07 said: Well, that's MCP javadocs MCP or not, its misleading. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
November 12, 201410 yr Author The cake is a lie, Nop This time the Cake knows the true in the cake class i found like diesieben says using world.getBlockMetadata(x,y,z); to get the meta direct here a video the block is the one whith oak texture there is some weirdiness whit the icons in hotbar they start to change but for now i dont care now is more easy to get done the rest of the code im gona do dat in a few days. public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { int l = world.getBlockMetadata(x,y,z); System.out.println("//################# ################ meta2="+l); if (l==0){ this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);}//cara 0 else if (l==1){ this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);}//cara 1 else if (l==2){ this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);}//cara 2 else if (l==3){ this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);}//cara 3 else if (l==4){ this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);}//cara 4 else if (l==5){ this.setBlockBounds(0.0F,0F,0F,0.5F,1.0F,1.0F);}//cara 5 else { this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,1.0F);}//full blocke } // all the code for the block package mercenary00.mercenarymod.blocks; import java.util.List; import mercenary00.mercenarymod.items.ItemBlockMultiBlock; import mercenary00.mercenarymod.Mercenary; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mercenary00.mercenarymod.utilidades.util; import mercenary00.mercenarymod.blocks.puertaMercenaria; //################################################################################################################ public class puertaMercenaria extends Block{ private int maxMeta = 6; IIcon[] icons = new IIcon[36]; private final String name = "puertamercenaria"; //################################################################################################################ public puertaMercenaria() { super(Material.rock); setBlockName(Mercenary.MODID + "_" + name); // setCreativeTab(CreativeTabs.tabBlock); this.setHardness(4.0F); this.setResistance(6.0F); this.setStepSound(soundTypeWood); GameRegistry.registerBlock(this, ItemBlockMultiBlock.class, name); }//fin del contructor //################################################################################################################ @Override public void registerBlockIcons(IIconRegister iconRegister) { for(int ic = 0; ic < icons.length; ic++) { icons[ic] = iconRegister.registerIcon(Mercenary.MODID + ":"+"puertas/" + name + ic); } } //################################################################################################################ @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { int tex=(meta*6)+(side); if (tex < icons.length ){return icons[tex];} else{return icons[0];} } // fin de IIcon getIcon //################################################################################################################ @Override public int damageDropped(int meta) { return meta; } //################################################################################################################ @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { for(int i = 0; i < maxMeta; i++){ list.add(new ItemStack(item, 1, i)); } } //################################################################################################################ //@Override public int getMetadata(int meta) { return meta; } //################################################################################################################ public boolean isOpaqueCube() { return false; } //################################################################################################################ /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } //################################################################################################################ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase steve, ItemStack p_149689_6_){ int meta=util.meta(world, steve); System.out.println("util.meta(world, steve)="+meta); world.setBlock(x, y, z, modBlocks.puertaMercenaria , meta, 4); } //################################################################################################################ public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { int l = world.getBlockMetadata(x,y,z); System.out.println("//################# ################ meta2="+l); if (l==0){ this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);}//cara 0 else if (l==1){ this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);}//cara 1 else if (l==2){ this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);}//cara 2 else if (l==3){ this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);}//cara 3 else if (l==4){ this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);}//cara 4 else if (l==5){ this.setBlockBounds(0.0F,0F,0F,0.5F,1.0F,1.0F);}//cara 5 else { this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,1.0F);}//full blocke } //################################################################################################################ }
November 12, 201410 yr On 11/12/2014 at 2:03 AM, perromercenary00 said: The cake is a lie, Nop This time the Cake knows the true in the cake class i found like diesieben says using world.getBlockMetadata(x,y,z); to get the meta direct here a video the block is the one whith oak texture there is some weirdiness whit the icons in hotbar they start to change but for now i dont care now is more easy to get done the rest of the code im gona do dat in a few days. -snip- Quote Use getCollisionBoundingBoxFromPool and getSelectedBoundingBoxFromPool. You're still using setBlockBoundsBasedOnState... Also use http://gist.github.com to post your code, it's 1. far more readable and 2. doesn't clutter the thread. Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter Quote This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.