1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Fixed Reactor Overflows

This commit is contained in:
TheBusyBiscuit 2018-05-11 13:11:13 +02:00 committed by GitHub
parent 2ef7fbd575
commit 340fc046d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -308,11 +308,13 @@ public abstract class AReactor extends SlimefunItem {
extraTick(l); extraTick(l);
int timeleft = progress.get(l); int timeleft = progress.get(l);
if (timeleft > 0) { if (timeleft > 0) {
boolean should_charge = ChargableBlock.getMaxCharge(l) - ChargableBlock.getCharge(l) >= getEnergyProduction(); int produced = getEnergyProduction();
if (should_charge) { int space = ChargableBlock.getMaxCharge(l) - ChargableBlock.getCharge(l);
if (space >= produced) {
ChargableBlock.addCharge(l, getEnergyProduction()); ChargableBlock.addCharge(l, getEnergyProduction());
space -= produced;
} }
if (should_charge || !BlockStorage.getBlockInfo(l, "reactor-mode").equals("generator")) { if (space >= produced || !BlockStorage.getBlockInfo(l, "reactor-mode").equals("generator")) {
progress.put(l, timeleft - 1); progress.put(l, timeleft - 1);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {