Posted October 17, 20169 yr I've got the following issues with my slab: They won't stack. The metadata isn't being saved (upper slabs revert to lower once reloaded) The item has no texture. (no info in log though, and all 3 blocks have their textures) The double slab block won't drop two slabs - tried to fix this one by using the ItemSlab, which crashes the game. Blocks class: public class BettermentsBlocks { public static MarbleSlab marble_slab; public static MarbleDoubleSlab marble_double_slab; public static void init() { marble_double_slab = register(new MarbleDoubleSlab("marble_double_slab", marble_double_slab, Material.ROCK, 0.6f, 30f, 1, "Pickaxe", MapColor.SNOW)); marble_slab = register(new MarbleSlab("marble_slab", marble_slab, Material.ROCK, 0.6f, 30f, 1, "Pickaxe", MapColor.SNOW)).setCreativeTab(CreativeTabs.BUILDING_BLOCKS); } private static <T extends Block> T register(T block, ItemBlock itemBlock) { GameRegistry.register(block); GameRegistry.register(itemBlock); return block; } private static <T extends Block> T registerd(T block) { GameRegistry.register(block); return block; } private static <T extends Block> T register(T block, ItemSlab itemSlab){ GameRegistry.register(block); GameRegistry.register(itemSlab); ((MarbleSlab)block).registerItemModel(itemSlab); return block; } private static <T extends Block> T register(T block) { if(block instanceof MarbleSlab) { ItemSlab itemSlab = new ItemSlab(marble_slab, marble_slab, marble_double_slab); itemSlab.setRegistryName(Reference.MOD_ID + ":" + "marble_slab"); return register(block, itemSlab); } else if(!(block instanceof MarbleDoubleSlab)){ ItemBlock itemBlock = new ItemBlock(block); itemBlock.setRegistryName(block.getRegistryName()); return register(block, itemBlock); } else { return registerd(block); } } } Slab and Double Slab class: public class MarbleSlab extends BlockSlab { protected String name; public MarbleSlab(String name, Block BlockIn, Material material, float hardness, float resistance, int harvest, String tool, MapColor color) { super(material); IBlockState iblockstate = this.blockState.getBaseState(); if (!this.isDouble()){ iblockstate = iblockstate.withProperty(HALF, EnumBlockHalf.BOTTOM); } this.setDefaultState(iblockstate); this.name = name; setUnlocalizedName(name); setRegistryName(name); setHardness(hardness); setResistance(resistance); setHarvestLevel(tool, harvest); this.useNeighborBrightness = true; } @Override public String getUnlocalizedName(int meta) { return this.getLocalizedName(); } @Override public Comparable<?> getTypeForItem(ItemStack stack) { return false; } @Override public IProperty<?> getVariantProperty() { return null; } @Override public int damageDropped(IBlockState state) { return 0; } @Override public final IBlockState getStateFromMeta(final int meta) { IBlockState iblockstate = this.getDefaultState(); if (!this.isDouble()){ EnumBlockHalf value = EnumBlockHalf.BOTTOM; if ((meta & != 0){ value = EnumBlockHalf.TOP; } } return iblockstate; } @Override public final int getMetaFromState(final IBlockState state){ if (this.isDouble()){ return 0; } if ((EnumBlockHalf) state.getValue(HALF) == EnumBlockHalf.TOP){ return 8; } else { return 0; } } @Override protected final BlockStateContainer createBlockState(){ if(this.isDouble()){ return new BlockStateContainer(this, new IProperty[] {}); } else { return new BlockStateContainer(this, new IProperty[] {HALF}); } } public void registerItemModel(ItemSlab itemBlock) { BettermentsMod.proxy.registerItemRenderer(itemBlock, 0, name); } @Override public MarbleSlab setCreativeTab(CreativeTabs tab) { super.setCreativeTab(tab); return this; } @Override public MapColor getMapColor(IBlockState state){ return MapColor.SNOW; } @Override public boolean isDouble() { return false; } } public class MarbleDoubleSlab extends MarbleSlab{ public MarbleDoubleSlab(String name, Block BlockIn, Material material, float hardness, float resistance, int harvest, String tool, MapColor color) { super(name, BlockIn, material, hardness, resistance, harvest, tool, color); } @Override public boolean isDouble() { return true; } } .json files: marble_slab { "forge_marker": 1, "variants": { "half=bottom": { "model": "betterments:marble_slab_half_bottom" }, "half=top": { "model": "betterments:marble_slab_half_top" }, "inventory": { "model": "betterments:marble_slab_half_bottom", "transform": "forge:default-block" } } } marble_double_slab: { "forge_marker": 1, "defaults": { "textures": { "all": "betterments:blocks/dummy_side" } }, "variants": { "normal": { "model": "cube_all" }, "inventory": { "model": "cube_all" } } } marble_slab_half_bottom: { "parent": "block/half_slab", "textures": { "bottom": "betterments:blocks/dummy_side", "top": "betterments:blocks/dummy_side", "side": "betterments:blocks/dummy_side" } } marble_slab_half_top: { "parent": "block/upper_slab", "textures": { "bottom": "betterments:blocks/dummy_side", "top": "betterments:blocks/dummy_side", "side": "betterments:blocks/dummy_side" } } And crash report for the code above: http://pastebin.com/zbr1jygH I am human and thus will make stupid and obvious mistakes and cannot be expected to know everything.
October 20, 20169 yr Author I could really use some help creating this slab. I have tried moving the itemSlab as the last thing, and it is still not working. I don't see why Forge can't find the unlocalized name for the single slab block. *Edit: just noticed I didn't post the error eclipse gave me: http://pastebin.com/Fm7JgAz0 I am human and thus will make stupid and obvious mistakes and cannot be expected to know everything.
October 20, 20169 yr .json files: marble_slab marble_double_slab marble_slab_half_bottom marble_slab_half_top Caused by: java.lang.RuntimeException: Encountered an exception when loading model definition of model betterments:blockstates/marble_single_slab.json You don't have a json file named "marble_single_slab" 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.
October 20, 20169 yr Author You don't have a json file named "marble_single_slab" Right, sorry... As I try to debug, I occasionally change names of things as I re-do them. But that doesn't fix the null pointer exception... I am human and thus will make stupid and obvious mistakes and cannot be expected to know everything.
October 20, 20169 yr That's because you never set it: if(block instanceof MarbleSlab) { ItemSlab itemSlab = new ItemSlab(marble_slab, marble_slab, marble_double_slab); itemSlab.setRegistryName(Reference.MOD_ID + ":" + "marble_slab"); return register(block, itemSlab); } You never call itemSlab.setUnlocalizedName(...) 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.
October 20, 20169 yr Author I'm sorry... I've tried setting the unlocalized name and it is still crashing with the null pointer exception. Is this not where I would set it? public class BettermentsBlocks { public static BlockBase marble; public static MarbleDoubleSlab marble_double_slab; public static MarbleSingleSlab marble_single_slab; public static MarbleStair marble_stair; public static void init() { marble = register(new BlockBase("marble", marble, Material.ROCK, 1.5f, 30f, 1, "Pickaxe", MapColor.SNOW).setCreativeTab(CreativeTabs.BUILDING_BLOCKS)); marble_double_slab = register(new MarbleDoubleSlab("marble_double_slab", marble_double_slab, Material.ROCK, 0.6f, 30f, 1, "Pickaxe", MapColor.SNOW)); marble_single_slab = register(new MarbleSingleSlab("marble_single_slab", marble_single_slab, Material.ROCK, 0.6f, 30f, 1, "Pickaxe", MapColor.SNOW)).setCreativeTab(CreativeTabs.BUILDING_BLOCKS); marble_stair = register(new MarbleStair(marble.getDefaultState(), "marble_stair", marble_stair, Material.ROCK, 1.5f, 30f, 1, "Pickaxe", MapColor.SNOW).setCreativeTab(CreativeTabs.BUILDING_BLOCKS)); } private static <T extends Block> T register(T block, ItemBlock itemBlock) { GameRegistry.register(block); GameRegistry.register(itemBlock); if (block instanceof BlockBase) { ((BlockBase)block).registerItemModel(itemBlock); } else if (block instanceof MarbleStair) { ((MarbleStair)block).registerItemModel(itemBlock); } return block; } private static <T extends Block> T registernoitemblock(T block) { GameRegistry.register(block); return block; } private static <T extends Block> T register(T block) { if(block instanceof MarbleSingleSlab) { GameRegistry.register(block); ItemSlab itemSlab = new ItemSlab(marble, marble_single_slab, marble_double_slab); //********* Right Here: ********** itemSlab.setUnlocalizedName(block.getUnlocalizedName()); itemSlab.setRegistryName(block.getRegistryName()); GameRegistry.register(itemSlab); ((MarbleSlab)block).registerItemModel(itemSlab); return block; } else if(!(block instanceof MarbleDoubleSlab)){ ItemBlock itemBlock = new ItemBlock(block); itemBlock.setRegistryName(block.getRegistryName()); return register(block, itemBlock); } else { return registernoitemblock(block); } } } I am human and thus will make stupid and obvious mistakes and cannot be expected to know everything.
October 20, 20169 yr Well...do you ever call setUnlocalizedName on the block? 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.
October 21, 20169 yr Author Alright, so I've realized that the block that I am using is the standard block. I also fixed most things, but I still have four issues that I can't seem to resolve: The slabs do not stack, The block is not saving its metadata (I think... It reverts to the bottom slab if reloaded) The inventory item has no texture and is not showing in the creative inventory (registration problem, right?) But the game no longer crashes, so that's a plus. The game is also placing marble_slab blocks, not marble_single_slab. I don't know if this is a problem or not. Updated codes: Blocks File: public class BettermentsBlocks { public static BlockBase marble; public static MarbleSlab marble_slab; public static MarbleDoubleSlab marble_double_slab; public static MarbleSingleSlab marble_single_slab; public static MarbleStair marble_stair; public static void init() { marble = register(new BlockBase("marble", marble, Material.ROCK, 1.5f, 30f, 1, "Pickaxe", MapColor.SNOW).setCreativeTab(CreativeTabs.BUILDING_BLOCKS)); marble_slab = register(new MarbleSlab("marble_slab", marble_slab, Material.ROCK, 0.6f, 30f, 1, "Pickaxe", MapColor.SNOW)); marble_double_slab = register(new MarbleDoubleSlab("marble_double_slab", marble_double_slab, Material.ROCK, 0.6f, 30f, 1, "Pickaxe", MapColor.SNOW)); marble_single_slab = register(new MarbleSingleSlab("marble_single_slab", marble_single_slab, Material.ROCK, 0.6f, 30f, 1, "Pickaxe", MapColor.SNOW)).setCreativeTab(CreativeTabs.BUILDING_BLOCKS); marble_stair = register(new MarbleStair(marble.getDefaultState(), "marble_stair", marble_stair, Material.ROCK, 1.5f, 30f, 1, "Pickaxe", MapColor.SNOW).setCreativeTab(CreativeTabs.BUILDING_BLOCKS)); MarbleSlabItem itemSlab = new MarbleSlabItem(marble_slab, marble_single_slab, marble_double_slab); ModelLoader.setCustomModelResourceLocation(itemSlab, 1, new ModelResourceLocation("marble_slab")); } private static <T extends Block> T register(T block, ItemBlock itemBlock) { GameRegistry.register(block); GameRegistry.register(itemBlock); if (block instanceof BlockBase) { ((BlockBase)block).registerItemModel(itemBlock); } else if (block instanceof MarbleStair) { ((MarbleStair)block).registerItemModel(itemBlock); } return block; } private static <T extends Block> T registernoitemblock(T block) { GameRegistry.register(block); return block; } private static <T extends Block> T register(T block) { if(block instanceof MarbleSingleSlab) { GameRegistry.register(block); return block; } else if(!(block instanceof MarbleDoubleSlab)){ ItemBlock itemBlock = new ItemBlock(block); itemBlock.setRegistryName(block.getRegistryName()); return register(block, itemBlock); } else { return registernoitemblock(block); } } } MarbleSlab: public class MarbleSlab extends BlockSlab { protected String name; public MarbleSlab(String name, Block BlockIn, Material material, float hardness, float resistance, int harvest, String tool, MapColor color) { super(material); IBlockState iblockstate = this.blockState.getBaseState(); if (!this.isDouble()){ iblockstate = iblockstate.withProperty(HALF, EnumBlockHalf.BOTTOM); } this.setDefaultState(iblockstate); this.name = name; setUnlocalizedName(name); setRegistryName(name); setHardness(hardness); setResistance(resistance); setHarvestLevel(tool, harvest); this.useNeighborBrightness = !this.isDouble(); } @Override public String getUnlocalizedName(int meta) { return this.getLocalizedName(); } @Override public Comparable<?> getTypeForItem(ItemStack stack) { return false; } @Override public IProperty<?> getVariantProperty() { return null; } @Override public int damageDropped(IBlockState state) { return 0; } @Override public final IBlockState getStateFromMeta(final int meta) { IBlockState iblockstate = this.getDefaultState(); if (!this.isDouble()){ EnumBlockHalf value = EnumBlockHalf.BOTTOM; if ((meta & != 0){ value = EnumBlockHalf.TOP; } } return iblockstate; } @Override public final int getMetaFromState(final IBlockState state){ if (this.isDouble()){ return 0; } if ((EnumBlockHalf) state.getValue(HALF) == EnumBlockHalf.TOP){ return 8; } else { return 0; } } @Override protected final BlockStateContainer createBlockState(){ if(this.isDouble()){ return new BlockStateContainer(this, new IProperty[] {}); } else { return new BlockStateContainer(this, new IProperty[] {HALF}); } } public void registerItemModel(ItemSlab itemBlock) { BettermentsMod.proxy.registerItemRenderer(itemBlock, 0, name); } @Override public MarbleSlab setCreativeTab(CreativeTabs tab) { super.setCreativeTab(tab); return this; } @Override public MapColor getMapColor(IBlockState state){ return MapColor.SNOW; } @Override public boolean isDouble() { return false; } } MarbleDoubleSlab: public class MarbleDoubleSlab extends MarbleSlab{ public MarbleDoubleSlab(String name, Block BlockIn, Material material, float hardness, float resistance, int harvest, String tool, MapColor color) { super(name, BlockIn, material, hardness, resistance, harvest, tool, color); } @Override public boolean isDouble() { return true; } @Override public String getUnlocalizedName(int meta) { return this.getLocalizedName(); } } MarbleSingleSlab: public class MarbleSingleSlab extends MarbleSlab{ public MarbleSingleSlab(String name, Block BlockIn, Material material, float hardness, float resistance, int harvest, String tool, MapColor color) { super(name, BlockIn, material, hardness, resistance, harvest, tool, color); } @Override public boolean isDouble() { return false; } @Override public void registerItemModel(ItemSlab itemBlock) { BettermentsMod.proxy.registerItemRenderer(itemBlock, 0, name); } @Override public MarbleSingleSlab setCreativeTab(CreativeTabs tab) { super.setCreativeTab(tab); return this; } @Override public String getUnlocalizedName(int meta) { return this.getLocalizedName(); } } MarbleSlabItem: public class MarbleSlabItem extends ItemSlab{ public MarbleSlabItem(Block block, BlockSlab singleSlab, BlockSlab doubleSlab) { super(block, singleSlab, doubleSlab); setCreativeTab(CreativeTabs.BUILDING_BLOCKS); } } marble_slab.json (marble_single_slab.json is the same, but the game is not using it): { "forge_marker": 1, "variants": { "half": { "bottom":{"model": "betterments:marble_slab_half_bottom" }, "top": { "model": "betterments:marble_slab_half_top" } }, "inventory": { "model": "betterments:marble_slab_half_bottom", "transform": "forge:default-block" } } } I am human and thus will make stupid and obvious mistakes and cannot be expected to know everything.
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.