use of minechem.radiation.RadiationFluidTileEntity in project Minechem by iopleke.
the class MinechemBucketDispenser method dispense.
@Override
public ItemStack dispense(IBlockSource blockSource, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.func_149937_b(blockSource.getBlockMetadata());
World world = blockSource.getWorld();
int x = blockSource.getXInt() + enumfacing.getFrontOffsetX();
int y = blockSource.getYInt() + enumfacing.getFrontOffsetY();
int z = blockSource.getZInt() + enumfacing.getFrontOffsetZ();
Block front = world.getBlock(x, y, z);
if (!front.getMaterial().isSolid()) {
world.func_147480_a(x, y, z, true);
world.setBlockToAir(x, y, z);
MinechemBucketItem item = (MinechemBucketItem) itemstack.getItem();
Block block = item.block;
world.setBlock(x, y, z, block, 0, 3);
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && item.chemical.radioactivity() != RadiationEnum.stable) {
int dimensionID = itemstack.stackTagCompound.getInteger("dimensionID");
long lastUpdate = itemstack.stackTagCompound.getLong("lastUpdate");
long decayStart = itemstack.stackTagCompound.getLong("decayStart");
RadiationInfo radioactivity = new RadiationInfo(itemstack, decayStart, lastUpdate, dimensionID, item.chemical.radioactivity());
((RadiationFluidTileEntity) tile).info = radioactivity;
}
itemstack.func_150996_a(Items.bucket);
return itemstack;
}
return itemstack;
}
use of minechem.radiation.RadiationFluidTileEntity in project Minechem by iopleke.
the class MinechemBucketHandler method fillCustomBucket.
private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) {
Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
Item bucket = buckets.get(block);
if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) {
ItemStack stack = new ItemStack(bucket);
TileEntity tile = world.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
RadiationEnum radiation = ((MinechemBucketItem) bucket).chemical.radioactivity();
if (tile != null && radiation != RadiationEnum.stable && tile instanceof RadiationFluidTileEntity && ((RadiationFluidTileEntity) tile).info != null) {
RadiationInfo.setRadiationInfo(((RadiationFluidTileEntity) tile).info, stack);
}
world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
return stack;
} else {
return null;
}
}
use of minechem.radiation.RadiationFluidTileEntity in project Minechem by iopleke.
the class MinechemBucketReceiver method dispense.
@Override
public ItemStack dispense(IBlockSource blockSource, ItemStack itemstack) {
EnumFacing enumfacing = BlockDispenser.func_149937_b(blockSource.getBlockMetadata());
World world = blockSource.getWorld();
int x = blockSource.getXInt() + enumfacing.getFrontOffsetX();
int y = blockSource.getYInt() + enumfacing.getFrontOffsetY();
int z = blockSource.getZInt() + enumfacing.getFrontOffsetZ();
Block front = world.getBlock(x, y, z);
if (front instanceof MinechemFluidBlock) {
MinechemBucketItem item = MinechemBucketHandler.getInstance().buckets.get(front);
ItemStack newstack = new ItemStack(item);
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && item.chemical.radioactivity() != RadiationEnum.stable) {
RadiationInfo.setRadiationInfo(((RadiationFluidTileEntity) tile).info, newstack);
}
world.func_147480_a(x, y, z, true);
itemstack.stackSize--;
if (itemstack.stackSize <= 0) {
return newstack;
} else {
TileEntity inventoryTile = blockSource.getBlockTileEntity();
if (inventoryTile instanceof IInventory) {
ItemStack stack = MinechemUtil.addItemToInventory((IInventory) blockSource.getBlockTileEntity(), newstack);
if (stack != null) {
MinechemUtil.throwItemStack(world, stack, x, y, z);
}
} else {
MinechemUtil.throwItemStack(world, newstack, x, y, z);
}
}
return itemstack;
}
return source.dispense(blockSource, itemstack);
}
Aggregations