From 68c0afa6b583f1f387bc9dcfeb44540bf349fa39 Mon Sep 17 00:00:00 2001 From: Mgazul Date: Fri, 31 Jan 2025 16:06:10 +0800 Subject: [PATCH] Fixed #3502 --- .../world/entity/projectile/Arrow.java.patch | 14 ++-- .../entity/projectile/ThrownPotion.java.patch | 5 +- .../block/entity/SignBlockEntity.java.patch | 67 +++++++++---------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/Arrow.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/Arrow.java.patch index 5c62a3e55f..30e72e7b47 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/Arrow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/Arrow.java.patch @@ -27,21 +27,21 @@ this.f_36853_ = true; this.f_19804_.m_135381_(f_36854_, p_36883_); } -@@ -178,14 +_,14 @@ +@@ -178,6 +_,7 @@ Entity entity = this.m_150173_(); for(MobEffectInstance mobeffectinstance : this.f_36855_.m_43488_()) { -- p_36873_.m_147207_(new MobEffectInstance(mobeffectinstance.m_19544_(), Math.max(mobeffectinstance.m_267696_((p_268168_) -> { -+ p_36873_.addEffect(new MobEffectInstance(mobeffectinstance.m_19544_(), Math.max(mobeffectinstance.m_267696_((p_268168_) -> { ++ p_36873_.pushEffectCause(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit // Mohist + p_36873_.m_147207_(new MobEffectInstance(mobeffectinstance.m_19544_(), Math.max(mobeffectinstance.m_267696_((p_268168_) -> { return p_268168_ / 8; -- }), 1), mobeffectinstance.m_19564_(), mobeffectinstance.m_19571_(), mobeffectinstance.m_19572_()), entity); -+ }), 1), mobeffectinstance.m_19564_(), mobeffectinstance.m_19571_(), mobeffectinstance.m_19572_()), entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit - } + }), 1), mobeffectinstance.m_19564_(), mobeffectinstance.m_19571_(), mobeffectinstance.m_19572_()), entity); +@@ -185,7 +_,8 @@ if (!this.f_36852_.isEmpty()) { for(MobEffectInstance mobeffectinstance1 : this.f_36852_) { - p_36873_.m_147207_(mobeffectinstance1, entity); -+ p_36873_.addEffect(mobeffectinstance1, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit ++ p_36873_.pushEffectCause(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit // Mohist ++ p_36873_.addEffect(mobeffectinstance1, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); } } diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownPotion.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownPotion.java.patch index e38620133b..dfa11077ba 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownPotion.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownPotion.java.patch @@ -53,7 +53,7 @@ if (livingentity.m_5801_()) { double d0 = this.m_20280_(livingentity); if (d0 < 16.0D) { -@@ -140,20 +_,43 @@ +@@ -140,20 +_,44 @@ } else { d1 = 1.0D - Math.sqrt(d0) / 4.0D; } @@ -107,7 +107,8 @@ + }); + MobEffectInstance mobeffectinstance1 = new MobEffectInstance(mobeffect, i, mobeffectinstance.m_19564_(), mobeffectinstance.m_19571_(), mobeffectinstance.m_19572_()); + if (!mobeffectinstance1.m_267633_(20)) { -+ livingentity.addEffect(mobeffectinstance1, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit ++ livingentity.pushEffectCause(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit // Mohist ++ livingentity.m_147207_(mobeffectinstance1, entity); } } } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index 4398c0d37a..4bfd7f27a2 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -1,13 +1,15 @@ --- a/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -3,6 +_,7 @@ +@@ -3,7 +_,9 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.logging.LogUtils; import java.util.List; +import java.util.Objects; import java.util.UUID; ++import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.UnaryOperator; import javax.annotation.Nullable; + import net.minecraft.commands.CommandSource; @@ -17,6 +_,7 @@ import net.minecraft.network.chat.Style; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; @@ -37,12 +39,12 @@ private SignText f_276598_ = this.m_277006_(); private SignText f_276476_ = this.m_277006_(); private boolean f_276544_; -@@ -142,12 +_,13 @@ +@@ -142,12 +_,14 @@ public void m_277134_(Player p_278048_, boolean p_278103_, List p_277990_) { if (!this.m_277118_() && p_278048_.m_20148_().equals(this.m_155726_()) && this.f_58857_ != null) { this.m_277073_((p_277776_) -> { -- return this.m_276929_(p_278048_, p_277990_, p_277776_); -+ return this.setMessages(p_278048_, p_277990_, p_277776_, p_278103_); // CraftBukkit ++ setMessages$front.set(p_278103_); // CraftBukkit // Mohist + return this.m_276929_(p_278048_, p_277990_, p_277776_); }, p_278103_); this.m_155713_((UUID)null); this.f_58857_.m_7260_(this.m_58899_(), this.m_58900_(), this.m_58900_(), 3); @@ -52,43 +54,31 @@ } } -@@ -156,18 +_,42 @@ +@@ -156,7 +_,10 @@ return this.m_276956_(p_277877_.apply(signtext), p_277426_); } -- private SignText m_276929_(Player p_277396_, List p_277744_, SignText p_277359_) { -- for(int i = 0; i < p_277744_.size(); ++i) { -- FilteredText filteredtext = p_277744_.get(i); -- Style style = p_277359_.m_277138_(i, p_277396_.m_143387_()).m_7383_(); -- if (p_277396_.m_143387_()) { -- p_277359_ = p_277359_.m_276913_(i, Component.m_237113_(filteredtext.m_243113_()).m_6270_(style)); -+ private SignText setMessages(Player pPlayer, List pFilteredText, SignText pText, boolean front) { // CraftBukkit -+ SignText originalText = pText; // CraftBukkit -+ for(int i = 0; i < pFilteredText.size(); ++i) { -+ FilteredText filteredtext = pFilteredText.get(i); -+ Style style = pText.m_277138_(i, pPlayer.m_143387_()).m_7383_(); -+ if (pPlayer.m_143387_()) { -+ pText = pText.m_276913_(i, Component.m_237113_(filteredtext.m_243113_()).m_6270_(style)); - } else { -- p_277359_ = p_277359_.m_276948_(i, Component.m_237113_(filteredtext.f_215168_()).m_6270_(style), Component.m_237113_(filteredtext.m_243113_()).m_6270_(style)); -- } -- } -- -- return p_277359_; -+ pText = pText.m_276948_(i, Component.m_237113_(filteredtext.f_215168_()).m_6270_(style), Component.m_237113_(filteredtext.m_243113_()).m_6270_(style)); -+ } -+ } ++ private final AtomicBoolean setMessages$front = new AtomicBoolean(false); + + private SignText m_276929_(Player p_277396_, List p_277744_, SignText p_277359_) { ++ SignText originalText = p_277359_; // CraftBukkit + for(int i = 0; i < p_277744_.size(); ++i) { + FilteredText filteredtext = p_277744_.get(i); + Style style = p_277359_.m_277138_(i, p_277396_.m_143387_()).m_7383_(); +@@ -167,9 +_,39 @@ + } + } + + // CraftBukkit start -+ org.bukkit.entity.Player player = ((ServerPlayer) pPlayer).getBukkitEntity(); ++ org.bukkit.entity.Player player = ((ServerPlayer) p_277396_).getBukkitEntity(); + String[] lines = new String[4]; + -+ for (int i = 0; i < pFilteredText.size(); ++i) { -+ lines[i] = CraftChatMessage.fromComponent(pText.m_277138_(i, pPlayer.m_143387_())); ++ for (int i = 0; i < p_277744_.size(); ++i) { ++ lines[i] = CraftChatMessage.fromComponent(p_277359_.m_277138_(i, p_277396_.m_143387_())); + } + -+ SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.f_58857_, this.f_58858_), player, lines.clone(), (front) ? Side.FRONT : Side.BACK); -+ pPlayer.m_9236_().getCraftServer().getPluginManager().callEvent(event); ++ SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.f_58857_, this.f_58858_), player, lines.clone(), (setMessages$front.getAndSet(false)) ? Side.FRONT : Side.BACK); ++ p_277396_.m_9236_().getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return originalText; @@ -97,15 +87,24 @@ + Component[] components = org.bukkit.craftbukkit.v1_20_R1.block.CraftSign.sanitizeLines(event.getLines()); + for (int i = 0; i < components.length; i++) { + if (!Objects.equals(lines[i], event.getLine(i))) { -+ pText = pText.m_276913_(i, components[i]); ++ p_277359_ = p_277359_.m_276913_(i, components[i]); + } + } + // CraftBukkit end + -+ return pText; + return p_277359_; } ++ // Mohist start ++ private SignText setMessages(Player pPlayer, List pFilteredText, SignText pText, boolean front) { // CraftBukkit ++ setMessages$front.set(front); ++ return m_276929_(pPlayer, pFilteredText, pText); ++ } ++ // Mohist end ++ public boolean m_276956_(SignText p_277733_, boolean p_277720_) { + return p_277720_ ? this.m_276964_(p_277733_) : this.m_277170_(p_277733_); + } @@ -213,10 +_,33 @@ return flag; }