Search in sources :

Example 6 with MinechemBucketItem

use of minechem.item.bucket.MinechemBucketItem in project Minechem by iopleke.

the class RadiationMoleculeHandler method handleRadiationMoleculeBucket.

public RadiationInfo handleRadiationMoleculeBucket(World world, ItemStack itemStack, IInventory inventory, double x, double y, double z) {
    PotionChemical[] decayedChemicals = getDecayedMolecule((MoleculeEnum) ((MinechemBucketItem) itemStack.getItem()).chemical);
    for (int i = 0; i < decayedChemicals.length; i++) {
        decayedChemicals[i].amount *= 8 * itemStack.stackSize;
    }
    ItemStack[] items = toItemStacks(decayedChemicals);
    for (int i = 1; i < items.length; i++) {
        ItemStack stack = MinechemUtil.addItemToInventory(inventory, items[i]);
        if (stack != null) {
            MinechemUtil.throwItemStack(world, itemStack, x, y, z);
        }
    }
    Item item = items[0].getItem();
    if (item instanceof MoleculeItem) {
        itemStack.func_150996_a(MinechemBucketHandler.getInstance().buckets.get(FluidHelper.moleculeBlocks.get(FluidHelper.molecules.get(MoleculeItem.getMolecule(items[0])))));
    } else if (item instanceof ElementItem) {
        itemStack.func_150996_a(MinechemBucketHandler.getInstance().buckets.get(FluidHelper.elementsBlocks.get(FluidHelper.elements.get(ElementItem.getElement(items[0])))));
    }
    itemStack.stackSize = (items[0].stackSize / 8);
    itemStack.setTagCompound(items[0].stackTagCompound);
    return ElementItem.initiateRadioactivity(itemStack, world);
}
Also used : ElementItem(minechem.item.element.ElementItem) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) Item(net.minecraft.item.Item) ElementItem(minechem.item.element.ElementItem) MoleculeItem(minechem.item.molecule.MoleculeItem) MoleculeItem(minechem.item.molecule.MoleculeItem) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) PotionChemical(minechem.potion.PotionChemical) ItemStack(net.minecraft.item.ItemStack)

Example 7 with MinechemBucketItem

use of minechem.item.bucket.MinechemBucketItem in project Minechem by iopleke.

the class ChemicalBucketNEIRecipeHandler method loadCraftingRecipes.

@Override
public void loadCraftingRecipes(ItemStack result) {
    if (result.getItem() instanceof MinechemBucketItem) {
        MinechemBucketItem bucket = (MinechemBucketItem) result.getItem();
        List<ItemStack> recipe = new ArrayList<ItemStack>();
        Item type = bucket.chemical instanceof ElementEnum ? MinechemItemsRegistration.element : MinechemItemsRegistration.molecule;
        int meta = bucket.chemical instanceof ElementEnum ? ((ElementEnum) bucket.chemical).atomicNumber() : ((MoleculeEnum) bucket.chemical).id();
        for (int i = 0; i < 4; i++) recipe.add(new ItemStack(type, 1, meta));
        recipe.add(new ItemStack(Items.bucket));
        for (int i = 0; i < 4; i++) recipe.add(new ItemStack(type, 1, meta));
        arecipes.add(new CachedShapelessRecipe(recipe, result));
    } else if (Compare.isStackAnElement(result)) {
        ItemStack recipe = new ItemStack(MinechemBucketHandler.getInstance().getBucket(ElementItem.getElement(result)));
        arecipes.add(new CachedShapelessRecipe(new ItemStack[] { recipe }, new ItemStack(result.getItem(), 8, result.getItemDamage())));
    } else if (Compare.isStackAMolecule(result)) {
        ItemStack recipe = new ItemStack(MinechemBucketHandler.getInstance().getBucket(MoleculeItem.getMolecule(result)));
        arecipes.add(new CachedShapelessRecipe(new ItemStack[] { recipe }, new ItemStack(result.getItem(), 8, result.getItemDamage())));
    }
}
Also used : ElementEnum(minechem.item.element.ElementEnum) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) Item(net.minecraft.item.Item) ElementItem(minechem.item.element.ElementItem) MoleculeItem(minechem.item.molecule.MoleculeItem) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 8 with MinechemBucketItem

use of minechem.item.bucket.MinechemBucketItem in project Minechem by iopleke.

the class ChemicalBucketNEIRecipeHandler method loadUsageRecipes.

@Override
public void loadUsageRecipes(ItemStack ingredient) {
    if (ingredient.getItem() == Items.bucket) {
        arecipes.add(new CachedChemicalBucketRecipe());
    } else if (Compare.isStackAnElement(ingredient)) {
        MinechemBucketItem bucketItem = MinechemBucketHandler.getInstance().getBucket(ElementItem.getElement(ingredient));
        if (bucketItem == null)
            return;
        ItemStack result = new ItemStack(bucketItem);
        List<ItemStack> recipe = new ArrayList<ItemStack>();
        for (int i = 0; i < 4; i++) recipe.add(new ItemStack(ingredient.getItem(), 1, ingredient.getItemDamage()));
        recipe.add(new ItemStack(Items.bucket));
        for (int i = 0; i < 4; i++) recipe.add(new ItemStack(ingredient.getItem(), 1, ingredient.getItemDamage()));
        arecipes.add(new CachedShapelessRecipe(recipe, result));
    } else if (Compare.isStackAMolecule(ingredient)) {
        MinechemBucketItem bucketItem = MinechemBucketHandler.getInstance().getBucket(MoleculeItem.getMolecule(ingredient));
        if (bucketItem == null)
            return;
        ItemStack result = new ItemStack(bucketItem);
        List<ItemStack> recipe = new ArrayList<ItemStack>();
        for (int i = 0; i < 4; i++) recipe.add(new ItemStack(ingredient.getItem(), 1, ingredient.getItemDamage()));
        recipe.add(new ItemStack(Items.bucket));
        for (int i = 0; i < 4; i++) recipe.add(new ItemStack(ingredient.getItem(), 1, ingredient.getItemDamage()));
        arecipes.add(new CachedShapelessRecipe(recipe, result));
    }
}
Also used : MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Example 9 with MinechemBucketItem

use of minechem.item.bucket.MinechemBucketItem in project Minechem by iopleke.

the class ChemicalFluidReactionHandler method checkEntityItem.

public void checkEntityItem(World world, EntityItem entityItem) {
    ItemStack itemStack = entityItem.getEntityItem();
    if (itemStack.stackSize <= 0) {
        return;
    }
    Item item = itemStack.getItem();
    MinechemChemicalType chemicalA = null;
    if (item instanceof MinechemBucketItem) {
        chemicalA = MinechemUtil.getChemical(((MinechemBucketItem) item).fluid);
    }
    if (chemicalA != null && (world.isMaterialInBB(entityItem.boundingBox, Material.water) || world.isMaterialInBB(entityItem.boundingBox, MinechemFluidBlock.materialFluidBlock))) {
        int x = MathHelper.floor_double(entityItem.posX);
        int y = MathHelper.floor_double(entityItem.posY);
        int z = MathHelper.floor_double(entityItem.posZ);
        Block block = world.getBlock(x, y, z);
        MinechemChemicalType chemicalB = MinechemUtil.getChemical(block);
        if (chemicalB != null) {
            ChemicalFluidReactionRule rule = new ChemicalFluidReactionRule(chemicalA, chemicalB);
            if (reactionRules.containsKey(rule)) {
                chemicalReaction(world, entityItem, x, y, z, rule, !(MinechemUtil.canDrain(world, block, x, y, z)));
                itemStack.stackSize--;
                entityItem.setEntityItemStack(itemStack);
                if (itemStack.stackSize <= 0) {
                    world.removeEntity(entityItem);
                }
                MinechemUtil.throwItemStack(world, new ItemStack(Items.bucket), x, y, z);
            }
        }
    }
}
Also used : Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) MinechemBucketItem(minechem.item.bucket.MinechemBucketItem) Block(net.minecraft.block.Block) MinechemFluidBlock(minechem.fluid.MinechemFluidBlock) ItemStack(net.minecraft.item.ItemStack) MinechemChemicalType(minechem.item.MinechemChemicalType)

Example 10 with MinechemBucketItem

use of minechem.item.bucket.MinechemBucketItem 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

MinechemBucketItem (minechem.item.bucket.MinechemBucketItem)10 ItemStack (net.minecraft.item.ItemStack)7 Item (net.minecraft.item.Item)6 ElementItem (minechem.item.element.ElementItem)4 MoleculeItem (minechem.item.molecule.MoleculeItem)4 ElementEnum (minechem.item.element.ElementEnum)3 Block (net.minecraft.block.Block)3 ArrayList (java.util.ArrayList)2 MinechemChemicalType (minechem.item.MinechemChemicalType)2 RadiationFluidTileEntity (minechem.radiation.RadiationFluidTileEntity)2 IInventory (net.minecraft.inventory.IInventory)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 World (net.minecraft.world.World)2 List (java.util.List)1 INoDecay (minechem.api.INoDecay)1 MinechemFluidBlock (minechem.fluid.MinechemFluidBlock)1 PotionChemical (minechem.potion.PotionChemical)1 RadiationInfo (minechem.radiation.RadiationInfo)1 EntityItem (net.minecraft.entity.item.EntityItem)1