Posted January 26, 20169 yr Hi, I'm wondering how I can render a block correct. It's not just a normal block with one texture, that would be easy. Thats what I got so far. My problem is now: How to do the rotation? I don't want the bread texture always looking in the same direction, it should show in the direction the block is rotated, too. So when the block gets rotated the texture, too. How to setup the rendering when holding the block in the hand and in the GUI? The code: Block class: public class BlockHutBaker extends Block { protected BlockHutBaker() { super(Material.wood); //setBlockName(getName()); setUnlocalizedName(Constants.MOD_ID + "." + getName()); setCreativeTab(ModCreativeTabs.MINECOLONIES); setResistance(1000f); GameRegistry.registerBlock(this, getName()); } public String getName() { return "blockHutBaker"; } } Blockstates json: { "variants": { "normal": { "model": "minecolonies:blockHutBaker" } } } block json: { "parent": "block/cube_all", "textures": { "particle": "blocks/planks_oak", "down": "blocks/planks_oak", "up": "minecolonies:blocks/blockHutBakerTop", "north": "minecolonies:blocks/sideChest", "east": "minecolonies:blocks/sideChest", "south": "minecolonies:blocks/sideChest", "west": "minecolonies:blocks/sideChest" } } item (or should I call it block item json ) json: { "parent":"minecolonies:block/blockHutBaker", "display": { "thirdperson": { "rotation": [ -90, 0, 0 ], "translation": [ 0, 1, -3 ], "scale": [ 0.55, 0.55, 0.55 ] }, "firstperson": { "rotation": [ 0, -135, 25 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } } } register rendering: Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.blockHutBaker), 0, new ModelResourceLocation(Constants.MOD_ID + ":" + ModBlocks.blockHutBaker.getRegistryName(), "inventory")); Thx in advance. Bektor Developer of Primeval Forest.
January 26, 20169 yr Hello, first of all you should set the rotation of the block when the block is added in the block class. Using the furnace as an example. (I added the up and down direction for you.) Block class: public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL) public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { this.setDefaultFacing(worldIn, pos, state); } protected void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { Block block = worldIn.getBlockState(pos.north()).getBlock(); Block block1 = worldIn.getBlockState(pos.south()).getBlock(); Block block2 = worldIn.getBlockState(pos.west()).getBlock(); Block block3 = worldIn.getBlockState(pos.east()).getBlock(); Block block4 = worldIn.getBlockState(pos.up()).getBlock(); Block block5 = worldIn.getBlockState(pos.down()).getBlock(); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock()) { enumfacing = EnumFacing.WEST; } else if (enumfacing == EnumFacing.DOWN && block3.isFullBlock() && !block4.isFullBlock()) { enumfacing = EnumFacing.UP; } else if (enumfacing == EnumFacing.UP && block3.isFullBlock() && !block5.isFullBlock()) { enumfacing = EnumFacing.DOWN; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } } In your blockstate you should state all variants. "facing=north": { "model": "pandp:washing_table" }, "facing=south": { "model": "pandp:washing_table", "y": 180 }, "facing=west": { "model": "pandp:washing_table", "y": 270 }, "facing=east": { "model": "pandp:washing_table", "y": 90 }, "facing=up": { "model": "pandp:washing_table", "x": 270 }, "facing=down": { "model": "pandp:washing_table", "x": 90 } In your blockstate you might need to do different rotations because of how you setup the model. And the .json of the item of your block is in models/item is it? I am not a long time veteran of modding so if you have any further problems just ask them and also if you don't understand some parts ask abotu what they do instead of blindly copying. (Not saying that you do just to make sure.
January 26, 20169 yr Author Ok, thx. I got now the rotation working, but the item is still not rendered in the GUI and in the hand. And yes, the file is in the models/item folder: assets.minecolonies.models.item.blockHutBaker.json Developer of Primeval Forest.
January 26, 20169 yr Author protected BlockHutBaker() { super(Material.wood); //setBlockName(getName()); setUnlocalizedName(Constants.MOD_ID + "." + getName()); setCreativeTab(ModCreativeTabs.MINECOLONIES); setResistance(1000f); GameRegistry.registerBlock(this, getName()); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } Oh and here is the Inventory rendering stuff called: @Mod.EventHandler public void init(FMLInitializationEvent event) { proxy.registerRendering(); } The code with the model mesher itself is in the client proxy in the metod which is called above. Developer of Primeval Forest.
January 26, 20169 yr Author ModBlocks: public static Block blockHutBaker; public static void init() { blockHutBaker = new BlockHutBaker(); } Developer of Primeval Forest.
January 26, 20169 yr ModBlocks.blockHutBaker.getRegistryName() already has your mod ID included. Removing 'Constants.MOD_ID + ":" +' from you registerRendering should normally do the trick.
January 26, 20169 yr Author ModBlocks.blockHutBaker.getRegistryName() already has your mod ID included. Removing 'Constants.MOD_ID + ":" +' from you registerRendering should normally do the trick. Ok, thx. Now it's working perfectly. Developer of Primeval Forest.
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.