Search in sources :

Example 6 with RadiationFluidTileEntity

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RadiationFluidTileEntity(minechem.radiation.RadiationFluidTileEntity) RadiationInfo(minechem.radiation.RadiationInfo) EnumFacing(net.minecraft.util.EnumFacing) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) Block(net.minecraft.block.Block) World(net.minecraft.world.World)

Example 7 with RadiationFluidTileEntity

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;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RadiationFluidTileEntity(minechem.radiation.RadiationFluidTileEntity) Item(net.minecraft.item.Item) RadiationFluidTileEntity(minechem.radiation.RadiationFluidTileEntity) RadiationEnum(minechem.radiation.RadiationEnum) Block(net.minecraft.block.Block) MinechemFluidBlock(minechem.fluid.MinechemFluidBlock) ItemStack(net.minecraft.item.ItemStack)

Example 8 with RadiationFluidTileEntity

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RadiationFluidTileEntity(minechem.radiation.RadiationFluidTileEntity) IInventory(net.minecraft.inventory.IInventory) EnumFacing(net.minecraft.util.EnumFacing) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) Block(net.minecraft.block.Block) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Aggregations

RadiationFluidTileEntity (minechem.radiation.RadiationFluidTileEntity)8 TileEntity (net.minecraft.tileentity.TileEntity)8 Block (net.minecraft.block.Block)7 ItemStack (net.minecraft.item.ItemStack)6 RadiationInfo (minechem.radiation.RadiationInfo)5 EnumFacing (net.minecraft.util.EnumFacing)3 World (net.minecraft.world.World)3 MinechemChemicalType (minechem.item.MinechemChemicalType)2 MinechemBucketItem (minechem.item.bucket.MinechemBucketItem)2 IInventory (net.minecraft.inventory.IInventory)2 Fluid (net.minecraftforge.fluids.Fluid)2 MinechemFluidBlock (minechem.fluid.MinechemFluidBlock)1 ElementEnum (minechem.item.element.ElementEnum)1 ElementItem (minechem.item.element.ElementItem)1 MoleculeEnum (minechem.item.molecule.MoleculeEnum)1 MoleculeItem (minechem.item.molecule.MoleculeItem)1 RadiationEnum (minechem.radiation.RadiationEnum)1 Material (net.minecraft.block.material.Material)1 Item (net.minecraft.item.Item)1 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)1