Posted April 19, 201510 yr Hello. I'm somewhat confused to what I should register and this and that. Let's say I have a custom leaves block, with 4 variants (just like a normal vanilla block): 0x1 and 0x2 defines the variant (oak, birch, spruce, jungle). 0x4 defines if its decayable or not. 0x8 defines if it should check its decayable status. This means that I'll be utilizing metadata from 0 to 15. They use different models per variant. If I were to register those 4 models (oak, birch, spruce, jungle), will I need to register all 0 to 15 metadatas? Or only the 0, 1, 2, 3 ones? Thanks! ps: By register I mean: Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(args)
April 19, 201510 yr Hi Just the four metadata values that you use for items. http://greyminecraftcoder.blogspot.com.au/2014/12/item-rendering-18.html See also this tutorial project https://github.com/TheGreyGhost/MinecraftByExample MBE03 https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/mbe03_block_variants/StartupClientOnly.java and the appropriate functions in your block class Block:: // this function returns the correct item type corresponding to the colour of our block; // i.e. when a sign is broken, it will drop the correct item. Ignores Facing, because we get the same item // no matter which way the block is facing @Override public int damageDropped(IBlockState state) { EnumColour enumColour = (EnumColour)state.getValue(PROPERTYCOLOUR); return enumColour.getMetadata(); } // create a list of the subBlocks available for this block, i.e. one for each colour // ignores facings, because the facing is calculated when we place the item. // - used to populate items for the creative inventory // - the "metadata" value of the block is set to the colours metadata @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { EnumColour[] allColours = EnumColour.values(); for (EnumColour colour : allColours) { list.add(new ItemStack(itemIn, 1, colour.getMetadata())); } } // when the block is placed, set the appropriate facing direction based on which way the player is looking // the colour of block is contained in meta, it corresponds to the values we used for getSubBlocks @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { EnumColour colour = EnumColour.byMetadata(meta); // find the quadrant the player is facing EnumFacing enumfacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw); return this.getDefaultState().withProperty(PROPERTYFACING, enumfacing).withProperty(PROPERTYCOLOUR, colour); } -TGG
April 22, 201510 yr Author Follow-up question (I'm sorry if this is explained somewhere in your wonderful tutorials, I probably missed it): If I only need to register models for blocks that can appear on inventory, does this mean that I wouldn't need to register models for technical blocks (melon stem, wheat, etc.)? Thanks again! :-)
April 22, 201510 yr If I only need to register models for blocks that can appear on inventory, does this mean that I wouldn't need to register models for technical blocks (melon stem, wheat, etc.)? You wouldn't. Actually, these technical blocks shall not even have an corresponding ItemBlock, which makes it impossible to get this block by /give command. Author of Tao Land Mod. http://taoland.herbix.me/images/1/14/TaoLandLogo.png[/img] Also, author of RenderTo ---- I'm not an English native speaker. I just try my best.
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.