2020-10-19 16:42:19 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com>
|
|
|
|
Date: Mon, 19 Oct 2020 15:56:47 +0300
|
|
|
|
Subject: [PATCH] PaperPR: Fix harming potion dupe
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemPotion.java b/src/main/java/net/minecraft/server/ItemPotion.java
|
2020-10-22 13:37:58 +02:00
|
|
|
index 7862b63a245222d9a3d0896bdb2741b0e5e7ac40..47a6e8428f5a9dd19514ee0ad487bcb16dc34214 100644
|
2020-10-19 16:42:19 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemPotion.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemPotion.java
|
|
|
|
@@ -22,6 +22,8 @@ public class ItemPotion extends Item {
|
|
|
|
CriterionTriggers.z.a((EntityPlayer) entityhuman, itemstack);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ List<MobEffect> instantLater = new net.yatopia.server.list.GlueList<>(); // Yatopia
|
|
|
|
+
|
|
|
|
if (!world.isClientSide) {
|
|
|
|
List<MobEffect> list = PotionUtil.getEffects(itemstack);
|
|
|
|
Iterator iterator = list.iterator();
|
|
|
|
@@ -30,7 +32,7 @@ public class ItemPotion extends Item {
|
|
|
|
MobEffect mobeffect = (MobEffect) iterator.next();
|
|
|
|
|
|
|
|
if (mobeffect.getMobEffect().isInstant()) {
|
|
|
|
- mobeffect.getMobEffect().applyInstantEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D);
|
|
|
|
+ instantLater.add(mobeffect); // Yatopia
|
|
|
|
} else {
|
|
|
|
entityliving.addEffect(new MobEffect(mobeffect), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit
|
|
|
|
}
|
2020-10-22 13:37:58 +02:00
|
|
|
@@ -44,7 +46,24 @@ public class ItemPotion extends Item {
|
2020-10-19 16:42:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Yatopia start - fix harming potion dupe
|
|
|
|
+ if (!world.isClientSide) {
|
2020-10-22 13:37:58 +02:00
|
|
|
+ int len = instantLater.size();
|
|
|
|
+ while (len > 0) {
|
|
|
|
+ MobEffect mobeffect = instantLater.remove(0);
|
2020-10-19 16:42:19 +02:00
|
|
|
+ mobeffect.getMobEffect().applyInstantEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D);
|
2020-10-22 13:37:58 +02:00
|
|
|
+ len--;
|
2020-10-19 16:42:19 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Yatopia end
|
|
|
|
+
|
|
|
|
if (entityhuman == null || !entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
+ // Yatopia start - fix harming potion dupe
|
|
|
|
+ if (entityliving.getHealth() <= 0 && !(entityhuman != null && entityliving.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY))) {
|
|
|
|
+ entityliving.dropItem(new ItemStack(Items.GLASS_BOTTLE), 0);
|
|
|
|
+ return ItemStack.NULL_ITEM;
|
|
|
|
+ }
|
|
|
|
+ // Yatopia end
|
|
|
|
if (itemstack.isEmpty()) {
|
|
|
|
return new ItemStack(Items.GLASS_BOTTLE);
|
|
|
|
}
|