Build / build (push) Failing after 8m23s
来源 jar:[1.7.10] Thaumic Additions - 0.41.jar(liuhao/liangzishidai)。 反编译 307 个类(Fernflower,0 失败),资源 281 个;未编译验证。 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
87 lines
2.6 KiB
Java
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;
|
|
}
|
|
}
|