mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 05:28:59 +00:00
Fixes to the Brewing Stand for distilling
This commit is contained in:
@@ -2,6 +2,7 @@ package com.dre.brewery;
|
|||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.Levelled;
|
import org.bukkit.block.data.Levelled;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -97,12 +98,17 @@ public class BCauldron {
|
|||||||
if (potion != null) {
|
if (potion != null) {
|
||||||
|
|
||||||
if (P.use1_13) {
|
if (P.use1_13) {
|
||||||
Levelled cauldron = ((Levelled) block.getBlockData());
|
BlockData data = block.getBlockData();
|
||||||
|
Levelled cauldron = ((Levelled) data);
|
||||||
if (cauldron.getLevel() <= 0) {
|
if (cauldron.getLevel() <= 0) {
|
||||||
bcauldrons.remove(bcauldron);
|
bcauldrons.remove(bcauldron);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cauldron.setLevel(cauldron.getLevel() - 1);
|
cauldron.setLevel(cauldron.getLevel() - 1);
|
||||||
|
// Update the new Level to the Block
|
||||||
|
// We have to use the BlockData variable "data" here instead of the casted "cauldron"
|
||||||
|
// otherwise < 1.13 crashes on plugin load for not finding the BlockData Class
|
||||||
|
block.setBlockData(data);
|
||||||
|
|
||||||
if (cauldron.getLevel() <= 0) {
|
if (cauldron.getLevel() <= 0) {
|
||||||
bcauldrons.remove(bcauldron);
|
bcauldrons.remove(bcauldron);
|
||||||
|
|||||||
@@ -727,10 +727,12 @@ public class Brew {
|
|||||||
|
|
||||||
public void colorBrew(PotionMeta meta, ItemStack potion, boolean destillable) {
|
public void colorBrew(PotionMeta meta, ItemStack potion, boolean destillable) {
|
||||||
if (P.use1_9) {
|
if (P.use1_9) {
|
||||||
meta.setBasePotionData(new PotionData(getType()));
|
|
||||||
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
|
||||||
if (P.use1_12) {
|
if (P.use1_12) {
|
||||||
|
// BasePotionData was only used for the Color, so starting with 1.12 we can use setColor instead
|
||||||
meta.setColor(getColor());
|
meta.setColor(getColor());
|
||||||
|
} else {
|
||||||
|
meta.setBasePotionData(new PotionData(getType()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
potion.setDurability(getColorId(destillable));
|
potion.setDurability(getColorId(destillable));
|
||||||
|
|||||||
@@ -124,11 +124,18 @@ public class InventoryListener implements Listener {
|
|||||||
case 1:
|
case 1:
|
||||||
// Custom potion but not for distilling. Stop any brewing and cancel this task
|
// Custom potion but not for distilling. Stop any brewing and cancel this task
|
||||||
if (stand.getBrewingTime() > 0) {
|
if (stand.getBrewingTime() > 0) {
|
||||||
// Brewing time is sent and stored as short
|
if (P.use1_12) {
|
||||||
// This sends a negative short value to the Client
|
// The trick below doesnt work in 1.12, but we dont need it anymore
|
||||||
// In the client the Brewer will look like it is not doing anything
|
// This should only happen with older Brews that have been made with the old Potion Color System
|
||||||
stand.setBrewingTime(Short.MAX_VALUE << 1);
|
stand.setBrewingTime(Short.MAX_VALUE);
|
||||||
|
} else {
|
||||||
|
// Brewing time is sent and stored as short
|
||||||
|
// This sends a negative short value to the Client
|
||||||
|
// In the client the Brewer will look like it is not doing anything
|
||||||
|
stand.setBrewingTime(Short.MAX_VALUE << 1);
|
||||||
|
}
|
||||||
stand.setFuelLevel(fuel);
|
stand.setFuelLevel(fuel);
|
||||||
|
stand.update();
|
||||||
}
|
}
|
||||||
case 0:
|
case 0:
|
||||||
// No custom potion, cancel and ignore
|
// No custom potion, cancel and ignore
|
||||||
@@ -148,19 +155,20 @@ public class InventoryListener implements Listener {
|
|||||||
stand.setBrewingTime((int) ((float) brewTime / ((float) runTime / (float) DISTILLTIME)) + 1);
|
stand.setBrewingTime((int) ((float) brewTime / ((float) runTime / (float) DISTILLTIME)) + 1);
|
||||||
|
|
||||||
if (brewTime <= 1) { // Done!
|
if (brewTime <= 1) { // Done!
|
||||||
|
stand.setBrewingTime(0);
|
||||||
|
stand.update();
|
||||||
BrewerInventory brewer = stand.getInventory();
|
BrewerInventory brewer = stand.getInventory();
|
||||||
if (!runDistill(brewer)) {
|
if (!runDistill(brewer)) {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
trackedBrewers.remove(brewery);
|
trackedBrewers.remove(brewery);
|
||||||
stand.setBrewingTime(0);
|
|
||||||
P.p.debugLog("All done distilling");
|
P.p.debugLog("All done distilling");
|
||||||
} else {
|
} else {
|
||||||
brewTime = -1; // go again.
|
brewTime = -1; // go again.
|
||||||
stand.setBrewingTime(0);
|
|
||||||
P.p.debugLog("Can distill more! Continuing.");
|
P.p.debugLog("Can distill more! Continuing.");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
stand.update();
|
||||||
}
|
}
|
||||||
stand.update();
|
|
||||||
} else {
|
} else {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
trackedBrewers.remove(brewery);
|
trackedBrewers.remove(brewery);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class TabListener implements TabCompleter {
|
|||||||
private static final List<String> topCompletions = new ArrayList<>(2);
|
private static final List<String> topCompletions = new ArrayList<>(2);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
completions.put("", Arrays.asList("info", "unlabel"));
|
completions.put("", Arrays.asList("info", "unlabel", "help"));
|
||||||
topCompletions.add("brew");
|
topCompletions.add("brew");
|
||||||
//topCompletions.add("brewery");
|
//topCompletions.add("brewery");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user