mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-14 01:04:17 +00:00
Machine upgrades via capacitors now done.
This commit is contained in:
1 parent
bbef12c398
commit
0be34ac2ef
15 files changed
+130
-79
No files matched your search
@@ -165,7 +165,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
}
|
||||
|
||||
public void dropContent(int newSize, T inventory, World world, int xCoord, int yCoord, int zCoord) {
|
||||
for (int i = newSize; i < inventory.getSizeInventory(); i++) {
|
||||
for (int i = newSize; i < inventory.getSizeInventory() - 1; i++) { // -1 to leave capacitor in place
|
||||
ItemStack itemstack = inventory.getStackInSlot(i);
|
||||
if (itemstack == null) {
|
||||
continue;
|
||||
|
||||
@@ -14,6 +14,13 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
this.tileEntity = te;
|
||||
|
||||
addMachineSlots(playerInv);
|
||||
|
||||
addSlotToContainer(new Slot(te, te.inventory.length - 1, 12, 60) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return tileEntity.isItemValidForSlot(tileEntity.inventory.length - 1, itemStack);
|
||||
}
|
||||
});
|
||||
|
||||
// add players inventory
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
@@ -36,9 +43,10 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
|
||||
boolean hasOutput = tileEntity.getSizeInventory() > 1;
|
||||
int outputSlot = tileEntity.getSizeInventory() - 1;
|
||||
int startPlayerSlot = outputSlot + 1;
|
||||
boolean hasOutput = tileEntity.getSizeInventory() > 2; //Assume one input and capacitor
|
||||
int outputSlot = tileEntity.getSizeInventory() - 2;
|
||||
int capacitorSlot = outputSlot + 1;
|
||||
int startPlayerSlot = capacitorSlot + 1;
|
||||
int endPlayerSlot = startPlayerSlot + 26;
|
||||
int startHotBarSlot = endPlayerSlot + 1;
|
||||
int endHotBarSlot = startHotBarSlot + 9;
|
||||
@@ -50,7 +58,7 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
ItemStack origStack = slot.getStack();
|
||||
copystack = origStack.copy();
|
||||
|
||||
if (hasOutput ? (slotIndex < outputSlot) : (slotIndex <= outputSlot)) {
|
||||
if ( (hasOutput ? (slotIndex < outputSlot) : (slotIndex <= outputSlot)) || slotIndex == capacitorSlot) {
|
||||
//merge from machine input slots to inventory
|
||||
if (!mergeItemStack(origStack, startPlayerSlot, endHotBarSlot, false)) {
|
||||
return null;
|
||||
@@ -61,8 +69,8 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
if (!mergeItemStack(origStack, startPlayerSlot, endHotBarSlot, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
} else /* if (slotIndex > outputSlot) */{ // from inventory into inputs
|
||||
|
||||
} else /* if (slotIndex > capacitorSlot) */{ // from inventory into inputs
|
||||
|
||||
boolean merged = false;
|
||||
for (int i = 0; (hasOutput ? (i < outputSlot) : (i <= outputSlot)) && !merged; i++) {
|
||||
@@ -70,6 +78,11 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
merged = mergeItemStack(origStack, i, i + 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
//check for capacitor mergers
|
||||
if(!merged) {
|
||||
merged = mergeItemStack(origStack, capacitorSlot, capacitorSlot + 1, false);
|
||||
}
|
||||
|
||||
// If we cant merge into the machine, see if we can merge stacks within
|
||||
// the inventory
|
||||
|
||||
@@ -2,6 +2,7 @@ package crazypants.enderio.machine;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.PacketHandler;
|
||||
import crazypants.enderio.power.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -23,47 +24,55 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
|
||||
// Client sync monitoring
|
||||
protected int ticksSinceSync = -1;
|
||||
protected boolean firstUpdate = true;
|
||||
protected boolean forceClientUpdate = true;
|
||||
protected boolean lastActive;
|
||||
protected float lastSyncPowerStored = -1;
|
||||
|
||||
// Power
|
||||
protected ICapacitor capacitor;
|
||||
// Power
|
||||
protected Capacitors capacitorType;
|
||||
|
||||
// Used on the client as the power provided isn't sinked
|
||||
private float storedEnergy;
|
||||
|
||||
|
||||
protected ItemStack[] inventory;
|
||||
protected final int inventorySize;
|
||||
|
||||
protected PowerHandler powerHandler;
|
||||
|
||||
|
||||
protected RedstoneControlMode redstoneControlMode;
|
||||
|
||||
protected boolean redstoneCheckPassed;
|
||||
|
||||
public AbstractMachineEntity(int inventorySize, Type powerType) {
|
||||
this.inventorySize = inventorySize;
|
||||
this.inventorySize = inventorySize + 1; //plus one for capacitor
|
||||
facing = 3;
|
||||
capacitor = Capacitors.BASIC_CAPACITOR.capacitor;
|
||||
powerHandler = PowerHandlerUtil.createHandler(capacitor, this, powerType);
|
||||
|
||||
inventory = new ItemStack[inventorySize];
|
||||
|
||||
capacitorType = Capacitors.BASIC_CAPACITOR;
|
||||
powerHandler = PowerHandlerUtil.createHandler(capacitorType.capacitor, this, powerType);
|
||||
|
||||
inventory = new ItemStack[inventorySize];
|
||||
|
||||
redstoneControlMode = RedstoneControlMode.IGNORE;
|
||||
}
|
||||
|
||||
public final boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
if(i == inventorySize - 1) {
|
||||
return itemstack.itemID == ModObject.itemBasicCapacitor.actualId && itemstack.getItemDamage() > 0;
|
||||
}
|
||||
return isMachineItemValidForSlot(i, itemstack);
|
||||
}
|
||||
|
||||
protected abstract boolean isMachineItemValidForSlot(int i, ItemStack itemstack);
|
||||
|
||||
public AbstractMachineEntity(int inventorySize) {
|
||||
this(inventorySize, Type.MACHINE);
|
||||
}
|
||||
|
||||
|
||||
public RedstoneControlMode getRedstoneControlMode() {
|
||||
return redstoneControlMode;
|
||||
}
|
||||
|
||||
public void setRedstoneControlMode(RedstoneControlMode redstoneControlMode) {
|
||||
this.redstoneControlMode = redstoneControlMode;
|
||||
this.redstoneControlMode = redstoneControlMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,7 +83,7 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
@Override
|
||||
public void applyPerdition() {
|
||||
// TODO Apply values derived capcitor
|
||||
|
||||
|
||||
}
|
||||
|
||||
public short getFacing() {
|
||||
@@ -103,30 +112,30 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
}
|
||||
|
||||
public ICapacitor getCapacitor() {
|
||||
return capacitor;
|
||||
return capacitorType.capacitor;
|
||||
}
|
||||
|
||||
public int getEnergyStoredScaled(int scale) {
|
||||
// NB: called on the client so can't use the power provider
|
||||
return (int) (scale * (storedEnergy / capacitor.getMaxEnergyStored()));
|
||||
return (int) (scale * (storedEnergy / capacitorType.capacitor.getMaxEnergyStored()));
|
||||
}
|
||||
|
||||
|
||||
public float getEnergyStored() {
|
||||
return storedEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
// Needs NBT support for this
|
||||
// public void setCapacitor(ICapacitor capacitor) {
|
||||
// this.capacitor = capacitor;
|
||||
// powerProvider.setCapacitor(capacitor);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
public void setCapacitor(Capacitors capacitorType) {
|
||||
this.capacitorType = capacitorType;
|
||||
PowerHandlerUtil.configure(powerHandler, capacitorType.capacitor);
|
||||
forceClientUpdate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@@ -136,7 +145,7 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
}
|
||||
|
||||
protected float getPowerUsePerTick() {
|
||||
return capacitor.getMaxEnergyExtracted();
|
||||
return capacitorType.capacitor.getMaxEnergyExtracted();
|
||||
}
|
||||
|
||||
// --- Process Loop
|
||||
@@ -158,37 +167,35 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
return;
|
||||
|
||||
} // else is server, do all logic only on the server
|
||||
|
||||
float stored = powerHandler.getEnergyStored();
|
||||
|
||||
float stored = powerHandler.getEnergyStored();
|
||||
powerHandler.update();
|
||||
powerHandler.setEnergy(stored);
|
||||
|
||||
boolean requiresClientSync = false;
|
||||
if (firstUpdate) {
|
||||
if (forceClientUpdate) {
|
||||
// First update, send state to client
|
||||
firstUpdate = false;
|
||||
forceClientUpdate = false;
|
||||
requiresClientSync = true;
|
||||
}
|
||||
|
||||
redstoneCheckPassed = true;
|
||||
if(redstoneControlMode == RedstoneControlMode.ON) {
|
||||
int powerLevel = worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord);
|
||||
if(powerLevel < 1) {
|
||||
if (redstoneControlMode == RedstoneControlMode.ON) {
|
||||
int powerLevel = worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord);
|
||||
if (powerLevel < 1) {
|
||||
redstoneCheckPassed = false;
|
||||
}
|
||||
} else if(redstoneControlMode == RedstoneControlMode.OFF) {
|
||||
int powerLevel = worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord);
|
||||
if(powerLevel > 0) {
|
||||
}
|
||||
} else if (redstoneControlMode == RedstoneControlMode.OFF) {
|
||||
int powerLevel = worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord);
|
||||
if (powerLevel > 0) {
|
||||
redstoneCheckPassed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
requiresClientSync |= processTasks(redstoneCheckPassed);
|
||||
|
||||
|
||||
// Update if our power has changed by more than 1%
|
||||
requiresClientSync |= Math.abs(lastSyncPowerStored - powerHandler.getEnergyStored()) > powerHandler.getMaxEnergyStored() / 100;
|
||||
requiresClientSync |= Math.abs(lastSyncPowerStored - powerHandler.getEnergyStored()) > powerHandler.getMaxEnergyStored() / 100;
|
||||
|
||||
if (requiresClientSync) {
|
||||
lastSyncPowerStored = powerHandler.getEnergyStored();
|
||||
@@ -204,12 +211,9 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
|
||||
protected abstract boolean processTasks(boolean redstoneCheckPassed);
|
||||
|
||||
|
||||
// ---- Tile Entity
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
return PacketHandler.getPacket(this);
|
||||
@@ -220,12 +224,14 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
super.readFromNBT(nbtRoot);
|
||||
|
||||
facing = nbtRoot.getShort("facing");
|
||||
|
||||
setCapacitor(Capacitors.values()[nbtRoot.getShort("capacitorType")]);
|
||||
|
||||
float storedEnergy = nbtRoot.getFloat("storedEnergy");
|
||||
powerHandler.setEnergy(storedEnergy);
|
||||
// For the client as provider is not saved to NBT
|
||||
this.storedEnergy = storedEnergy;
|
||||
|
||||
|
||||
// read in the inventories contents
|
||||
inventory = new ItemStack[inventorySize];
|
||||
NBTTagList itemList = nbtRoot.getTagList("Items");
|
||||
@@ -237,13 +243,13 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
inventory[slot] = ItemStack.loadItemStackFromNBT(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int rsContr = nbtRoot.getInteger("redstoneControlMode");
|
||||
if(rsContr < 0 || rsContr >= RedstoneControlMode.values().length) {
|
||||
if (rsContr < 0 || rsContr >= RedstoneControlMode.values().length) {
|
||||
rsContr = 0;
|
||||
}
|
||||
redstoneControlMode = RedstoneControlMode.values()[rsContr];
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -251,7 +257,8 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
super.writeToNBT(nbtRoot);
|
||||
nbtRoot.setShort("facing", facing);
|
||||
nbtRoot.setFloat("storedEnergy", powerHandler.getEnergyStored());
|
||||
|
||||
nbtRoot.setShort("capacitorType", (short)capacitorType.ordinal());
|
||||
|
||||
// write inventory list
|
||||
NBTTagList itemList = new NBTTagList();
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
@@ -262,19 +269,19 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
itemList.appendTag(itemStackNBT);
|
||||
}
|
||||
}
|
||||
nbtRoot.setTag("Items", itemList);
|
||||
|
||||
nbtRoot.setTag("Items", itemList);
|
||||
|
||||
nbtRoot.setInteger("redstoneControlMode", redstoneControlMode.ordinal());
|
||||
}
|
||||
|
||||
// ---- Inventory
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
if (worldObj == null) {
|
||||
@@ -309,6 +316,7 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
}
|
||||
if (fromStack.stackSize <= amount) {
|
||||
inventory[fromSlot] = null;
|
||||
updateCapacitorFromSlot();
|
||||
return fromStack;
|
||||
}
|
||||
ItemStack result = new ItemStack(fromStack.itemID, amount, fromStack.getItemDamage());
|
||||
@@ -330,6 +338,19 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
if (contents != null && contents.stackSize > getInventoryStackLimit()) {
|
||||
contents.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
if(slot == inventory.length - 1) {
|
||||
updateCapacitorFromSlot();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCapacitorFromSlot() {
|
||||
ItemStack contents = inventory[inventory.length - 1];
|
||||
if(contents == null) {
|
||||
setCapacitor(Capacitors.BASIC_CAPACITOR);
|
||||
} else {
|
||||
setCapacitor(Capacitors.values()[contents.getItemDamage()]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -345,9 +366,7 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
public void closeChest() {
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(int blockId) {
|
||||
public void onNeighborBlockChange(int blockId) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -41,8 +41,8 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
int outputIndex = inventory.length - 1;
|
||||
if (outputIndex != 2) {
|
||||
int outputIndex = inventory.length - 2;
|
||||
if (outputIndex != i) {
|
||||
return false;
|
||||
}
|
||||
if (inventory[outputIndex] == null || inventory[outputIndex].stackSize < itemstack.stackSize) {
|
||||
@@ -94,7 +94,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
}
|
||||
|
||||
protected void taskComplete() {
|
||||
int outputIndex = inventory.length - 1;
|
||||
int outputIndex = inventory.length - 2;
|
||||
if (currentTask != null) {
|
||||
ItemStack result = currentTask.getCompletedResult()[0];
|
||||
if (inventory[outputIndex] == null) {
|
||||
@@ -109,7 +109,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
}
|
||||
|
||||
protected RecipeInput[] getInputs() {
|
||||
RecipeInput[] res = new RecipeInput[inventorySize - 1];
|
||||
RecipeInput[] res = new RecipeInput[inventorySize - 2];
|
||||
for(int i=0;i < res.length;i++) {
|
||||
res[i] = new RecipeInput(i, inventory[i]);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
return null; // no template
|
||||
}
|
||||
|
||||
int outputIndex = inventory.length - 1;
|
||||
int outputIndex = inventory.length - 2;
|
||||
// make sure we can merge the recipe output with our result
|
||||
if (inventory[outputIndex] == null) {
|
||||
return nextRecipe;
|
||||
@@ -147,7 +147,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity im
|
||||
}
|
||||
|
||||
protected boolean canMergeWithCurrentOuput(ItemStack nextResult) {
|
||||
if (!nextResult.isItemEqual(inventory[inventory.length - 1])) {
|
||||
if (!nextResult.isItemEqual(inventory[inventory.length - 2])) {
|
||||
// next result is a different item type
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class GuiMachineBase extends GuiContainerBase {
|
||||
|
||||
protected static final int POWER_Y = 14;
|
||||
protected final int POWER_X = 15;
|
||||
protected static final int POWER_WIDTH = 11;
|
||||
protected static final int POWER_WIDTH = 10;
|
||||
protected static final int POWER_HEIGHT = 42;
|
||||
protected static final int BOTTOM_POWER_Y = POWER_Y + POWER_HEIGHT;
|
||||
|
||||
@@ -118,7 +118,7 @@ public abstract class GuiMachineBase extends GuiContainerBase {
|
||||
int l = (height - ySize) / 2;
|
||||
int i1 = tileEntity.getEnergyStoredScaled(POWER_HEIGHT);
|
||||
//x, y, u, v, width, height
|
||||
drawTexturedModalRect(k + POWER_X, l + BOTTOM_POWER_Y - i1, 176, 31, 11, i1);
|
||||
drawTexturedModalRect(k + POWER_X, l + BOTTOM_POWER_Y - i1, 176, 31, POWER_WIDTH, i1);
|
||||
|
||||
for (int i = 0; i < buttonList.size(); ++i) {
|
||||
GuiButton guibutton = (GuiButton)this.buttonList.get(i);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class TileAlloySmelter extends AbstractPoweredTaskEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
public boolean isMachineItemValidForSlot(int i, ItemStack itemstack) {
|
||||
if(i >= 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class TileEntityStirlingGenerator extends AbstractMachineEntity implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
public boolean isMachineItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return TileEntityFurnace.isItemFuel(itemstack);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class TileEntityStirlingGenerator extends AbstractMachineEntity implement
|
||||
powerHandler.update();
|
||||
return false;
|
||||
}
|
||||
float canTransmit = Math.min(powerHandler.getEnergyStored(), capacitor.getMaxEnergyExtracted());
|
||||
float canTransmit = Math.min(powerHandler.getEnergyStored(), capacitorType.capacitor.getMaxEnergyExtracted());
|
||||
float transmitted = 0;
|
||||
|
||||
float stored = powerHandler.getEnergyStored();
|
||||
|
||||
@@ -25,7 +25,7 @@ public class TileEntityPainter extends AbstractPoweredTaskEntity implements ISid
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
public boolean isMachineItemValidForSlot(int i, ItemStack itemStack) {
|
||||
if (i > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package crazypants.enderio.power;
|
||||
|
||||
import crazypants.enderio.ModObject;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public enum Capacitors {
|
||||
@@ -27,5 +28,9 @@ public enum Capacitors {
|
||||
this.iconKey = "enderio:" + iconKey;
|
||||
this.unlocalisedName = name();
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return new ItemStack(ModObject.itemBasicCapacitor.actualId,1,ordinal());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,11 +16,22 @@ public class PowerHandlerUtil {
|
||||
public static PowerHandler createHandler(ICapacitor capacitor, IPowerReceptor pr, Type type) {
|
||||
PowerHandler ph = new PowerHandler(pr, type);
|
||||
ph.configure(capacitor.getMinEnergyReceived(),capacitor.getMaxEnergyReceived(),capacitor.getMinActivationEnergy(),capacitor.getMaxEnergyStored());
|
||||
//TODO: Setup perdition properly
|
||||
ph.configurePowerPerdition(0, 0);
|
||||
ph.setPerdition(new NullPerditionCalculator());
|
||||
return ph;
|
||||
}
|
||||
|
||||
public static void configure(PowerHandler ph, ICapacitor capacitor) {
|
||||
ph.configure(capacitor.getMinEnergyReceived(),capacitor.getMaxEnergyReceived(),capacitor.getMinActivationEnergy(),capacitor.getMaxEnergyStored());
|
||||
if(ph.getEnergyStored() > ph.getMaxEnergyStored()) {
|
||||
ph.setEnergy(ph.getMaxEnergyStored());
|
||||
}
|
||||
//TODO: Setup perdition properly
|
||||
ph.configurePowerPerdition(0, 0);
|
||||
ph.setPerdition(new NullPerditionCalculator());
|
||||
}
|
||||
|
||||
public static float transmitInternal(IInternalPowerReceptor receptor, PowerReceiver pp, float quantity, Type type, ForgeDirection from) {
|
||||
float used = quantity;
|
||||
|
||||
@@ -89,7 +100,10 @@ public class PowerHandlerUtil {
|
||||
}
|
||||
float res = current - 0.001f;
|
||||
if(res >= current) {
|
||||
System.out.println("PowerHandlerUtil.NullPerditionCalculator.applyPerdition: Fail! current is: " + current + " res is:" + res);
|
||||
res -= 0.01f;
|
||||
if(res >= current) {
|
||||
System.out.println("PowerHandlerUtil.NullPerditionCalculator.applyPerdition: Fail! current is: " + current + " res is:" + res);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Reference in new issue
Block a user