use of blusunrize.immersiveengineering.common.blocks.TileEntityMultiblockPart in project Immersive-Tech by FerroO2000.
the class BlockITTileProvider method getActualState.
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
state = super.getActualState(state, world, pos);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof IAttachedIntegerProperies) {
for (String s : ((IAttachedIntegerProperies) tile).getIntPropertyNames()) state = applyProperty(state, ((IAttachedIntegerProperies) tile).getIntProperty(s), ((IAttachedIntegerProperies) tile).getIntPropertyValue(s));
}
if (tile instanceof IDirectionalTile && (state.getPropertyKeys().contains(IEProperties.FACING_ALL) || state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL))) {
PropertyDirection prop = state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL) ? IEProperties.FACING_HORIZONTAL : IEProperties.FACING_ALL;
state = applyProperty(state, prop, ((IDirectionalTile) tile).getFacing());
} else if (state.getPropertyKeys().contains(IEProperties.FACING_HORIZONTAL))
state = state.withProperty(IEProperties.FACING_HORIZONTAL, getDefaultFacing());
else if (state.getPropertyKeys().contains(IEProperties.FACING_ALL))
state = state.withProperty(IEProperties.FACING_ALL, getDefaultFacing());
if (tile instanceof IActiveState) {
IProperty boolProp = ((IActiveState) tile).getBoolProperty(IActiveState.class);
if (state.getPropertyKeys().contains(boolProp))
state = applyProperty(state, boolProp, ((IActiveState) tile).getIsActive());
}
if (tile instanceof IDualState) {
IProperty boolProp = ((IDualState) tile).getBoolProperty(IDualState.class);
if (state.getPropertyKeys().contains(boolProp))
state = applyProperty(state, boolProp, ((IDualState) tile).getIsSecondState());
}
if (tile instanceof TileEntityMultiblockPart)
state = applyProperty(state, IEProperties.MULTIBLOCKSLAVE, ((TileEntityMultiblockPart) tile).isDummy());
else if (tile instanceof IHasDummyBlocks)
state = applyProperty(state, IEProperties.MULTIBLOCKSLAVE, ((IHasDummyBlocks) tile).isDummy());
if (tile instanceof IMirrorAble)
state = applyProperty(state, ((IMirrorAble) tile).getBoolProperty(IMirrorAble.class), ((IMirrorAble) tile).getIsMirrored());
return state;
}
use of blusunrize.immersiveengineering.common.blocks.TileEntityMultiblockPart in project Immersive-Tech by FerroO2000.
the class BlockITMultiblock method breakBlock.
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof TileEntityMultiblockPart && world.getGameRules().getBoolean("doTileDrops")) {
TileEntityMultiblockPart tile = (TileEntityMultiblockPart) tileEntity;
if (!tile.formed && tile.pos == -1 && tile.getOriginalBlock() != null)
world.spawnEntity(new EntityItem(world, pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5, tile.getOriginalBlock().copy()));
if (tileEntity instanceof IInventory)
InventoryHelper.dropInventoryItems(world, pos, (IInventory) tile);
}
if (tileEntity instanceof TileEntityMultiblockPart)
((TileEntityMultiblockPart) tileEntity).disassemble();
super.breakBlock(world, pos, state);
}
Aggregations