mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-26 21:51:21 +01:00
Some BDistiller cleanup
This commit is contained in:
parent
c474ccb9dd
commit
95f59a5982
@ -89,7 +89,7 @@ public class BDistiller {
|
|||||||
for (int slot = 0; slot < 3; slot++) {
|
for (int slot = 0; slot < 3; slot++) {
|
||||||
if (contents[slot] != null) {
|
if (contents[slot] != null) {
|
||||||
item = inv.getItem(slot);
|
item = inv.getItem(slot);
|
||||||
if (item == null || !Brew.isBrew(item)) {
|
if (!Brew.isBrew(item)) {
|
||||||
contents[slot] = null;
|
contents[slot] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ public class BDistiller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class DistillRunnable extends BukkitRunnable {
|
public class DistillRunnable extends BukkitRunnable {
|
||||||
Brew[] contents = null;
|
private Brew[] contents = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -176,6 +176,35 @@ public class BDistiller {
|
|||||||
if (now instanceof BrewingStand) {
|
if (now instanceof BrewingStand) {
|
||||||
BrewingStand stand = (BrewingStand) now;
|
BrewingStand stand = (BrewingStand) now;
|
||||||
if (brewTime == -1) { // only check at the beginning (and end) for distillables
|
if (brewTime == -1) { // only check at the beginning (and end) for distillables
|
||||||
|
prepareForDistillables(stand);
|
||||||
|
}
|
||||||
|
|
||||||
|
brewTime--; // count down.
|
||||||
|
stand.setBrewingTime((int) ((float) brewTime / ((float) runTime / (float) DISTILLTIME)) + 1);
|
||||||
|
|
||||||
|
if (brewTime <= 1) { // Done!
|
||||||
|
checkContents(stand.getInventory(), contents);
|
||||||
|
stand.setBrewingTime(0);
|
||||||
|
stand.update();
|
||||||
|
if (!runDistill(stand.getInventory(), contents)) {
|
||||||
|
this.cancel();
|
||||||
|
trackedDistillers.remove(standBlock);
|
||||||
|
P.p.debugLog("All done distilling");
|
||||||
|
} else {
|
||||||
|
brewTime = -1; // go again.
|
||||||
|
P.p.debugLog("Can distill more! Continuing.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stand.update();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.cancel();
|
||||||
|
trackedDistillers.remove(standBlock);
|
||||||
|
P.p.debugLog("The block was replaced; not a brewing stand.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepareForDistillables(BrewingStand stand) {
|
||||||
BrewerInventory inventory = stand.getInventory();
|
BrewerInventory inventory = stand.getInventory();
|
||||||
if (contents == null) {
|
if (contents == null) {
|
||||||
contents = getDistillContents(inventory);
|
contents = getDistillContents(inventory);
|
||||||
@ -213,30 +242,5 @@ public class BDistiller {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
brewTime--; // count down.
|
|
||||||
stand.setBrewingTime((int) ((float) brewTime / ((float) runTime / (float) DISTILLTIME)) + 1);
|
|
||||||
|
|
||||||
if (brewTime <= 1) { // Done!
|
|
||||||
checkContents(stand.getInventory(), contents);
|
|
||||||
stand.setBrewingTime(0);
|
|
||||||
stand.update();
|
|
||||||
if (!runDistill(stand.getInventory(), contents)) {
|
|
||||||
this.cancel();
|
|
||||||
trackedDistillers.remove(standBlock);
|
|
||||||
P.p.debugLog("All done distilling");
|
|
||||||
} else {
|
|
||||||
brewTime = -1; // go again.
|
|
||||||
P.p.debugLog("Can distill more! Continuing.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
stand.update();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.cancel();
|
|
||||||
trackedDistillers.remove(standBlock);
|
|
||||||
P.p.debugLog("The block was replaced; not a brewing stand.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user