- 106
- 3
- 7
Привет, делаю печку с блокстейт булеан горением по тутору, но блокстейт обновляется только когда меняется соседний блок. Может есть способ сказать игре что надо обновить блок?
Код печки:
А и еще тайлэнтити не записывает нбт, может дело в том что оно создается каждый раз новое при перезаходе?
Код печки:
Код:
public class FusionBlastFurnace extends Block implements ITileEntityProvider {
public static final PropertyBool FIRE = PropertyBool.create("fire");
public FusionBlastFurnace(String name)
{
super(Material.ROCK);
this.setRegistryName(name);
this.setUnlocalizedName(name);
setCreativeTab(ModCreativeTabs.GENERAL);
setHardness(3.0F);
setHarvestLevel("pickaxe", 1);
this.setDefaultState(this.blockState.getBaseState().withProperty(FIRE, false));
InitBlocks.BLOCKS.add(this);
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
boolean b = getTileEntity(worldIn, pos).isBurning();
return state.withProperty(FIRE, b);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState();
}
@Override
public int getMetaFromState(IBlockState state)
{
return 0;
}
@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[] {FIRE});
}
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Item.getItemFromBlock(InitBlocks.FUSION_BLAST_FURNACE);
}
@Override
public boolean hasTileEntity(IBlockState blockState) {
return true;
}
public Class<TileEntityFusionBlastFurnace> getTileEntityClass() {
return TileEntityFusionBlastFurnace.class;
}
public TileEntityFusionBlastFurnace getTileEntity(IBlockAccess world, BlockPos position) {
return (TileEntityFusionBlastFurnace) world.getTileEntity(position);
}
@Override
public boolean onBlockActivated(World world, BlockPos position, IBlockState blockState, EntityPlayer playerSP, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
EntityPlayerMP player = (EntityPlayerMP) playerSP;
TileEntityFusionBlastFurnace tileEntity = getTileEntity(world, position);
player.openGui(Main.instance, 1, player.getEntityWorld(), position.getX(), position.getY(), position.getZ());
}
return true;
}
@Nullable
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityFusionBlastFurnace();
}
}
А и еще тайлэнтити не записывает нбт, может дело в том что оно создается каждый раз новое при перезаходе?