Posted August 29, 201510 yr Hello, I've created a block that utilizes IBlockState to iterate between models/textures and a different type of block on right-click, but the blockstates file is using a PropertyBool. Without overriding the Block#getStateFromMeta and Block#getMetaFromState the launcher returns an error, but I'm not quite sure how to override those methods with a PropertyBool. I don't want to make two different blocks, because that would just be annoying, but I'm getting stuck on those methods. Here's my class: package lordmastodon.miscal.blocks; import java.util.Random; import lordmastodon.miscal.block.MiscalBlocks; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class LightationBlock extends Block { public static final PropertyBool LIGHTED_UP = PropertyBool.create("lighted"); public LightationBlock() { super(Material.iron); this.setDefaultState(this.blockState.getBaseState().withProperty(LIGHTED_UP, false)); } public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(MiscalBlocks.lightation); } public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { if (!world.isRemote) { boolean lightedUp = (Boolean) state.getValue(LIGHTED_UP); if (lightedUp == true) { lightedUp = false; this.setLightLevel(1.0F); } else { lightedUp = true; this.setLightLevel(0.0F); } world.setBlockState(pos, state.withProperty(LIGHTED_UP, lightedUp)); } return true; } public IBlockState getStateFromMeta(int meta) { EnumFacing enumFacing = EnumFacing.getFront(meta); if (enumFacing.getAxis() == EnumFacing.Axis.Y) { enumFacing = EnumFacing.NORTH; } return this.getDefaultState().withProperty(LIGHTED_UP, enumFacing); } public int getMetaFromState(IBlockState state) { return ((EnumFacing) state.getValue(LIGHTED_UP)).getIndex(); } @SideOnly(Side.CLIENT) public IBlockState getStateForEntityRender(IBlockState state) { return this.getDefaultState().withProperty(LIGHTED_UP, false); } protected BlockState createBlockState() { return new BlockState(this, new IProperty[] {LIGHTED_UP}); } @Override public int getRenderType() { return 3; } @Override public boolean isOpaqueCube() { return false; } @SideOnly(Side.CLIENT) @Override public EnumWorldBlockLayer getBlockLayer() { return EnumWorldBlockLayer.CUTOUT_MIPPED; } @Override public boolean isFullCube() { return false; } } Any help? Thanks in advance! Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*. Also this. Check it out. http://i.imgur.com/J4rrGt6.png[/img]
August 29, 201510 yr You need to think about how each property's value will be stored in the metadata and then convert to and from the metadata appropriately. For a single boolean, you can just use metadata values 0 and 1. 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.
August 29, 201510 yr Author Ok thanks! That seemed to work. I was considering using something like that, but I wasn't sure whether that was how meta actually worked. Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*. Also this. Check it out. http://i.imgur.com/J4rrGt6.png[/img]
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.