mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-24 05:44:32 +00:00
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
46 lines
1.2 KiB
Java
46 lines
1.2 KiB
Java
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
public class ReagentStack {
|
|
|
|
public Reagent reagent;
|
|
public int amount;
|
|
|
|
public ReagentStack(Reagent reagent, int amount) {
|
|
this.reagent = reagent;
|
|
this.amount = amount;
|
|
}
|
|
|
|
public ReagentStack(ReagentStack reagentStack, int amount) {
|
|
this(reagentStack.reagent, amount);
|
|
}
|
|
|
|
public static ReagentStack loadReagentStackFromNBT(NBTTagCompound tag) {
|
|
Reagent reagent = ReagentRegistry.getReagentForKey(tag.getString("Reagent"));
|
|
|
|
if (reagent == null) {
|
|
return null;
|
|
}
|
|
|
|
int amount = tag.getInteger("amount");
|
|
|
|
return new ReagentStack(reagent, amount);
|
|
}
|
|
|
|
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
|
tag.setString("Reagent", ReagentRegistry.getKeyForReagent(this.reagent));
|
|
tag.setInteger("amount", this.amount);
|
|
|
|
return tag;
|
|
}
|
|
|
|
public ReagentStack copy() {
|
|
return new ReagentStack(this.reagent, this.amount);
|
|
}
|
|
|
|
public boolean isReagentEqual(ReagentStack other) {
|
|
return other != null && this.reagent == other.reagent;
|
|
}
|
|
}
|