Backport jump power, piston event and fall distance methods to player NPCs

This commit is contained in:
fullwall 2025-01-02 18:21:01 +08:00
parent e7010e9035
commit 16f8cdf33c
13 changed files with 190 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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);