mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
don't resend effects when PlayerItemConsumeEvent is cancelled
This commit is contained in:
parent
f88986a2c2
commit
5e3ea5c8f9
@ -114,25 +114,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
this.sendLevelInfo(player, worldserver1);
|
||||
|
||||
@@ -0,0 +0,0 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl networkHandler) {
|
||||
+ // Paper start - collect packets
|
||||
+ this.sendActiveEffects(entity, networkHandler::send);
|
||||
+ }
|
||||
+ public void sendActiveEffects(LivingEntity entity, java.util.function.Consumer<Packet<? super net.minecraft.network.protocol.game.ClientGamePacketListener>> packetConsumer) {
|
||||
+ // Paper end - collect packets
|
||||
Iterator iterator = entity.getActiveEffects().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
|
||||
|
||||
- networkHandler.send(new ClientboundUpdateMobEffectPacket(entity.getId(), mobeffect, false));
|
||||
+ packetConsumer.accept(new ClientboundUpdateMobEffectPacket(entity.getId(), mobeffect, false)); // Paper - collect packets
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@ -201,6 +182,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
private void updatingUsingItem() {
|
||||
if (this.isUsingItem()) {
|
||||
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
|
||||
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.stopUsingItem(); // Paper - event is using an item, clear active item to reset its use
|
||||
// Update client
|
||||
Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
|
||||
- if (consumable != null) {
|
||||
+ if (false && consumable != null) { // Paper
|
||||
consumable.cancelUsingItem(entityPlayer, this.useItem);
|
||||
}
|
||||
entityPlayer.getBukkitEntity().updateInventory();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bucketable.java b/src/main/java/net/minecraft/world/entity/animal/Bucketable.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bucketable.java
|
||||
@ -215,26 +205,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
return Optional.of(InteractionResult.FAIL);
|
||||
}
|
||||
entity.playSound(((Bucketable) entity).getPickupSound(), 1.0F, 1.0F);
|
||||
diff --git a/src/main/java/net/minecraft/world/item/component/SuspiciousStewEffects.java b/src/main/java/net/minecraft/world/item/component/SuspiciousStewEffects.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/component/SuspiciousStewEffects.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/component/SuspiciousStewEffects.java
|
||||
@@ -0,0 +0,0 @@ public record SuspiciousStewEffects(List<SuspiciousStewEffects.Entry> effects) i
|
||||
// CraftBukkit start
|
||||
@Override
|
||||
public void cancelUsingItem(net.minecraft.server.level.ServerPlayer entityplayer, ItemStack itemstack) {
|
||||
+ final List<net.minecraft.network.protocol.Packet<? super net.minecraft.network.protocol.game.ClientGamePacketListener>> packets = new java.util.ArrayList<>(); // Paper - bundlize packets
|
||||
for (SuspiciousStewEffects.Entry suspicioussteweffects_a : this.effects) {
|
||||
- entityplayer.connection.send(new net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket(entityplayer.getId(), suspicioussteweffects_a.effect()));
|
||||
+ packets.add(new net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket(entityplayer.getId(), suspicioussteweffects_a.effect())); // Paper - bundlize packets
|
||||
}
|
||||
+ // Paper start - bundlize packets
|
||||
+ entityplayer.server.getPlayerList().sendActiveEffects(entityplayer, packets::add);
|
||||
+ entityplayer.connection.send(new net.minecraft.network.protocol.game.ClientboundBundlePacket(packets));
|
||||
+ // Paper end - bundlize packets
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
|
Loading…
Reference in New Issue
Block a user