use of blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.ITileDrop in project Immersive-Tech by FerroO2000.
the class BlockITTileProvider method getPickBlock.
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ITileDrop) {
ItemStack s = ((ITileDrop) tile).getTileDrop(player, world.getBlockState(pos));
if (!s.isEmpty())
return s;
}
Item item = Item.getItemFromBlock(this);
return item == Items.AIR ? ItemStack.EMPTY : new ItemStack(item, 1, this.damageDropped(world.getBlockState(pos)));
}
use of blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.ITileDrop in project Immersive-Tech by FerroO2000.
the class BlockITTileProvider method breakBlock.
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if (tile != null && (!(tile instanceof ITileDrop) || !((ITileDrop) tile).preventInventoryDrop()) && tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
IItemHandler h = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (h instanceof IEInventoryHandler)
for (int i = 0; i < h.getSlots(); i++) if (h.getStackInSlot(i) != null) {
spawnAsEntity(world, pos, h.getStackInSlot(i));
((IEInventoryHandler) h).setStackInSlot(i, null);
}
}
if (tile instanceof IHasDummyBlocks) {
((IHasDummyBlocks) tile).breakDummies(pos, state);
}
if (tile instanceof IImmersiveConnectable)
if (!world.isRemote || !Minecraft.getMinecraft().isSingleplayer())
ImmersiveNetHandler.INSTANCE.clearAllConnectionsFor(Utils.toCC(tile), world, !world.isRemote && world.getGameRules().getBoolean("doTileDrops"));
super.breakBlock(world, pos, state);
world.removeTileEntity(pos);
}
use of blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.ITileDrop in project ImmersiveEngineering by BluSunrize.
the class TileEntityMultiblockPart method replaceStructureBlock.
public void replaceStructureBlock(BlockPos pos, IBlockState state, ItemStack stack, int h, int l, int w) {
if (state.getBlock() == this.getBlockType())
world.setBlockToAir(pos);
world.setBlockState(pos, state);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ITileDrop)
((ITileDrop) tile).readOnPlacement(null, stack);
}
use of blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.ITileDrop in project Immersive-Tech by FerroO2000.
the class BlockITTileProvider method onIEBlockPlacedBy.
@Override
public void onIEBlockPlacedBy(World world, BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer, ItemStack stack) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof IDirectionalTile) {
EnumFacing f = ((IDirectionalTile) tile).getFacingForPlacement(placer, pos, side, hitX, hitY, hitZ);
((IDirectionalTile) tile).setFacing(f);
if (tile instanceof IAdvancedDirectionalTile)
((IAdvancedDirectionalTile) tile).onDirectionalPlacement(side, hitX, hitY, hitZ, placer);
}
if (tile instanceof IHasDummyBlocks) {
((IHasDummyBlocks) tile).placeDummies(pos, state, side, hitX, hitY, hitZ);
}
if (tile instanceof ITileDrop) {
((ITileDrop) tile).readOnPlacement(placer, stack);
}
}
use of blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.ITileDrop in project ImmersiveEngineering by BluSunrize.
the class BlockIEMultiblock 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().isEmpty())
world.spawnEntity(new EntityItem(world, pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5, tile.getOriginalBlock().copy()));
if (tile.formed && tile instanceof IIEInventory) {
IIEInventory master = (IIEInventory) tile.master();
if (master != null && (!(master instanceof ITileDrop) || !((ITileDrop) master).preventInventoryDrop()) && master.getDroppedItems() != null)
for (ItemStack s : master.getDroppedItems()) if (!s.isEmpty())
world.spawnEntity(new EntityItem(world, pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5, s.copy()));
}
}
if (tileEntity instanceof TileEntityMultiblockPart)
((TileEntityMultiblockPart) tileEntity).disassemble();
super.breakBlock(world, pos, state);
}
Aggregations