From 16f8cdf33c20a85bc3c9028c74da248563884c5e Mon Sep 17 00:00:00 2001 From: fullwall Date: Thu, 2 Jan 2025 18:21:01 +0800 Subject: [PATCH] Backport jump power, piston event and fall distance methods to player NPCs --- .../nms/v1_10_R1/entity/EntityHumanNPC.java | 10 ++++++++++ .../nms/v1_11_R1/entity/EntityHumanNPC.java | 10 ++++++++++ .../nms/v1_12_R1/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_13_R2/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_14_R1/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_15_R1/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_16_R3/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_17_R1/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_18_R2/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_19_R3/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_20_R4/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_21_R3/entity/EntityHumanNPC.java | 16 ++++++++++++++++ .../nms/v1_8_R3/entity/EntityHumanNPC.java | 10 ++++++++++ 13 files changed, 190 insertions(+) diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java index 96c024d97..5491cc2bf 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java @@ -105,6 +105,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable this.bz.put(pathtype, f); } + @Override + public int aY() { + return NMS.getFallDistance(npc, super.aY()); + } + @Override public boolean bg() { return npc == null ? super.bg() : npc.isPushableByFluids(); @@ -120,6 +125,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable return NMSImpl.getSoundEffect(npc, super.bW(), NPC.Metadata.HURT_SOUND); } + @Override + public float ck() { + return NMS.getJumpPower(npc, super.ck()); + } + @Override public void collide(net.minecraft.server.v1_10_R1.Entity entity) { // this method is called by both the entities involved - cancelling diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java index 5f6f52551..051878a38 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java @@ -120,6 +120,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.update(); } + @Override + public int aY() { + return NMS.getFallDistance(npc, super.aY()); + } + @Override public boolean bg() { return npc == null ? super.bg() : npc.isPushableByFluids(); @@ -135,6 +140,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable return NMSImpl.getSoundEffect(npc, super.bX(), NPC.Metadata.HURT_SOUND); } + @Override + public float cl() { + return NMS.getJumpPower(npc, super.cl()); + } + @Override public void collide(net.minecraft.server.v1_11_R1.Entity entity) { // this method is called by both the entities involved - cancelling diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java index f0d4aa0ac..7c8db91dc 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/entity/EntityHumanNPC.java @@ -50,6 +50,7 @@ import net.minecraft.server.v1_12_R1.EntityHuman; import net.minecraft.server.v1_12_R1.EntityPlayer; import net.minecraft.server.v1_12_R1.EnumGamemode; import net.minecraft.server.v1_12_R1.EnumItemSlot; +import net.minecraft.server.v1_12_R1.EnumPistonReaction; import net.minecraft.server.v1_12_R1.EnumProtocolDirection; import net.minecraft.server.v1_12_R1.GenericAttributes; import net.minecraft.server.v1_12_R1.IBlockData; @@ -131,6 +132,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable npc.update(); } + @Override + public int bg() { + return NMS.getFallDistance(npc, super.bg()); + } + @Override public boolean bo() { return npc == null ? super.bo() : npc.isPushableByFluids(); @@ -151,6 +157,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable } } + @Override + public float ct() { + return NMS.getJumpPower(npc, super.ct()); + } + @Override protected SoundEffect d(DamageSource damagesource) { return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.Metadata.HURT_SOUND); @@ -240,6 +251,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable : super.getPlayerListName(); } + @Override + public EnumPistonReaction getPushReaction() { + return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction(); + } + @Override public String getSkinName() { String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName(); diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java index ba45ee550..8d34d81af 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/EntityHumanNPC.java @@ -50,6 +50,7 @@ import net.minecraft.server.v1_13_R2.EntityHuman; import net.minecraft.server.v1_13_R2.EntityPlayer; import net.minecraft.server.v1_13_R2.EnumGamemode; import net.minecraft.server.v1_13_R2.EnumItemSlot; +import net.minecraft.server.v1_13_R2.EnumPistonReaction; import net.minecraft.server.v1_13_R2.EnumProtocolDirection; import net.minecraft.server.v1_13_R2.GenericAttributes; import net.minecraft.server.v1_13_R2.IBlockData; @@ -121,6 +122,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable this.bz.put(pathtype, f); } + @Override + public int bn() { + return NMS.getFallDistance(npc, super.bn()); + } + @Override public void c(float f, float f1) { if (npc == null || !npc.isFlyable()) { @@ -128,6 +134,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable } } + @Override + public float cG() { + return NMS.getJumpPower(npc, super.cG()); + } + @Override public void collide(net.minecraft.server.v1_13_R2.Entity entity) { // this method is called by both the entities involved - cancelling @@ -231,6 +242,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable : super.getPlayerListName(); } + @Override + public EnumPistonReaction getPushReaction() { + return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction(); + } + @Override public String getSkinName() { String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName(); diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java index f950eed6b..ea666844b 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/EntityHumanNPC.java @@ -51,6 +51,7 @@ import net.minecraft.server.v1_14_R1.EntityHuman; import net.minecraft.server.v1_14_R1.EntityPlayer; import net.minecraft.server.v1_14_R1.EnumGamemode; import net.minecraft.server.v1_14_R1.EnumItemSlot; +import net.minecraft.server.v1_14_R1.EnumPistonReaction; import net.minecraft.server.v1_14_R1.EnumProtocolDirection; import net.minecraft.server.v1_14_R1.GenericAttributes; import net.minecraft.server.v1_14_R1.IBlockData; @@ -120,6 +121,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable } } + @Override + public int bv() { + return NMS.getFallDistance(npc, super.bv()); + } + @Override public void collide(net.minecraft.server.v1_14_R1.Entity entity) { // this method is called by both the entities involved - cancelling @@ -130,6 +136,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable } } + @Override + public float cX() { + return NMS.getJumpPower(npc, super.cX()); + } + @Override public boolean damageEntity(DamageSource damagesource, float f) { // knock back velocity is cancelled and sent to client for handling when @@ -223,6 +234,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable : super.getPlayerListName(); } + @Override + public EnumPistonReaction getPushReaction() { + return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction(); + } + @Override public String getSkinName() { String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName(); diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java index 605ebe15c..baa0db1ae 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/entity/EntityHumanNPC.java @@ -50,6 +50,7 @@ import net.minecraft.server.v1_15_R1.EntityHuman; import net.minecraft.server.v1_15_R1.EntityPlayer; import net.minecraft.server.v1_15_R1.EnumGamemode; import net.minecraft.server.v1_15_R1.EnumItemSlot; +import net.minecraft.server.v1_15_R1.EnumPistonReaction; import net.minecraft.server.v1_15_R1.EnumProtocolDirection; import net.minecraft.server.v1_15_R1.GenericAttributes; import net.minecraft.server.v1_15_R1.IBlockData; @@ -119,6 +120,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable return false; } + @Override + public int bD() { + return NMS.getFallDistance(npc, super.bD()); + } + @Override public void collide(net.minecraft.server.v1_15_R1.Entity entity) { // this method is called by both the entities involved - cancelling @@ -162,6 +168,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable // give enough time for death and smoke animation } + @Override + public float dp() { + return NMS.getJumpPower(npc, super.dp()); + } + @Override public void e(Vec3D vec3d) { if (npc == null || !npc.isFlyable()) { @@ -214,6 +225,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable : super.getPlayerListName(); } + @Override + public EnumPistonReaction getPushReaction() { + return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction(); + } + @Override public String getSkinName() { String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName(); diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java index d7215a9af..7661c9e63 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/entity/EntityHumanNPC.java @@ -49,6 +49,7 @@ import net.minecraft.server.v1_16_R3.EntityHuman; import net.minecraft.server.v1_16_R3.EntityPlayer; import net.minecraft.server.v1_16_R3.EnumGamemode; import net.minecraft.server.v1_16_R3.EnumItemSlot; +import net.minecraft.server.v1_16_R3.EnumPistonReaction; import net.minecraft.server.v1_16_R3.EnumProtocolDirection; import net.minecraft.server.v1_16_R3.GenericAttributes; import net.minecraft.server.v1_16_R3.IBlockData; @@ -105,6 +106,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable return false; } + @Override + public int bP() { + return NMS.getFallDistance(npc, super.bP()); + } + @Override public void collide(net.minecraft.server.v1_16_R3.Entity entity) { // this method is called by both the entities involved - cancelling @@ -149,6 +155,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable // animation } + @Override + public float dJ() { + return NMS.getJumpPower(npc, super.dJ()); + } + @Override public void g(Vec3D vec3d) { if (npc == null || !npc.isFlyable()) { @@ -195,6 +206,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable : super.getPlayerListName(); } + @Override + public EnumPistonReaction getPushReaction() { + return Util.callPistonPushEvent(npc) ? EnumPistonReaction.IGNORE : super.getPushReaction(); + } + @Override public String getSkinName() { String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName(); diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java index 4a04ac794..8da136a5c 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/entity/EntityHumanNPC.java @@ -52,6 +52,7 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -202,11 +203,26 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.Metadata.HURT_SOUND); } + @Override + public float getJumpPower() { + return NMS.getJumpPower(npc, super.getJumpPower()); + } + + @Override + public int getMaxFallDistance() { + return NMS.getFallDistance(npc, super.getMaxFallDistance()); + } + @Override public NPC getNPC() { return npc; } + @Override + public PushReaction getPistonPushReaction() { + return Util.callPistonPushEvent(npc) ? PushReaction.IGNORE : super.getPistonPushReaction(); + } + @Override public GameProfile getProfile() { return super.getGameProfile(); diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java index 8cb78a115..4327be4e0 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/entity/EntityHumanNPC.java @@ -53,6 +53,7 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -203,11 +204,26 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.Metadata.HURT_SOUND); } + @Override + public float getJumpPower() { + return NMS.getJumpPower(npc, super.getJumpPower()); + } + + @Override + public int getMaxFallDistance() { + return NMS.getFallDistance(npc, super.getMaxFallDistance()); + } + @Override public NPC getNPC() { return npc; } + @Override + public PushReaction getPistonPushReaction() { + return Util.callPistonPushEvent(npc) ? PushReaction.IGNORE : super.getPistonPushReaction(); + } + @Override public GameProfile getProfile() { return super.getGameProfile(); diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/EntityHumanNPC.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/EntityHumanNPC.java index ad89158bd..6ceb2dbdf 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/EntityHumanNPC.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/entity/EntityHumanNPC.java @@ -55,6 +55,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -208,11 +209,26 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.Metadata.HURT_SOUND); } + @Override + public float getJumpPower() { + return NMS.getJumpPower(npc, super.getJumpPower()); + } + + @Override + public int getMaxFallDistance() { + return NMS.getFallDistance(npc, super.getMaxFallDistance()); + } + @Override public NPC getNPC() { return npc; } + @Override + public PushReaction getPistonPushReaction() { + return Util.callPistonPushEvent(npc) ? PushReaction.IGNORE : super.getPistonPushReaction(); + } + @Override public GameProfile getProfile() { return super.getGameProfile(); diff --git a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/EntityHumanNPC.java b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/EntityHumanNPC.java index e4f2ef6d2..67321cc2d 100644 --- a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/EntityHumanNPC.java +++ b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/entity/EntityHumanNPC.java @@ -55,6 +55,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -209,11 +210,26 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.Metadata.HURT_SOUND); } + @Override + public float getJumpPower() { + return NMS.getJumpPower(npc, super.getJumpPower()); + } + + @Override + public int getMaxFallDistance() { + return NMS.getFallDistance(npc, super.getMaxFallDistance()); + } + @Override public NPC getNPC() { return npc; } + @Override + public PushReaction getPistonPushReaction() { + return Util.callPistonPushEvent(npc) ? PushReaction.IGNORE : super.getPistonPushReaction(); + } + @Override public GameProfile getProfile() { return super.getGameProfile(); diff --git a/v1_21_R3/src/main/java/net/citizensnpcs/nms/v1_21_R3/entity/EntityHumanNPC.java b/v1_21_R3/src/main/java/net/citizensnpcs/nms/v1_21_R3/entity/EntityHumanNPC.java index aa67a24f8..a953850c7 100644 --- a/v1_21_R3/src/main/java/net/citizensnpcs/nms/v1_21_R3/entity/EntityHumanNPC.java +++ b/v1_21_R3/src/main/java/net/citizensnpcs/nms/v1_21_R3/entity/EntityHumanNPC.java @@ -55,6 +55,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -210,11 +211,26 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable return NMSImpl.getSoundEffect(npc, super.getHurtSound(damagesource), NPC.Metadata.HURT_SOUND); } + @Override + public float getJumpPower() { + return NMS.getJumpPower(npc, super.getJumpPower()); + } + + @Override + public int getMaxFallDistance() { + return NMS.getFallDistance(npc, super.getMaxFallDistance()); + } + @Override public NPC getNPC() { return npc; } + @Override + public PushReaction getPistonPushReaction() { + return Util.callPistonPushEvent(npc) ? PushReaction.IGNORE : super.getPistonPushReaction(); + } + @Override public GameProfile getProfile() { return super.getGameProfile(); diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java index b595c2f98..d1c3eb498 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/entity/EntityHumanNPC.java @@ -100,11 +100,21 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable : !npc.isProtected(); } + @Override + public int aE() { + return NMS.getFallDistance(npc, super.aE()); + } + @Override public boolean aL() { return npc == null ? super.aL() : npc.isPushableByFluids(); } + @Override + public float bE() { + return NMS.getJumpPower(npc, super.bE()); + } + @Override protected String bo() { return NMSImpl.getSoundEffect(npc, super.bo(), NPC.Metadata.HURT_SOUND);