Skip to content

Commit

Permalink
修复无线能源仓插入能量不正常的问题
Browse files Browse the repository at this point in the history
修复无线动力仓丢失能量的问题
  • Loading branch information
liansishen committed Aug 10, 2024
1 parent 836ad52 commit 80eb5a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ loom.platform=forge
quilt_mappings=23

# Mod Properties
mod_version=1.3.0
mod_version=1.3.1
maven_group=com.hepdd.gtmthings
archives_base_name=gtmthings
mod_id=gtmthings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.hepdd.gtmthings.common.block.machine.multiblock.part;

import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper;
import com.gregtechceu.gtceu.api.capability.IEnergyContainer;
import com.gregtechceu.gtceu.api.capability.recipe.IO;
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity;
import com.gregtechceu.gtceu.api.machine.TickableSubscription;
Expand Down Expand Up @@ -104,24 +106,23 @@ private void updateEnergy() {
} else {
addEnergy();
}
updateEnergySubscription();
}

private void useEnergy() {
var currentStored = energyContainer.getEnergyStored();
var maxStored = energyContainer.getEnergyCapacity();
var changeStored = Math.min(maxStored - currentStored,energyContainer.getInputVoltage() * energyContainer.getInputVoltage());
var changeStored = Math.min(maxStored - currentStored,energyContainer.getInputVoltage() * energyContainer.getInputAmperage());
if (changeStored <= 0) return;
if (!WirelessEnergyManager.addEUToGlobalEnergyMap(this.owner_uuid,-changeStored)) return;
energyContainer.setEnergyStored(maxStored);
energyContainer.setEnergyStored(currentStored + changeStored);
}

private void addEnergy() {
var currentStored = energyContainer.getEnergyStored();
if (currentStored <= 0) return;
var changeStored = Math.min(energyContainer.getOutputVoltage() * energyContainer.getOutputAmperage(),currentStored);
if(!WirelessEnergyManager.addEUToGlobalEnergyMap(this.owner_uuid,changeStored)) return;
energyContainer.setEnergyStored(0L);
energyContainer.setEnergyStored(currentStored - changeStored);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,23 @@ private void updateEnergy() {
} else {
addEnergy();
}
updateEnergySubscription();
}

private void useEnergy() {
var currentStored = energyContainer.getEnergyStored();
var maxStored = energyContainer.getEnergyCapacity();
var changeStored = Math.min(maxStored - currentStored,energyContainer.getInputVoltage() * energyContainer.getInputVoltage());
var changeStored = Math.min(maxStored - currentStored,energyContainer.getInputVoltage() * energyContainer.getInputAmperage());
if (changeStored <= 0) return;
if (!WirelessEnergyManager.addEUToGlobalEnergyMap(this.owner_uuid,-changeStored)) return;
energyContainer.setEnergyStored(maxStored);
energyContainer.setEnergyStored(currentStored + changeStored);
}

private void addEnergy() {
var currentStored = energyContainer.getEnergyStored();
if (currentStored <= 0) return;
var changeStored = Math.min(energyContainer.getOutputVoltage() * energyContainer.getOutputAmperage(),currentStored);
if(!WirelessEnergyManager.addEUToGlobalEnergyMap(this.owner_uuid,changeStored)) return;
energyContainer.setEnergyStored(0L);
energyContainer.setEnergyStored(currentStored - changeStored);
}

@Override
Expand Down

0 comments on commit 80eb5a4

Please sign in to comment.