HarryTechReviews Posted August 22, 2017 Share Posted August 22, 2017 As the title says, the game won't let me place by custom slab on the bottom if top is already placed. Here is my custom slab class. I do have the CustomBlockHalfSlab and DoubleSlab classes as well. Thanks in advance public abstract class CustomBlockSlab extends BlockSlab { public CustomBlockSlab(String name, float hardness, float resistance) { super(Material.IRON); setUnlocalizedName(name); setRegistryName(name); setHardness(hardness); setResistance(resistance); this.fullBlock = this.isDouble(); IBlockState state = this.blockState.getBaseState(); if(!this.isDouble()) { state = state.withProperty(HALF, EnumBlockHalf.BOTTOM); } setDefaultState(state); this.useNeighborBrightness = true; } @Override public String getUnlocalizedName(int meta) { return this.getUnlocalizedName(); } @Override public IProperty<?> getVariantProperty() { return HALF; } @Override public Comparable<?> getTypeForItem(ItemStack stack) { return EnumBlockHalf.BOTTOM; } @Override public int damageDropped(IBlockState state) { return 0; } @Override public IBlockState getStateFromMeta(int meta) { if(!this.isDouble()) { return this.getDefaultState().withProperty(HALF, EnumBlockHalf.values()[meta % EnumBlockHalf.values().length]); } return this.getDefaultState(); } @Override public int getMetaFromState(IBlockState state) { if(this.isDouble()) { return 0; } return ((EnumBlockHalf)state.getValue(HALF)).ordinal() + 1; } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(BlockInit.tutorial_slab_half); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {HALF}); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand); } Quote Link to comment Share on other sites More sharing options...
Choonster Posted August 22, 2017 Share Posted August 22, 2017 What class are you using for the Item form of the slab? Vanilla uses ItemSlab, which handles combining single slabs into double slabs. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
HarryTechReviews Posted August 22, 2017 Author Share Posted August 22, 2017 I use item slab Quote Link to comment Share on other sites More sharing options...
HarryTechReviews Posted August 22, 2017 Author Share Posted August 22, 2017 Block Init: tutorial_slab_half = new CustomBlockHalfSlab("tutorial_slab_half", 2.5F, 4.5F); tutorial_slab_double = new CustomBlockDoubleSlab("tutorial_slab_double", 2.5F, 4.5F); registerBlock(tutorial_slab_half, new ItemSlab(tutorial_slab_half, tutorial_slab_half, tutorial_slab_double)); ForgeRegistries.BLOCKS.register(tutorial_slab_double); public static void registerBlock(Block block, ItemBlock itemblock) { ForgeRegistries.BLOCKS.register(block); block.setCreativeTab(TutorialMod.tutorialtab); itemblock.setRegistryName(block.getRegistryName()); ForgeRegistries.ITEMS.register(itemblock); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } Quote Link to comment Share on other sites More sharing options...
Choonster Posted August 22, 2017 Share Posted August 22, 2017 I'm not too sure what the problem is, then. Try setting a breakpoint in ItemSlab#onItemUse, clicking a top slab while holding a slab and stepping through the code to see why it's not combing the slabs. Side note: ModelLoader is a client-only class, referencing it in common code will crash the dedicated server. Model registration must be handled in a dedicated, client-only class. Registration of Blocks, Items and other IForgeRegistryEntry implementations should be done in the corresponding registry events. Registration of models should be done in ModelRegistryEvent. Pass Side.CLIENT to the @Mod.EventBusSubscriber annotation to prevent the model registration class being loaded on the dedicated server. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
HarryTechReviews Posted August 22, 2017 Author Share Posted August 22, 2017 The game won't let me click a block with the item, so it's not called. The top slab seems to be blocking the full place box 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.