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;
}
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;
}
}
}
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);
}
}
}
}
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) {
}
}
}
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);
}
Aggregations