Search in sources :

Example 26 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project PneumaticCraft by MineMaarten.

the class AmadronOffer method equals.

@Override
public boolean equals(Object o) {
    if (o instanceof AmadronOffer) {
        AmadronOffer offer = (AmadronOffer) o;
        if (offer.getInput().getClass() == getInput().getClass() && offer.getOutput().getClass() == getOutput().getClass()) {
            if (offer.getInput() instanceof ItemStack) {
                ItemStack s1 = (ItemStack) offer.getInput();
                ItemStack s2 = (ItemStack) getInput();
                if (!ItemStack.areItemStacksEqual(s1, s2))
                    return false;
            } else {
                FluidStack s1 = (FluidStack) offer.getInput();
                FluidStack s2 = (FluidStack) getInput();
                if (!s1.isFluidEqual(s2) || s1.amount != s2.amount)
                    return false;
            }
            if (offer.getOutput() instanceof ItemStack) {
                ItemStack s1 = (ItemStack) offer.getOutput();
                ItemStack s2 = (ItemStack) getOutput();
                if (!ItemStack.areItemStacksEqual(s1, s2))
                    return false;
            } else {
                FluidStack s1 = (FluidStack) offer.getOutput();
                FluidStack s2 = (FluidStack) getOutput();
                if (!s1.isFluidEqual(s2) || s1.amount != s2.amount)
                    return false;
            }
            return getVendor().equals(offer.getVendor());
        }
    }
    return false;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.item.ItemStack)

Example 27 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project PneumaticCraft by MineMaarten.

the class AmadronOfferCustom method returnStock.

public void returnStock() {
    TileEntity provider = getProvidingTileEntity();
    TileEntity returning = getReturningTileEntity();
    invert();
    while (inStock > 0) {
        int stock = Math.min(inStock, 50);
        stock = ContainerAmadron.capShoppingAmount(this, stock, returning instanceof IInventory ? (IInventory) returning : null, provider instanceof IInventory ? (IInventory) provider : null, returning instanceof IFluidHandler ? (IFluidHandler) returning : null, provider instanceof IFluidHandler ? (IFluidHandler) provider : null, null);
        if (stock > 0) {
            inStock -= stock;
            if (getInput() instanceof ItemStack) {
                ItemStack deliveringItems = (ItemStack) getInput();
                int amount = deliveringItems.stackSize * stock;
                List<ItemStack> stacks = new ArrayList<ItemStack>();
                while (amount > 0) {
                    ItemStack stack = deliveringItems.copy();
                    stack.stackSize = Math.min(amount, stack.getMaxStackSize());
                    stacks.add(stack);
                    amount -= stack.stackSize;
                }
                PneumaticRegistry.getInstance().deliverItemsAmazonStyle(provider.getWorldObj(), provider.xCoord, provider.yCoord, provider.zCoord, stacks.toArray(new ItemStack[stacks.size()]));
            } else {
                FluidStack deliveringFluid = ((FluidStack) getInput()).copy();
                deliveringFluid.amount *= stock;
                PneumaticRegistry.getInstance().deliverFluidAmazonStyle(provider.getWorldObj(), provider.xCoord, provider.yCoord, provider.zCoord, deliveringFluid);
            }
        } else {
            break;
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) FluidStack(net.minecraftforge.fluids.FluidStack) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 28 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project PneumaticCraft by MineMaarten.

the class AmadronOfferCustom method payout.

public void payout() {
    TileEntity returning = getReturningTileEntity();
    TileEntity provider = getProvidingTileEntity();
    if (pendingPayments > 0) {
        int paying = Math.min(pendingPayments, 50);
        paying = ContainerAmadron.capShoppingAmount(this, paying, provider instanceof IInventory ? (IInventory) provider : null, returning instanceof IInventory ? (IInventory) returning : null, provider instanceof IFluidHandler ? (IFluidHandler) provider : null, returning instanceof IFluidHandler ? (IFluidHandler) returning : null, null);
        if (paying > 0) {
            pendingPayments -= paying;
            if (getInput() instanceof ItemStack) {
                ItemStack deliveringItems = (ItemStack) getInput();
                int amount = deliveringItems.stackSize * paying;
                List<ItemStack> stacks = new ArrayList<ItemStack>();
                while (amount > 0) {
                    ItemStack stack = deliveringItems.copy();
                    stack.stackSize = Math.min(amount, stack.getMaxStackSize());
                    stacks.add(stack);
                    amount -= stack.stackSize;
                }
                PneumaticRegistry.getInstance().deliverItemsAmazonStyle(returning.getWorldObj(), returning.xCoord, returning.yCoord, returning.zCoord, stacks.toArray(new ItemStack[stacks.size()]));
            } else {
                FluidStack deliveringFluid = ((FluidStack) getInput()).copy();
                deliveringFluid.amount *= paying;
                PneumaticRegistry.getInstance().deliverFluidAmazonStyle(returning.getWorldObj(), returning.xCoord, returning.yCoord, returning.zCoord, deliveringFluid);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) FluidStack(net.minecraftforge.fluids.FluidStack) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 29 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project PneumaticCraft by MineMaarten.

the class CraftingRegistrator method registerAmadronOffers.

private static void registerAmadronOffers() {
    PneumaticRecipeRegistry registry = PneumaticRecipeRegistry.getInstance();
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 8), new ItemStack(Itemss.PCBBlueprint));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 8), new ItemStack(Itemss.assemblyProgram, 1, 0));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 8), new ItemStack(Itemss.assemblyProgram, 1, 1));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 14), new ItemStack(Itemss.assemblyProgram, 1, 2));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.oil, 5000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.diesel, 4000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.lubricant, 2500), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.kerosene, 3000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.gasoline, 2000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.lpg, 1000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald), new FluidStack(Fluids.oil, 1000));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 5), new FluidStack(Fluids.lubricant, 1000));
    for (int i = 0; i < 256; i++) {
        try {
            for (int j = 0; j < 10; j++) {
                EntityVillager villager = new EntityVillager(null, i);
                MerchantRecipeList list = villager.getRecipes(null);
                for (MerchantRecipe recipe : (List<MerchantRecipe>) list) {
                    if (recipe.getSecondItemToBuy() == null && recipe.getItemToBuy() != null && recipe.getItemToBuy().getItem() != null && recipe.getItemToSell() != null && recipe.getItemToSell().getItem() != null) {
                        registry.registerDefaultPeriodicAmadronOffer(recipe.getItemToBuy(), recipe.getItemToSell());
                    }
                }
            }
        } catch (Throwable e) {
        }
    }
}
Also used : MerchantRecipeList(net.minecraft.village.MerchantRecipeList) MerchantRecipe(net.minecraft.village.MerchantRecipe) IPneumaticRecipeRegistry(pneumaticCraft.api.recipe.IPneumaticRecipeRegistry) FluidStack(net.minecraftforge.fluids.FluidStack) EntityVillager(net.minecraft.entity.passive.EntityVillager) ArrayList(java.util.ArrayList) MerchantRecipeList(net.minecraft.village.MerchantRecipeList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Example 30 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project PneumaticCraft by MineMaarten.

the class CraftingRegistrator method addThermopneumaticProcessingPlantRecipes.

public static void addThermopneumaticProcessingPlantRecipes() {
    PneumaticRecipeRegistry registry = PneumaticRecipeRegistry.getInstance();
    registry.registerThermopneumaticProcessingPlantRecipe(new FluidStack(Fluids.lpg, 100), new ItemStack(Items.coal), new FluidStack(Fluids.plastic, 1000), 373, 0);
    registry.registerThermopneumaticProcessingPlantRecipe(new FluidStack(Fluids.diesel, 1000), new ItemStack(Items.redstone), new FluidStack(Fluids.lubricant, 1000), 373, 0);
    registry.registerThermopneumaticProcessingPlantRecipe(new FluidStack(Fluids.diesel, 100), null, new FluidStack(Fluids.kerosene, 80), 573, 2);
    registry.registerThermopneumaticProcessingPlantRecipe(new FluidStack(Fluids.kerosene, 100), null, new FluidStack(Fluids.gasoline, 80), 573, 2);
    registry.registerThermopneumaticProcessingPlantRecipe(new FluidStack(Fluids.gasoline, 100), null, new FluidStack(Fluids.lpg, 80), 573, 2);
}
Also used : IPneumaticRecipeRegistry(pneumaticCraft.api.recipe.IPneumaticRecipeRegistry) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

FluidStack (net.minecraftforge.fluids.FluidStack)188 ItemStack (net.minecraft.item.ItemStack)63 TileEntity (net.minecraft.tileentity.TileEntity)30 Fluid (net.minecraftforge.fluids.Fluid)28 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)25 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)19 ArrayList (java.util.ArrayList)18 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)16 Block (net.minecraft.block.Block)12 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 FluidTankInfo (net.minecraftforge.fluids.FluidTankInfo)10 Item (net.minecraft.item.Item)9 BlockPos (net.minecraft.util.math.BlockPos)9 HashMap (java.util.HashMap)6 FluidIdentifier (logisticspipes.utils.FluidIdentifier)6 StandardTank (mods.railcraft.common.fluids.tanks.StandardTank)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 PipeFluidTransportLogistics (logisticspipes.transport.PipeFluidTransportLogistics)5 IBlockState (net.minecraft.block.state.IBlockState)5 EnumFacing (net.minecraft.util.EnumFacing)5