Search in sources :

Example 1 with TileEntityMultiblockPart

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IProperty(net.minecraft.block.properties.IProperty) PropertyDirection(net.minecraft.block.properties.PropertyDirection) IAttachedIntegerProperies(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IAttachedIntegerProperies) TileEntityMultiblockPart(blusunrize.immersiveengineering.common.blocks.TileEntityMultiblockPart) IMirrorAble(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IMirrorAble) IDualState(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDualState) IActiveState(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IActiveState) IHasDummyBlocks(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IHasDummyBlocks) IDirectionalTile(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile)

Example 2 with TileEntityMultiblockPart

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) TileEntityMultiblockPart(blusunrize.immersiveengineering.common.blocks.TileEntityMultiblockPart) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

TileEntityMultiblockPart (blusunrize.immersiveengineering.common.blocks.TileEntityMultiblockPart)2 TileEntity (net.minecraft.tileentity.TileEntity)2 IActiveState (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IActiveState)1 IAttachedIntegerProperies (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IAttachedIntegerProperies)1 IDirectionalTile (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile)1 IDualState (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDualState)1 IHasDummyBlocks (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IHasDummyBlocks)1 IMirrorAble (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IMirrorAble)1 IProperty (net.minecraft.block.properties.IProperty)1 PropertyDirection (net.minecraft.block.properties.PropertyDirection)1 EntityItem (net.minecraft.entity.item.EntityItem)1 IInventory (net.minecraft.inventory.IInventory)1