Class AmadronTradeResource
java.lang.Object
me.desht.pneumaticcraft.api.crafting.AmadronTradeResource
Represents an Amadron trade resource. The input and output may be either an item or a fluid.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(Consumer<net.minecraft.world.item.ItemStack> cItemStack, Consumer<net.minecraftforge.fluids.FluidStack> cFluidStack) Run something against the resource, dependent on whether it's an item or a fluid<T> Tapply(Function<net.minecraft.world.item.ItemStack, T> fItemStack, Function<net.minecraftforge.fluids.FluidStack, T> fFluidStack) Run something against the resource, dependent on whether it's an item or a fluid, returning a resultintcountTradesInInventory(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> inv) intcountTradesInTank(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.fluids.capability.IFluidHandler> lazy) booleanbooleanequivalentTo(AmadronTradeResource other) Checks if these two resources are equivalent: same resource, but don't check amounts.intfindSpaceInFluidOutput(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.fluids.capability.IFluidHandler> lazy, int wantedTradeCount) intfindSpaceInItemOutput(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> inv, int wantedTradeCount) static AmadronTradeResourcefromJson(com.google.gson.JsonObject obj) static AmadronTradeResourcefromPacketBuf(net.minecraft.network.FriendlyByteBuf pb) intnet.minecraftforge.fluids.FluidStackgetFluid()Get the fluid for this trade resourcenet.minecraft.resources.ResourceLocationgetId()net.minecraft.world.item.ItemStackgetItem()Get the item for this trade resourcegetName()inthashCode()booleanisEmpty()static AmadronTradeResourceof(net.minecraft.world.item.ItemStack stack) static AmadronTradeResourceof(net.minecraftforge.fluids.FluidStack stack) com.google.gson.JsonObjecttoJson()toString()inttotalSpaceRequired(int units) The total space required for this resource, in stacks for an item resource, and in mB for a fluid resourcevalidate()voidwriteToBuf(net.minecraft.network.FriendlyByteBuf pb) net.minecraft.nbt.CompoundTag
-
Method Details
-
isEmpty
public boolean isEmpty() -
equivalentTo
Checks if these two resources are equivalent: same resource, but don't check amounts.- Parameters:
other- the trade resource to compare- Returns:
- true if the two are equivalent, false if not
-
of
-
of
-
fromPacketBuf
-
getItem
public net.minecraft.world.item.ItemStack getItem()Get the item for this trade resource- Returns:
- the itemstack, or ItemStack.EMPTY if the resource is a fluid
-
getFluid
public net.minecraftforge.fluids.FluidStack getFluid()Get the fluid for this trade resource- Returns:
- the fluidstack, or FluidStack.EMPTY if the resource is an item
-
accept
public void accept(Consumer<net.minecraft.world.item.ItemStack> cItemStack, Consumer<net.minecraftforge.fluids.FluidStack> cFluidStack) Run something against the resource, dependent on whether it's an item or a fluid- Parameters:
cItemStack- consumer which is called when the resource is an itemcFluidStack- consumer which is called when the resource is a fluid
-
apply
public <T> T apply(Function<net.minecraft.world.item.ItemStack, T> fItemStack, Function<net.minecraftforge.fluids.FluidStack, T> fFluidStack) Run something against the resource, dependent on whether it's an item or a fluid, returning a result- Parameters:
fItemStack- function which is called when the resource is an itemfFluidStack- function which is called when the resource is a fluid
-
totalSpaceRequired
public int totalSpaceRequired(int units) The total space required for this resource, in stacks for an item resource, and in mB for a fluid resource- Parameters:
units- number of offer units- Returns:
- total space required
-
countTradesInInventory
public int countTradesInInventory(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> inv) -
findSpaceInItemOutput
public int findSpaceInItemOutput(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> inv, int wantedTradeCount) -
countTradesInTank
public int countTradesInTank(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.fluids.capability.IFluidHandler> lazy) -
findSpaceInFluidOutput
public int findSpaceInFluidOutput(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.fluids.capability.IFluidHandler> lazy, int wantedTradeCount) -
validate
-
fromJson
public static AmadronTradeResource fromJson(com.google.gson.JsonObject obj) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
toJson
public com.google.gson.JsonObject toJson() -
writeToBuf
public void writeToBuf(net.minecraft.network.FriendlyByteBuf pb) -
getName
-
getId
public net.minecraft.resources.ResourceLocation getId() -
getAmount
public int getAmount() -
writeToNBT
public net.minecraft.nbt.CompoundTag writeToNBT() -
equals
-
hashCode
public int hashCode() -
toString
-