Negative Alc saving fix

This commit is contained in:
Sn0wStorm 2021-04-07 15:32:37 +02:00
parent 02f2e0c966
commit 556ce7ed34
2 changed files with 15 additions and 9 deletions

View File

@ -1005,18 +1005,20 @@ public class Brew implements Cloneable {
quality = 10;
}
alc = Math.min(alc, Short.MAX_VALUE);
alc = Math.max(alc, Short.MIN_VALUE);
out.writeByte((byte) quality);
int bools = 0;
bools |= ((distillRuns != 0) ? 1 : 0);
bools |= (ageTime > 0 ? 2 : 0);
bools |= (wood != -1 ? 4 : 0);
bools |= ((distillRuns != 0) ? 1 : 0);
bools |= (ageTime > 0 ? 2 : 0);
bools |= (wood != -1 ? 4 : 0);
bools |= (currentRecipe != null ? 8 : 0);
bools |= (unlabeled ? 16 : 0);
bools |= (immutable ? 32 : 0);
bools |= (alc > 0 ? 64 : 0);
bools |= (stripped ? 128 : 0);
bools |= (unlabeled ? 16 : 0);
bools |= (immutable ? 32 : 0);
bools |= (alc != 0 ? 64 : 0);
bools |= (stripped ? 128 : 0);
out.writeByte(bools);
if (alc > 0) {
if (alc != 0) {
out.writeShort(alc);
}
if (distillRuns != 0) {
@ -1143,7 +1145,7 @@ public class Brew implements Cloneable {
if (brew.quality != 0) {
idConfig.set("quality", brew.quality);
}
if (brew.alc > 0) {
if (brew.alc != 0) {
idConfig.set("alc", brew.alc);
}
if (brew.distillRuns != 0) {

View File

@ -8,6 +8,7 @@ import com.dre.brewery.utility.LegacyUtil;
import com.dre.brewery.utility.PermissionUtil;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -40,6 +41,9 @@ public class PlayerListener implements Listener {
if (Brew.isBrew(item)) {
event.setCancelled(true);
BUtil.setItemInHand(event, Material.GLASS_BOTTLE, false);
if (P.use1_11) {
clickedBlock.getWorld().playSound(clickedBlock.getLocation(), Sound.ITEM_BOTTLE_EMPTY, 1f, 1f);
}
}
}
}