Files
thaumicadditions/src/main/java/com/mrdimka/api/power/rj/ItemRJContainer.java
T
layue13andClaude Sonnet 5.5 e66978155d
Build / build (push) Failing after 8m23s
Thaumic Additions 0.41 (1.7.10):从 jar 反编译的源码和 GTNH 约定的 Gradle 构建
来源 jar:[1.7.10] Thaumic Additions - 0.41.jar(liuhao/liangzishidai)。
反编译 307 个类(Fernflower,0 失败),资源 281 个;未编译验证。

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-11 03:40:40 -07:00

87 lines
2.6 KiB
Java

package com.mrdimka.api.power.rj;
import com.mrdimka.api.power.rj.IRJContainerItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ItemRJContainer extends Item implements IRJContainerItem {
protected int capacity;
protected int maxReceive;
protected int maxExtract;
public ItemRJContainer() {}
public ItemRJContainer(int capacity) {
this(capacity, capacity, capacity);
}
public ItemRJContainer(int capacity, int maxTransfer) {
this(capacity, maxTransfer, maxTransfer);
}
public ItemRJContainer(int capacity, int maxReceive, int maxExtract) {
this.capacity = capacity;
this.maxReceive = maxReceive;
this.maxExtract = maxExtract;
}
public ItemRJContainer setCapacity(int capacity) {
this.capacity = capacity;
return this;
}
public void setMaxTransfer(int maxTransfer) {
this.setMaxReceive(maxTransfer);
this.setMaxExtract(maxTransfer);
}
public void setMaxReceive(int maxReceive) {
this.maxReceive = maxReceive;
}
public void setMaxExtract(int maxExtract) {
this.maxExtract = maxExtract;
}
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
if(container.field_77990_d == null) {
container.field_77990_d = new NBTTagCompound();
}
int energy = container.field_77990_d.func_74762_e("Energy");
int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive));
if(!simulate) {
energy += energyReceived;
container.field_77990_d.func_74768_a("Energy", energy);
}
return energyReceived;
}
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
if(container.field_77990_d != null && container.field_77990_d.func_74764_b("Energy")) {
int energy = container.field_77990_d.func_74762_e("Energy");
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
if(!simulate) {
energy -= energyExtracted;
container.field_77990_d.func_74768_a("Energy", energy);
}
return energyExtracted;
} else {
return 0;
}
}
public int getEnergyStored(ItemStack container) {
return container.field_77990_d != null && container.field_77990_d.func_74764_b("Energy")?container.field_77990_d.func_74762_e("Energy"):0;
}
public int getMaxEnergyStored(ItemStack container) {
return this.capacity;
}
}