ReyMagos
Тег-бомбастер
- 413
- 7
- 131
При таком коде вылетает нижеприведённый краш, что делать?
Java:
public class BlockPlantsSticks extends Block {
public static final PropertyInteger TYPE = PropertyInteger.create("type", 0, 2);
public BlockPlantsSticks(String name) {
super(Material.WOOD);
this.setRegistryName(name);
this.setUnlocalizedName(name);
this.setCreativeTab(RedModMain.Test);
this.setHardness(0.01f);
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, 0));
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack itemstack = player.getHeldItem(hand);
Item item = itemstack.getItem();
if (!itemstack.isEmpty()) {
if (item == ItemsRegister.Tomato) {
setType(world, pos, state, 1);
player.sendMessage(new TextComponentString("§4Event Activated!"));
return true;
}
}
return false;
}
private void setType(World worldIn, BlockPos pos, IBlockState state, int type)
{
worldIn.setBlockState(pos, state.withProperty(TYPE, MathHelper.clamp(type, 0, 3)));
}
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[] {TYPE});
}
@Override
public int getMetaFromState(IBlockState state) {
return super.getMetaFromState(state);
}
@Override
public IBlockState getStateFromMeta(int meta) {
return super.getStateFromMeta(meta);
}
}