From 11e326de48db543dfb38ec406aa099f06ef2d4df Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 6 Nov 2025 00:20:22 -0500 Subject: [PATCH 1/6] Add mount role for NPCs with rider controls --- src/main/java/noppes/npcs/DataAdvanced.java | 9 +- .../client/gui/mainmenu/GuiNpcAdvanced.java | 5 +- .../npcs/client/gui/roles/GuiNpcMount.java | 109 +++++++++++++++++ .../noppes/npcs/constants/EnumRoleType.java | 2 +- .../noppes/npcs/entity/EntityNPCFlying.java | 45 +++++++ .../npcs/entity/EntityNPCInterface.java | 102 +++++++++++++++- .../java/noppes/npcs/roles/RoleMount.java | 112 ++++++++++++++++++ .../assets/customnpcs/lang/cs_CZ.lang | 6 + .../assets/customnpcs/lang/de_DE.lang | 6 + .../assets/customnpcs/lang/en_US.lang | 6 + .../assets/customnpcs/lang/es_AR.lang | 6 + .../assets/customnpcs/lang/es_MX.lang | 6 + .../assets/customnpcs/lang/fr_FR.lang | 6 + .../assets/customnpcs/lang/hu_HU.lang | 6 + .../assets/customnpcs/lang/id_ID.lang | 6 + .../assets/customnpcs/lang/ko_KR.lang | 6 + .../assets/customnpcs/lang/nl_NL.lang | 8 +- .../assets/customnpcs/lang/pl_PL.lang | 6 + .../assets/customnpcs/lang/pt_BR.lang | 6 + .../assets/customnpcs/lang/ru_RU.lang | 6 + .../assets/customnpcs/lang/sv_SE.lang | 6 + .../assets/customnpcs/lang/zh_CN.lang | 6 + .../assets/customnpcs/lang/zh_TW.lang | 6 + 23 files changed, 476 insertions(+), 6 deletions(-) create mode 100644 src/main/java/noppes/npcs/client/gui/roles/GuiNpcMount.java create mode 100644 src/main/java/noppes/npcs/roles/RoleMount.java diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index cc9e08614..45ecfe4a8 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -21,6 +21,7 @@ import noppes.npcs.roles.JobSpawner; import noppes.npcs.roles.RoleBank; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleFollower; +import noppes.npcs.roles.RoleMount; import noppes.npcs.roles.RolePostman; import noppes.npcs.roles.RoleTrader; import noppes.npcs.roles.RoleTransporter; @@ -196,7 +197,11 @@ public class DataAdvanced { if (EnumRoleType.values().length <= i) { i -= 2; } - role = EnumRoleType.values()[i]; + EnumRoleType newRole = EnumRoleType.values()[i]; + if (npc.roleInterface instanceof RoleMount && newRole != EnumRoleType.Mount) { + ((RoleMount) npc.roleInterface).onDisable(); + } + role = newRole; if (role == EnumRoleType.None) npc.roleInterface = null; else if (role == EnumRoleType.Bank && !(npc.roleInterface instanceof RoleBank)) @@ -211,6 +216,8 @@ public class DataAdvanced { npc.roleInterface = new RoleTransporter(npc); else if (role == EnumRoleType.Companion && !(npc.roleInterface instanceof RoleCompanion)) npc.roleInterface = new RoleCompanion(npc); + else if (role == EnumRoleType.Mount && !(npc.roleInterface instanceof RoleMount)) + npc.roleInterface = new RoleMount(npc); } public void setJob(int i) { diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java index d7b5ac919..6452145a6 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java @@ -25,6 +25,7 @@ import noppes.npcs.client.gui.roles.GuiNpcFollowerJob; import noppes.npcs.client.gui.roles.GuiNpcGuard; import noppes.npcs.client.gui.roles.GuiNpcHealer; import noppes.npcs.client.gui.roles.GuiNpcSpawner; +import noppes.npcs.client.gui.roles.GuiNpcMount; import noppes.npcs.client.gui.roles.GuiNpcTransporter; import noppes.npcs.client.gui.util.GuiNPCInterface2; import noppes.npcs.client.gui.util.GuiNpcButton; @@ -47,7 +48,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData { super.initGui(); int y = guiTop + 10; this.addButton(new GuiNpcButton(3, guiLeft + 85 + 160, y, 52, 20, "selectServer.edit")); - this.addButton(new GuiNpcButton(8, guiLeft + 85, y, 155, 20, new String[]{"role.none", "role.trader", "role.follower", "role.bank", "role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)")}, npc.advanced.role.ordinal())); + this.addButton(new GuiNpcButton(8, guiLeft + 85, y, 155, 20, new String[]{"role.none", "role.trader", "role.follower", "role.bank", "role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)"), "role.mount"}, npc.advanced.role.ordinal())); getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman); this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += 22, 52, 20, "selectServer.edit")); @@ -148,6 +149,8 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData { displayGuiScreen(new GuiNpcTransporter(npc)); else if (npc.advanced.role == EnumRoleType.Companion) displayGuiScreen(new GuiNpcCompanion(npc)); + else if (npc.advanced.role == EnumRoleType.Mount) + displayGuiScreen(new GuiNpcMount(npc)); } else if (compound.hasKey("JobData")) { if (npc.jobInterface != null) npc.jobInterface.readFromNBT(compound); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcMount.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcMount.java new file mode 100644 index 000000000..57f39a6d8 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcMount.java @@ -0,0 +1,109 @@ +package noppes.npcs.client.gui.roles; + +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.request.role.RoleSavePacket; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import noppes.npcs.client.gui.util.GuiNPCInterface2; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiNpcLabel; +import noppes.npcs.client.gui.util.GuiNpcTextField; +import noppes.npcs.client.gui.util.ITextfieldListener; +import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.roles.RoleMount; + +import java.util.Locale; + +public class GuiNpcMount extends GuiNPCInterface2 implements ITextfieldListener { + + private final RoleMount role; + + public GuiNpcMount(EntityNPCInterface npc) { + super(npc); + this.role = npc.roleInterface instanceof RoleMount ? (RoleMount) npc.roleInterface : null; + } + + @Override + public void initGui() { + super.initGui(); + if (role == null) { + close(); + return; + } + + int y = guiTop + 6; + addOffsetRow(0, "role.mount.offsetx", role.getOffsetX(), y); + y += 24; + addOffsetRow(1, "role.mount.offsety", role.getOffsetY(), y); + y += 24; + addOffsetRow(2, "role.mount.offsetz", role.getOffsetZ(), y); + + addButton(new GuiNpcButton(3, guiLeft + 4, y + 26, 80, 20, "role.mount.reset")); + + GuiNpcLabel speedLabel = new GuiNpcLabel(4, "", guiLeft + 4, y + 6); + speedLabel.label = StatCollector.translateToLocalFormatted("role.mount.walkspeed", npc.ais.getWalkingSpeed()); + addLabel(speedLabel); + } + + private void addOffsetRow(int id, String translationKey, float value, int y) { + addLabel(new GuiNpcLabel(id, translationKey, guiLeft + 4, y + 5)); + GuiNpcTextField field = new GuiNpcTextField(id, this, guiLeft + 140, y, 80, 20, format(value)); + field.floatsOnly = true; + field.setMinMaxDefaultFloat(-5.0F, 5.0F, 0.0F); + addTextField(field); + } + + private String format(float value) { + return String.format(Locale.ROOT, "%.2f", value); + } + + @Override + public void buttonEvent(GuiButton guibutton) { + if (role == null) + return; + if (guibutton.id == 3) { + role.resetOffsets(); + initGui(); + } + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + if (role == null) + return; + float value = textfield.isFloat() ? textfield.getFloat() : 0.0F; + switch (textfield.id) { + case 0: + role.setOffsetX(value); + break; + case 1: + role.setOffsetY(value); + break; + case 2: + role.setOffsetZ(value); + break; + } + textfield.setText(format(valueForField(textfield.id))); + } + + private float valueForField(int id) { + switch (id) { + case 0: + return role.getOffsetX(); + case 1: + return role.getOffsetY(); + case 2: + return role.getOffsetZ(); + default: + return 0.0F; + } + } + + @Override + public void save() { + if (role != null) { + PacketClient.sendClient(new RoleSavePacket(role.writeToNBT(new NBTTagCompound()))); + } + } +} diff --git a/src/main/java/noppes/npcs/constants/EnumRoleType.java b/src/main/java/noppes/npcs/constants/EnumRoleType.java index a82f4b607..624658fb3 100644 --- a/src/main/java/noppes/npcs/constants/EnumRoleType.java +++ b/src/main/java/noppes/npcs/constants/EnumRoleType.java @@ -2,5 +2,5 @@ package noppes.npcs.constants; public enum EnumRoleType { - None, Trader, Follower, Bank, Transporter, Postman, Companion + None, Trader, Follower, Bank, Transporter, Postman, Companion, Mount } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index 92ad030c5..bba547c61 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -40,7 +40,10 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { super.onLivingUpdate(); } + @Override public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { + if (handleMountedMovement(p_70612_1_, p_70612_2_)) + return; if (!this.canFly() || this.hurtTime != 0 || !this.canBreathe()) { super.moveEntityWithHeading(p_70612_1_, p_70612_2_); return; @@ -92,4 +95,46 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { this.limbSwingAmount += (distance - this.limbSwingAmount) * 0.4F; this.limbSwing += this.limbSwingAmount; } + + @Override + protected void doMountedMovement(float strafe, float forward) { + if (!this.canFly() || this.hurtTime != 0 || !this.canBreathe()) { + super.doMountedMovement(strafe, forward); + return; + } + + boolean aboveLimit = false; + double heightOffGround = this.posY - this.worldObj.getTopSolidOrLiquidBlock((int) this.posX, (int) this.posZ); + if (heightOffGround < 0) { + Vec3 pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 posLimit = Vec3.createVectorHelper(this.posX, this.posY - this.ais.flyHeightLimit, this.posZ); + MovingObjectPosition mob = this.worldObj.rayTraceBlocks(pos, posLimit, true); + if (mob == null || mob.typeOfHit == MovingObjectPosition.MovingObjectType.MISS) { + aboveLimit = true; + } + } else if (heightOffGround > this.ais.flyHeightLimit) { + aboveLimit = true; + } + if (aboveLimit && this.ais.hasFlyLimit || (heightOffGround < Math.ceil(this.height) && this.motionY == 0)) { + this.flyLimitAllow = false; + if (!this.getNavigator().noPath() && this.motionY > 0) { + this.motionY = 0; + } else { + super.doMountedMovement(strafe, forward); + return; + } + } + this.flyLimitAllow = true; + + double d3 = this.motionY; + super.doMountedMovement(strafe, forward); + this.motionY = d3; + + if (this.getNavigator().noPath()) { + this.motionY = -Math.abs(this.ais.flyGravity); + } + + this.updateLimbSwing(); + this.velocityChanged = true; + } } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index c72aa7117..fb125982e 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -152,6 +152,7 @@ import noppes.npcs.roles.JobFollower; import noppes.npcs.roles.JobInterface; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleFollower; +import noppes.npcs.roles.RoleMount; import noppes.npcs.roles.RoleInterface; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptNpc; @@ -1753,6 +1754,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti roleInterface.writeToNBT(bard); compound.setTag("Companion", bard); } + if (advanced.role == EnumRoleType.Mount) { + NBTTagCompound mount = new NBTTagCompound(); + roleInterface.writeToNBT(mount); + compound.setTag("Mount", mount); + } if (this instanceof EntityCustomNpc) { compound.setTag("ModelData", ((EntityCustomNpc) this).modelData.writeToNBT()); @@ -1790,6 +1796,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti NBTTagCompound companion = compound.getCompoundTag("Companion"); roleInterface.readFromNBT(companion); } + if (advanced.role == EnumRoleType.Mount) { + NBTTagCompound mount = compound.getCompoundTag("Mount"); + roleInterface.readFromNBT(mount); + } if (this instanceof EntityCustomNpc) { ((EntityCustomNpc) this).modelData.readFromNBT(compound.getCompoundTag("ModelData")); } @@ -2056,15 +2066,86 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } @Override - public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { + public void moveEntityWithHeading(float strafe, float forward) { + if (handleMountedMovement(strafe, forward)) { + return; + } double d0 = this.posX; double d1 = this.posY; double d2 = this.posZ; - super.moveEntityWithHeading(p_70612_1_, p_70612_2_); + super.moveEntityWithHeading(strafe, forward); if (advanced.role == EnumRoleType.Companion && !isRemote()) ((RoleCompanion) roleInterface).addMovementStat(this.posX - d0, this.posY - d1, this.posZ - d2); } + protected boolean handleMountedMovement(float strafe, float forward) { + if (advanced.role != EnumRoleType.Mount || !(roleInterface instanceof RoleMount)) + return false; + if (!(riddenByEntity instanceof EntityLivingBase)) + return false; + + EntityLivingBase rider = (EntityLivingBase) riddenByEntity; + this.prevRotationYaw = this.rotationYaw = rider.rotationYaw; + this.rotationPitch = rider.rotationPitch * 0.5F; + this.setRotation(this.rotationYaw, this.rotationPitch); + this.renderYawOffset = this.rotationYaw; + this.rotationYawHead = this.rotationYaw; + + float controlledStrafe = rider.moveStrafing * 0.5F; + float controlledForward = rider.moveForward; + if (controlledForward <= 0.0F) { + controlledForward *= 0.25F; + } + + float moveSpeed = getSpeed(); + if (rider.isSprinting()) { + moveSpeed *= 1.2F; + } + + this.setSprinting(rider.isSprinting()); + this.setAIMoveSpeed(moveSpeed); + this.stepHeight = 1.0F; + this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F; + + this.getNavigator().clearPathEntity(); + this.setAttackTarget(null); + this.setRevengeTarget(null); + + this.fallDistance = 0.0F; + rider.fallDistance = 0.0F; + + applyMountedVerticalMotion(rider, moveSpeed); + doMountedMovement(controlledStrafe, controlledForward); + + return true; + } + + protected void doMountedMovement(float strafe, float forward) { + super.moveEntityWithHeading(strafe, forward); + } + + protected void applyMountedVerticalMotion(EntityLivingBase rider, float moveSpeed) { + if (canFly()) { + double vertical = Math.max(0.1D, moveSpeed * 0.6D); + if (rider.isJumping()) { + this.motionY = Math.min(this.motionY + vertical, vertical); + this.isAirBorne = true; + } else { + float pitch = rider.rotationPitch; + if (pitch < -10F) { + this.motionY = vertical; + } else if (pitch > 10F) { + this.motionY = -vertical; + } else if (!this.onGround) { + this.motionY *= 0.6D; + } + } + } else if (rider.isJumping() && this.onGround) { + this.motionY = 0.5D; + this.isAirBorne = true; + } + } + @Override public boolean allowLeashing() { return false; @@ -2075,6 +2156,23 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti return false; } + @Override + public void updateRiderPosition() { + super.updateRiderPosition(); + if (advanced.role == EnumRoleType.Mount && roleInterface instanceof RoleMount && riddenByEntity != null) { + RoleMount mount = (RoleMount) roleInterface; + double yaw = Math.toRadians(this.renderYawOffset); + double offsetX = mount.getOffsetX(); + double offsetZ = mount.getOffsetZ(); + double rotatedX = offsetX * Math.cos(yaw) - offsetZ * Math.sin(yaw); + double rotatedZ = offsetX * Math.sin(yaw) + offsetZ * Math.cos(yaw); + double offsetY = mount.getOffsetY(); + riddenByEntity.setPosition(this.posX + rotatedX, + this.posY + this.getMountedYOffset() + riddenByEntity.getYOffset() + offsetY, + this.posZ + rotatedZ); + } + } + // Model Types: 0: Steve 64x32, 1: Steve 64x64, 2: Alex 64x64 public int getModelType() { return this.display.modelType; diff --git a/src/main/java/noppes/npcs/roles/RoleMount.java b/src/main/java/noppes/npcs/roles/RoleMount.java new file mode 100644 index 000000000..455f8f329 --- /dev/null +++ b/src/main/java/noppes/npcs/roles/RoleMount.java @@ -0,0 +1,112 @@ +package noppes.npcs.roles; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.util.ValueUtil; + +public class RoleMount extends RoleInterface { + + private float offsetX; + private float offsetY; + private float offsetZ; + private boolean storedReturnToStart; + + public RoleMount(EntityNPCInterface npc) { + super(npc); + this.storedReturnToStart = npc.ais.returnToStart; + npc.ais.returnToStart = false; + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setFloat("MountOffsetX", offsetX); + compound.setFloat("MountOffsetY", offsetY); + compound.setFloat("MountOffsetZ", offsetZ); + compound.setBoolean("MountReturnFlag", storedReturnToStart); + return compound; + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + setOffsetX(compound.getFloat("MountOffsetX")); + setOffsetY(compound.getFloat("MountOffsetY")); + setOffsetZ(compound.getFloat("MountOffsetZ")); + if (compound.hasKey("MountReturnFlag")) { + storedReturnToStart = compound.getBoolean("MountReturnFlag"); + } else { + storedReturnToStart = npc.ais.returnToStart; + } + npc.ais.returnToStart = false; + } + + @Override + public void interact(EntityPlayer player) { + if (player == null || npc.worldObj.isRemote) { + return; + } + if (npc.riddenByEntity != null && npc.riddenByEntity != player) { + return; + } + if (player.ridingEntity != null && player.ridingEntity != npc) { + player.mountEntity(null); + } + player.fallDistance = 0.0F; + npc.fallDistance = 0.0F; + player.mountEntity(npc); + npc.getNavigator().clearPathEntity(); + npc.setAttackTarget(null); + npc.setRevengeTarget(null); + } + + @Override + public boolean aiShouldExecute() { + if (npc.ais.returnToStart) { + npc.ais.returnToStart = false; + } + return false; + } + + public void setOffsetX(float value) { + this.offsetX = clamp(value); + } + + public void setOffsetY(float value) { + this.offsetY = clamp(value); + } + + public void setOffsetZ(float value) { + this.offsetZ = clamp(value); + } + + public float getOffsetX() { + return offsetX; + } + + public float getOffsetY() { + return offsetY; + } + + public float getOffsetZ() { + return offsetZ; + } + + private float clamp(float value) { + return ValueUtil.clamp(value, -5.0F, 5.0F); + } + + public void resetOffsets() { + offsetX = 0.0F; + offsetY = 0.0F; + offsetZ = 0.0F; + } + + public void onDisable() { + npc.ais.returnToStart = storedReturnToStart; + } + + @Override + public void delete() { + onDisable(); + } +} diff --git a/src/main/resources/assets/customnpcs/lang/cs_CZ.lang b/src/main/resources/assets/customnpcs/lang/cs_CZ.lang index f8f092bbf..e9cd29b99 100644 --- a/src/main/resources/assets/customnpcs/lang/cs_CZ.lang +++ b/src/main/resources/assets/customnpcs/lang/cs_CZ.lang @@ -439,3 +439,9 @@ item.npcOfficerHelmet.name=důstojnické brnění item.npcCrown.name=Koruna item.npcCrown2.name=Koruna key.npcInventory=NPC inventář +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/de_DE.lang b/src/main/resources/assets/customnpcs/lang/de_DE.lang index f88dd2769..38f3d3377 100644 --- a/src/main/resources/assets/customnpcs/lang/de_DE.lang +++ b/src/main/resources/assets/customnpcs/lang/de_DE.lang @@ -871,3 +871,9 @@ companion.stage=Bühne #German by DewTix key.npcInventory=NPC Inventar +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 57dc34cdc..c3edc664e 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -417,6 +417,12 @@ role.transporter=Transporter role.mailman=Mailman role.marketname=Linked Marketname role.companion=Companion +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s trader.insufficient=Insufficient Currency trader.sufficient=Sufficient Currency diff --git a/src/main/resources/assets/customnpcs/lang/es_AR.lang b/src/main/resources/assets/customnpcs/lang/es_AR.lang index 27c79cd78..5ca50fc49 100644 --- a/src/main/resources/assets/customnpcs/lang/es_AR.lang +++ b/src/main/resources/assets/customnpcs/lang/es_AR.lang @@ -499,3 +499,9 @@ item.npcSlingshot.name=Slingshot item.npcMusket.name=Mosquete item.npcExcalibur.name=Excalibur key.npcInventory=Inventario de NPC +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/es_MX.lang b/src/main/resources/assets/customnpcs/lang/es_MX.lang index 53bca03af..fd58878af 100644 --- a/src/main/resources/assets/customnpcs/lang/es_MX.lang +++ b/src/main/resources/assets/customnpcs/lang/es_MX.lang @@ -499,3 +499,9 @@ item.npcSlingshot.name=Slingshot item.npcMusket.name=Mosquete item.npcExcalibur.name=Excalibur key.npcInventory=Inventario de NPC +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/fr_FR.lang b/src/main/resources/assets/customnpcs/lang/fr_FR.lang index b22a75ac3..6229aa1b9 100644 --- a/src/main/resources/assets/customnpcs/lang/fr_FR.lang +++ b/src/main/resources/assets/customnpcs/lang/fr_FR.lang @@ -541,3 +541,9 @@ item.npcSlingshot.name=Lance-Pièrre item.npcMusket.name=Mousquet item.npcExcalibur.name=Excalibur key.npcInventory=Inventaire Pnj +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/hu_HU.lang b/src/main/resources/assets/customnpcs/lang/hu_HU.lang index 1a9fc71f5..e3112252c 100644 --- a/src/main/resources/assets/customnpcs/lang/hu_HU.lang +++ b/src/main/resources/assets/customnpcs/lang/hu_HU.lang @@ -541,3 +541,9 @@ item.npcSlingshot.name=Csúzli item.npcMusket.name=Muskéta item.npcExcalibur.name=Excalibur key.npcInventory=NPC felszerelés +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/id_ID.lang b/src/main/resources/assets/customnpcs/lang/id_ID.lang index a5952d7ab..a7de30101 100644 --- a/src/main/resources/assets/customnpcs/lang/id_ID.lang +++ b/src/main/resources/assets/customnpcs/lang/id_ID.lang @@ -316,3 +316,9 @@ item.npcAmethyst.name=Permata Amethyst item.npcRuby.name=Permata Rubi +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/ko_KR.lang b/src/main/resources/assets/customnpcs/lang/ko_KR.lang index 993006c34..64b370445 100644 --- a/src/main/resources/assets/customnpcs/lang/ko_KR.lang +++ b/src/main/resources/assets/customnpcs/lang/ko_KR.lang @@ -796,3 +796,9 @@ enchantment.infinite=무한 enchantment.poison=독 key.npcInventory=NPC 인벤토리 +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/nl_NL.lang b/src/main/resources/assets/customnpcs/lang/nl_NL.lang index 6756f197f..6998ad909 100644 --- a/src/main/resources/assets/customnpcs/lang/nl_NL.lang +++ b/src/main/resources/assets/customnpcs/lang/nl_NL.lang @@ -230,4 +230,10 @@ item.npcCrown2.name=Kroon item.npcNinjaHead.name=Ninja Helm item.npcNinjaChest.name=Ninja Borst -item.npcNinjaPants.name=Ninja Broek \ No newline at end of file +item.npcNinjaPants.name=Ninja Broek +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/pl_PL.lang b/src/main/resources/assets/customnpcs/lang/pl_PL.lang index 2f1047663..0526906d6 100644 --- a/src/main/resources/assets/customnpcs/lang/pl_PL.lang +++ b/src/main/resources/assets/customnpcs/lang/pl_PL.lang @@ -497,3 +497,9 @@ item.npcSlingshot.name=Proca item.npcMusket.name=Muszkiet item.npcExcalibur.name=Excalibur key.npcInventory=Inwentarz npc +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/pt_BR.lang b/src/main/resources/assets/customnpcs/lang/pt_BR.lang index c3bbd3c26..3e5411213 100644 --- a/src/main/resources/assets/customnpcs/lang/pt_BR.lang +++ b/src/main/resources/assets/customnpcs/lang/pt_BR.lang @@ -497,3 +497,9 @@ item.npcSlingshot.name=Estilingue item.npcMusket.name=Mosquete item.npcExcalibur.name=Excalibur key.npcInventory=Inventário NPC +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/ru_RU.lang b/src/main/resources/assets/customnpcs/lang/ru_RU.lang index 0b286b3ae..f190a84f0 100644 --- a/src/main/resources/assets/customnpcs/lang/ru_RU.lang +++ b/src/main/resources/assets/customnpcs/lang/ru_RU.lang @@ -1020,3 +1020,9 @@ questgui.reject=Отменить questgui.accept=Принять key.npcInventory=Инвентарь NPC +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/sv_SE.lang b/src/main/resources/assets/customnpcs/lang/sv_SE.lang index 91be6d6bc..adf43d88c 100644 --- a/src/main/resources/assets/customnpcs/lang/sv_SE.lang +++ b/src/main/resources/assets/customnpcs/lang/sv_SE.lang @@ -307,3 +307,9 @@ item.npcKey.name=Key item.npcPendant.name=Pendant item.npcBlueprint.name=Blueprint item.npcRing.name=Ring +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/zh_CN.lang b/src/main/resources/assets/customnpcs/lang/zh_CN.lang index 7831cf590..41799f778 100644 --- a/src/main/resources/assets/customnpcs/lang/zh_CN.lang +++ b/src/main/resources/assets/customnpcs/lang/zh_CN.lang @@ -1243,3 +1243,9 @@ hitbox.width=宽度比例 hitbox.height=身高比例 key.npcInventory=NPC物品栏 +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/zh_TW.lang b/src/main/resources/assets/customnpcs/lang/zh_TW.lang index 168709725..6b864af53 100644 --- a/src/main/resources/assets/customnpcs/lang/zh_TW.lang +++ b/src/main/resources/assets/customnpcs/lang/zh_TW.lang @@ -313,3 +313,9 @@ item.npcBronzeIngot.name=銅錠 item.npcSaphire.name=藍寶石 item.npcAmethyst.name=紫水晶 item.npcRuby.name=紅寶石 +role.mount=Mount +role.mount.offsetx=Seat Offset X +role.mount.offsety=Seat Offset Y +role.mount.offsetz=Seat Offset Z +role.mount.reset=Reset Position +role.mount.walkspeed=Walking speed: %s From d00c1cf15637f1601bbd3fc85c3ace71cca51e17 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 6 Nov 2025 01:42:55 -0500 Subject: [PATCH 2/6] Refine mount role rider positioning and home behavior --- .../npcs/client/gui/mainmenu/GuiNpcAI.java | 16 ++++- .../npcs/entity/EntityNPCInterface.java | 69 ++++++++++++++++--- .../java/noppes/npcs/roles/RoleMount.java | 10 +++ .../npcs/scripted/entity/ScriptNpc.java | 10 ++- 4 files changed, 91 insertions(+), 14 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java index 538d58b59..cc785f299 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java @@ -16,6 +16,7 @@ import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.constants.EnumCombatPolicy; import noppes.npcs.constants.EnumNavType; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.roles.RoleMount; public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IGuiData { private DataAI ai; @@ -44,7 +45,12 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG addLabel(new GuiNpcLabel(10, "ai.avoidwater", guiLeft + 150, guiTop + 17)); addButton(new GuiNpcButton(5, guiLeft + 230, guiTop + 10, 60, 20, new String[]{"gui.no", "gui.yes"}, npc.ais.avoidsWater ? 1 : 0)); addLabel(new GuiNpcLabel(11, "ai.return", guiLeft + 150, guiTop + 40)); - addButton(new GuiNpcButton(6, guiLeft + 230, guiTop + 35, 60, 20, new String[]{"gui.no", "gui.yes"}, npc.ais.returnToStart ? 1 : 0)); + int returnValue = npc.ais.returnToStart ? 1 : 0; + if (npc.advanced.role == EnumRoleType.Mount && npc.roleInterface instanceof RoleMount) { + returnValue = ((RoleMount) npc.roleInterface).getReturnToStartPreference() ? 1 : 0; + } + addButton(new GuiNpcButton(6, guiLeft + 230, guiTop + 35, 60, 20, new String[]{"gui.no", "gui.yes"}, returnValue)); + getButton(6).setEnabled(npc.advanced.role != EnumRoleType.Mount); addLabel(new GuiNpcLabel(17, "ai.leapattarget", guiLeft + 150, guiTop + 65)); addButton(new GuiNpcButton(15, guiLeft + 230, guiTop + 60, 60, 20, new String[]{"gui.no", "ai.jump", "ai.pounce"}, npc.ais.leapType)); addLabel(new GuiNpcLabel(15, "ai.indirect", guiLeft + 150, guiTop + 90)); @@ -132,7 +138,13 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG } else if (button.id == 5) { npc.setAvoidWater(button.getValue() == 1); } else if (button.id == 6) { - ai.returnToStart = (button.getValue() == 1); + if (npc.advanced.role == EnumRoleType.Mount && npc.roleInterface instanceof RoleMount) { + ((RoleMount) npc.roleInterface).setReturnToStartPreference(button.getValue() == 1); + ai.returnToStart = false; + initGui(); + } else { + ai.returnToStart = (button.getValue() == 1); + } } else if (button.id == 7) { ai.canSwim = (button.getValue() == 1); } else if (button.id == 9) { diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index fb125982e..5602ba027 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -65,6 +65,7 @@ import net.minecraft.util.IChatComponent; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.MinecraftForge; @@ -209,6 +210,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public ResourceLocation textureLocation = null; + private Entity lastRider; + public EnumAnimation currentAnimation = EnumAnimation.NONE; public int npcVersion = VersionCompatibility.ModRev; @@ -469,6 +472,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti super.onLivingUpdate(); + handleMountRiderState(); + if (worldObj.isRemote) { if (roleInterface != null) { roleInterface.clientUpdate(); @@ -1479,10 +1484,13 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti this.spawnExplosionParticle(); delete(); } else { - if (this.riddenByEntity != null) + if (this.riddenByEntity != null) { + stabilizeDismountedRider(this.riddenByEntity); this.riddenByEntity.mountEntity(null); + } if (this.ridingEntity != null) this.mountEntity(null); + lastRider = null; setHealth(-1); setSprinting(false); getNavigator().clearPathEntity(); @@ -2158,21 +2166,60 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti @Override public void updateRiderPosition() { - super.updateRiderPosition(); if (advanced.role == EnumRoleType.Mount && roleInterface instanceof RoleMount && riddenByEntity != null) { RoleMount mount = (RoleMount) roleInterface; - double yaw = Math.toRadians(this.renderYawOffset); - double offsetX = mount.getOffsetX(); - double offsetZ = mount.getOffsetZ(); - double rotatedX = offsetX * Math.cos(yaw) - offsetZ * Math.sin(yaw); - double rotatedZ = offsetX * Math.sin(yaw) + offsetZ * Math.cos(yaw); - double offsetY = mount.getOffsetY(); - riddenByEntity.setPosition(this.posX + rotatedX, - this.posY + this.getMountedYOffset() + riddenByEntity.getYOffset() + offsetY, - this.posZ + rotatedZ); + double scale = Math.max(0.1D, this.display.modelSize / 5.0D); + Vec3 seat = Vec3.createVectorHelper(mount.getOffsetX(), 0.0D, mount.getOffsetZ() + (0.8D * scale)); + seat.rotateAroundY((float) Math.toRadians(-this.renderYawOffset)); + double px = this.posX + seat.xCoord; + double py = this.posY + this.getMountedYOffset() + riddenByEntity.getYOffset() + mount.getOffsetY(); + double pz = this.posZ + seat.zCoord; + + riddenByEntity.setPosition(px, py, pz); + + if (riddenByEntity instanceof EntityLivingBase) { + EntityLivingBase rider = (EntityLivingBase) riddenByEntity; + rider.prevRotationPitch = rider.rotationPitch; + rider.prevRotationYaw = rider.rotationYaw; + rider.setRenderYawOffset(this.renderYawOffset); + rider.setRotationYawHead(this.renderYawOffset); + } + } else { + super.updateRiderPosition(); } } + private void handleMountRiderState() { + if (worldObj.isRemote) { + if (advanced.role != EnumRoleType.Mount || !(roleInterface instanceof RoleMount)) { + lastRider = null; + } + return; + } + + if (advanced.role != EnumRoleType.Mount || !(roleInterface instanceof RoleMount)) { + lastRider = null; + return; + } + + Entity currentRider = this.riddenByEntity; + if (currentRider != lastRider) { + if (lastRider != null) { + stabilizeDismountedRider(lastRider); + } + lastRider = currentRider; + } + } + + private void stabilizeDismountedRider(Entity rider) { + rider.motionX = 0.0D; + rider.motionY = 0.0D; + rider.motionZ = 0.0D; + rider.fallDistance = 0.0F; + rider.velocityChanged = true; + rider.onGround = true; + } + // Model Types: 0: Steve 64x32, 1: Steve 64x64, 2: Alex 64x64 public int getModelType() { return this.display.modelType; diff --git a/src/main/java/noppes/npcs/roles/RoleMount.java b/src/main/java/noppes/npcs/roles/RoleMount.java index 455f8f329..e3ee3bf25 100644 --- a/src/main/java/noppes/npcs/roles/RoleMount.java +++ b/src/main/java/noppes/npcs/roles/RoleMount.java @@ -62,6 +62,7 @@ public class RoleMount extends RoleInterface { @Override public boolean aiShouldExecute() { if (npc.ais.returnToStart) { + storedReturnToStart = true; npc.ais.returnToStart = false; } return false; @@ -91,6 +92,15 @@ public class RoleMount extends RoleInterface { return offsetZ; } + public void setReturnToStartPreference(boolean value) { + this.storedReturnToStart = value; + npc.ais.returnToStart = false; + } + + public boolean getReturnToStartPreference() { + return storedReturnToStart; + } + private float clamp(float value) { return ValueUtil.clamp(value, -5.0F, 5.0F); } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 53f26f5d9..8b632f7ce 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -32,6 +32,7 @@ import noppes.npcs.controllers.data.DialogOption; import noppes.npcs.controllers.data.Line; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.roles.RoleMount; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.AnimationType; import noppes.npcs.scripted.constants.EntityType; @@ -269,13 +270,20 @@ public class ScriptNpc extends ScriptLiving imp * @param bo Whether or not the npc will try to return to his home position */ public void setReturnToHome(boolean bo) { - npc.ais.returnToStart = bo; + if (npc.advanced.role == EnumRoleType.Mount && npc.roleInterface instanceof RoleMount) { + ((RoleMount) npc.roleInterface).setReturnToStartPreference(bo); + } else { + npc.ais.returnToStart = bo; + } } /** * @return Whether or not the npc returns home */ public boolean getReturnToHome() { + if (npc.advanced.role == EnumRoleType.Mount && npc.roleInterface instanceof RoleMount) { + return ((RoleMount) npc.roleInterface).getReturnToStartPreference(); + } return npc.ais.returnToStart; } From 1754aa536a74f113aed20cacb841de563cdc9252 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 6 Nov 2025 01:43:00 -0500 Subject: [PATCH 3/6] Fix mount rider jump handling --- .../java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java | 1 + .../java/noppes/npcs/entity/EntityNPCInterface.java | 10 ++++++---- src/main/resources/META-INF/customnpcs_at.cfg | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java index cc785f299..6e0ebfa6e 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java @@ -15,6 +15,7 @@ import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.constants.EnumCombatPolicy; import noppes.npcs.constants.EnumNavType; +import noppes.npcs.constants.EnumRoleType; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleMount; diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 5602ba027..5b5bb06c2 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -2135,7 +2135,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti protected void applyMountedVerticalMotion(EntityLivingBase rider, float moveSpeed) { if (canFly()) { double vertical = Math.max(0.1D, moveSpeed * 0.6D); - if (rider.isJumping()) { + if (rider.isJumping) { this.motionY = Math.min(this.motionY + vertical, vertical); this.isAirBorne = true; } else { @@ -2148,7 +2148,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti this.motionY *= 0.6D; } } - } else if (rider.isJumping() && this.onGround) { + } else if (rider.isJumping && this.onGround) { this.motionY = 0.5D; this.isAirBorne = true; } @@ -2181,8 +2181,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti EntityLivingBase rider = (EntityLivingBase) riddenByEntity; rider.prevRotationPitch = rider.rotationPitch; rider.prevRotationYaw = rider.rotationYaw; - rider.setRenderYawOffset(this.renderYawOffset); - rider.setRotationYawHead(this.renderYawOffset); + rider.prevRenderYawOffset = this.renderYawOffset; + rider.renderYawOffset = this.renderYawOffset; + rider.prevRotationYawHead = this.renderYawOffset; + rider.rotationYawHead = this.renderYawOffset; } } else { super.updateRiderPosition(); diff --git a/src/main/resources/META-INF/customnpcs_at.cfg b/src/main/resources/META-INF/customnpcs_at.cfg index 990efc151..5597bbba8 100644 --- a/src/main/resources/META-INF/customnpcs_at.cfg +++ b/src/main/resources/META-INF/customnpcs_at.cfg @@ -17,6 +17,7 @@ public net.minecraft.client.renderer.ItemRenderer field_78453_b # itemToRender public net.minecraft.client.renderer.entity.RenderPlayer func_77043_a(Lnet/minecraft/entity/EntityLivingBase;FFF)V # rotateCorpse #EntityLivingBase public net.minecraft.entity.EntityLivingBase func_82166_i()I # getArmSwingAnimationEnd +public net.minecraft.entity.EntityLivingBase field_70703_bu # isJumping # Minecraft public net.minecraft.client.Minecraft field_147126_aw # mcMusicTicker # MusicTicker From b035f4e18846181bb6b43d4fc21e3a31d4d90150 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 6 Nov 2025 02:00:55 -0500 Subject: [PATCH 4/6] Smooth mount steering and halt dismount drift --- .../noppes/npcs/entity/EntityNPCFlying.java | 8 +-- .../npcs/entity/EntityNPCInterface.java | 59 ++++++++++++++++--- 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index bba547c61..78a7ee23a 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -97,9 +97,9 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { } @Override - protected void doMountedMovement(float strafe, float forward) { + protected void doMountedMovement(float strafe, float forward, float moveSpeed) { if (!this.canFly() || this.hurtTime != 0 || !this.canBreathe()) { - super.doMountedMovement(strafe, forward); + super.doMountedMovement(strafe, forward, moveSpeed); return; } @@ -120,14 +120,14 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { if (!this.getNavigator().noPath() && this.motionY > 0) { this.motionY = 0; } else { - super.doMountedMovement(strafe, forward); + super.doMountedMovement(strafe, forward, moveSpeed); return; } } this.flyLimitAllow = true; double d3 = this.motionY; - super.doMountedMovement(strafe, forward); + super.doMountedMovement(strafe, forward, moveSpeed); this.motionY = d3; if (this.getNavigator().noPath()) { diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 5b5bb06c2..56bc0df8c 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -68,6 +68,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraft.world.WorldServer; +import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.ServerChatEvent; @@ -1487,6 +1488,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti if (this.riddenByEntity != null) { stabilizeDismountedRider(this.riddenByEntity); this.riddenByEntity.mountEntity(null); + haltMountedMotion(); } if (this.ridingEntity != null) this.mountEntity(null); @@ -2105,15 +2107,14 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti controlledForward *= 0.25F; } - float moveSpeed = getSpeed(); + float moveSpeed = Math.max(0.1F, getSpeed()); if (rider.isSprinting()) { moveSpeed *= 1.2F; } this.setSprinting(rider.isSprinting()); - this.setAIMoveSpeed(moveSpeed); this.stepHeight = 1.0F; - this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F; + this.jumpMovementFactor = moveSpeed * 0.1F; this.getNavigator().clearPathEntity(); this.setAttackTarget(null); @@ -2122,22 +2123,37 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti this.fallDistance = 0.0F; rider.fallDistance = 0.0F; - applyMountedVerticalMotion(rider, moveSpeed); - doMountedMovement(controlledStrafe, controlledForward); + applyMountedVerticalMotion(rider, moveSpeed, controlledForward); + doMountedMovement(controlledStrafe, controlledForward, moveSpeed); return true; } - protected void doMountedMovement(float strafe, float forward) { - super.moveEntityWithHeading(strafe, forward); + protected void doMountedMovement(float strafe, float forward, float moveSpeed) { + this.moveStrafing = strafe; + this.moveForward = forward; + if (!worldObj.isRemote) { + this.setAIMoveSpeed(moveSpeed); + super.moveEntityWithHeading(strafe, forward); + this.prevLimbSwingAmount = this.limbSwingAmount; + double deltaX = this.posX - this.prevPosX; + double deltaZ = this.posZ - this.prevPosZ; + float limbSwingSpeed = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ) * 4.0F; + if (limbSwingSpeed > 1.0F) { + limbSwingSpeed = 1.0F; + } + this.limbSwingAmount += (limbSwingSpeed - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; + } } - protected void applyMountedVerticalMotion(EntityLivingBase rider, float moveSpeed) { + protected void applyMountedVerticalMotion(EntityLivingBase rider, float moveSpeed, float forward) { if (canFly()) { double vertical = Math.max(0.1D, moveSpeed * 0.6D); if (rider.isJumping) { this.motionY = Math.min(this.motionY + vertical, vertical); this.isAirBorne = true; + this.velocityChanged = true; } else { float pitch = rider.rotationPitch; if (pitch < -10F) { @@ -2149,8 +2165,17 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } } } else if (rider.isJumping && this.onGround) { - this.motionY = 0.5D; + double jumpVelocity = MathHelper.clamp_double(0.4D + moveSpeed * 1.5D, 0.4D, 0.9D); + this.motionY = jumpVelocity; this.isAirBorne = true; + this.velocityChanged = true; + if (forward > 0.0F) { + float yawRadians = this.rotationYaw * (float) Math.PI / 180.0F; + double boost = 0.4D * forward; + this.motionX += -MathHelper.sin(yawRadians) * boost; + this.motionZ += MathHelper.cos(yawRadians) * boost; + } + ForgeHooks.onLivingJump(this); } } @@ -2208,6 +2233,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti if (currentRider != lastRider) { if (lastRider != null) { stabilizeDismountedRider(lastRider); + haltMountedMotion(); } lastRider = currentRider; } @@ -2222,6 +2248,21 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti rider.onGround = true; } + private void haltMountedMotion() { + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.velocityChanged = true; + this.isAirBorne = false; + this.setSprinting(false); + this.moveForward = 0.0F; + this.moveStrafing = 0.0F; + this.setAIMoveSpeed(0.0F); + this.limbSwingAmount = 0.0F; + this.limbSwing = 0.0F; + this.getNavigator().clearPathEntity(); + } + // Model Types: 0: Steve 64x32, 1: Steve 64x64, 2: Alex 64x64 public int getModelType() { return this.display.modelType; From bed60002c35ec58c866e7bc2536ee00f69cc22d1 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 6 Nov 2025 02:14:11 -0500 Subject: [PATCH 5/6] Restrict mount riders and expose jump controls --- .../npcs/client/gui/roles/GuiNpcMount.java | 27 ++++++++- .../npcs/entity/EntityNPCInterface.java | 60 ++++++++++++++----- .../java/noppes/npcs/roles/RoleMount.java | 29 +++++++++ .../assets/customnpcs/lang/cs_CZ.lang | 2 + .../assets/customnpcs/lang/de_DE.lang | 2 + .../assets/customnpcs/lang/en_US.lang | 2 + .../assets/customnpcs/lang/es_AR.lang | 2 + .../assets/customnpcs/lang/es_MX.lang | 2 + .../assets/customnpcs/lang/fr_FR.lang | 2 + .../assets/customnpcs/lang/hu_HU.lang | 2 + .../assets/customnpcs/lang/id_ID.lang | 2 + .../assets/customnpcs/lang/ko_KR.lang | 2 + .../assets/customnpcs/lang/nl_NL.lang | 2 + .../assets/customnpcs/lang/pl_PL.lang | 2 + .../assets/customnpcs/lang/pt_BR.lang | 2 + .../assets/customnpcs/lang/ru_RU.lang | 2 + .../assets/customnpcs/lang/sv_SE.lang | 2 + .../assets/customnpcs/lang/zh_CN.lang | 2 + .../assets/customnpcs/lang/zh_TW.lang | 2 + 19 files changed, 130 insertions(+), 18 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcMount.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcMount.java index 57f39a6d8..0a2a2a450 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcMount.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcMount.java @@ -38,10 +38,16 @@ public class GuiNpcMount extends GuiNPCInterface2 implements ITextfieldListener addOffsetRow(1, "role.mount.offsety", role.getOffsetY(), y); y += 24; addOffsetRow(2, "role.mount.offsetz", role.getOffsetZ(), y); + y += 24; + addJumpRow(3, "role.mount.jumpheight", role.getJumpStrength(), y); + y += 24; - addButton(new GuiNpcButton(3, guiLeft + 4, y + 26, 80, 20, "role.mount.reset")); + addLabel(new GuiNpcLabel(5, "role.mount.sprint", guiLeft + 4, y + 5)); + addButton(new GuiNpcButton(5, guiLeft + 140, y, 60, 20, new String[]{"gui.no", "gui.yes"}, role.isSprintAllowed() ? 1 : 0)); - GuiNpcLabel speedLabel = new GuiNpcLabel(4, "", guiLeft + 4, y + 6); + addButton(new GuiNpcButton(4, guiLeft + 4, y + 30, 80, 20, "role.mount.reset")); + + GuiNpcLabel speedLabel = new GuiNpcLabel(6, "", guiLeft + 4, y + 56); speedLabel.label = StatCollector.translateToLocalFormatted("role.mount.walkspeed", npc.ais.getWalkingSpeed()); addLabel(speedLabel); } @@ -54,6 +60,14 @@ public class GuiNpcMount extends GuiNPCInterface2 implements ITextfieldListener addTextField(field); } + private void addJumpRow(int id, String translationKey, float value, int y) { + addLabel(new GuiNpcLabel(id, translationKey, guiLeft + 4, y + 5)); + GuiNpcTextField field = new GuiNpcTextField(id, this, guiLeft + 140, y, 80, 20, format(value)); + field.floatsOnly = true; + field.setMinMaxDefaultFloat(0.1F, 3.0F, 1.0F); + addTextField(field); + } + private String format(float value) { return String.format(Locale.ROOT, "%.2f", value); } @@ -62,9 +76,11 @@ public class GuiNpcMount extends GuiNPCInterface2 implements ITextfieldListener public void buttonEvent(GuiButton guibutton) { if (role == null) return; - if (guibutton.id == 3) { + if (guibutton.id == 4) { role.resetOffsets(); initGui(); + } else if (guibutton.id == 5 && guibutton instanceof GuiNpcButton) { + role.setSprintAllowed(((GuiNpcButton) guibutton).getValue() == 1); } } @@ -83,6 +99,9 @@ public class GuiNpcMount extends GuiNPCInterface2 implements ITextfieldListener case 2: role.setOffsetZ(value); break; + case 3: + role.setJumpStrength(value); + break; } textfield.setText(format(valueForField(textfield.id))); } @@ -95,6 +114,8 @@ public class GuiNpcMount extends GuiNPCInterface2 implements ITextfieldListener return role.getOffsetY(); case 2: return role.getOffsetZ(); + case 3: + return role.getJumpStrength(); default: return 0.0F; } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 56bc0df8c..4f0abbe61 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -2091,10 +2091,15 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti protected boolean handleMountedMovement(float strafe, float forward) { if (advanced.role != EnumRoleType.Mount || !(roleInterface instanceof RoleMount)) return false; - if (!(riddenByEntity instanceof EntityLivingBase)) + if (riddenByEntity != null && !(riddenByEntity instanceof EntityPlayer)) { + riddenByEntity.mountEntity(null); + return false; + } + if (!(riddenByEntity instanceof EntityPlayer)) return false; - EntityLivingBase rider = (EntityLivingBase) riddenByEntity; + RoleMount mount = (RoleMount) roleInterface; + EntityPlayer rider = (EntityPlayer) riddenByEntity; this.prevRotationYaw = this.rotationYaw = rider.rotationYaw; this.rotationPitch = rider.rotationPitch * 0.5F; this.setRotation(this.rotationYaw, this.rotationPitch); @@ -2108,11 +2113,16 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } float moveSpeed = Math.max(0.1F, getSpeed()); - if (rider.isSprinting()) { + boolean riderSprinting = rider.isSprinting() && mount.isSprintAllowed(); + if (riderSprinting) { moveSpeed *= 1.2F; } - this.setSprinting(rider.isSprinting()); + if (!mount.isSprintAllowed() && rider.isSprinting()) { + rider.setSprinting(false); + } + + this.setSprinting(riderSprinting); this.stepHeight = 1.0F; this.jumpMovementFactor = moveSpeed * 0.1F; @@ -2135,21 +2145,33 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti if (!worldObj.isRemote) { this.setAIMoveSpeed(moveSpeed); super.moveEntityWithHeading(strafe, forward); - this.prevLimbSwingAmount = this.limbSwingAmount; - double deltaX = this.posX - this.prevPosX; - double deltaZ = this.posZ - this.prevPosZ; - float limbSwingSpeed = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ) * 4.0F; - if (limbSwingSpeed > 1.0F) { - limbSwingSpeed = 1.0F; - } - this.limbSwingAmount += (limbSwingSpeed - this.limbSwingAmount) * 0.4F; - this.limbSwing += this.limbSwingAmount; } + + this.prevLimbSwingAmount = this.limbSwingAmount; + double deltaX = this.posX - this.prevPosX; + double deltaZ = this.posZ - this.prevPosZ; + if (worldObj.isRemote && deltaX * deltaX + deltaZ * deltaZ < 1.0E-6D) { + deltaX = this.motionX; + deltaZ = this.motionZ; + } + float limbSwingSpeed = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ) * 4.0F; + if (limbSwingSpeed > 1.0F) { + limbSwingSpeed = 1.0F; + } + this.limbSwingAmount += (limbSwingSpeed - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; } protected void applyMountedVerticalMotion(EntityLivingBase rider, float moveSpeed, float forward) { + if (!(roleInterface instanceof RoleMount)) { + return; + } + RoleMount mount = (RoleMount) roleInterface; + double jumpFactor = MathHelper.clamp_double(mount.getJumpStrength(), 0.1D, 3.0D); + if (canFly()) { - double vertical = Math.max(0.1D, moveSpeed * 0.6D); + double verticalBase = Math.max(0.1D, moveSpeed * 0.6D); + double vertical = MathHelper.clamp_double(verticalBase * jumpFactor, 0.05D, 2.0D); if (rider.isJumping) { this.motionY = Math.min(this.motionY + vertical, vertical); this.isAirBorne = true; @@ -2165,7 +2187,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } } } else if (rider.isJumping && this.onGround) { - double jumpVelocity = MathHelper.clamp_double(0.4D + moveSpeed * 1.5D, 0.4D, 0.9D); + double baseVelocity = MathHelper.clamp_double(0.4D + moveSpeed * 1.5D, 0.2D, 1.2D); + double jumpVelocity = MathHelper.clamp_double(baseVelocity * jumpFactor, 0.2D, 2.0D); this.motionY = jumpVelocity; this.isAirBorne = true; this.velocityChanged = true; @@ -2230,6 +2253,13 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } Entity currentRider = this.riddenByEntity; + if (currentRider != null && !(currentRider instanceof EntityPlayer)) { + Entity dismount = currentRider; + dismount.mountEntity(null); + stabilizeDismountedRider(dismount); + haltMountedMotion(); + currentRider = null; + } if (currentRider != lastRider) { if (lastRider != null) { stabilizeDismountedRider(lastRider); diff --git a/src/main/java/noppes/npcs/roles/RoleMount.java b/src/main/java/noppes/npcs/roles/RoleMount.java index e3ee3bf25..a1a07c800 100644 --- a/src/main/java/noppes/npcs/roles/RoleMount.java +++ b/src/main/java/noppes/npcs/roles/RoleMount.java @@ -10,7 +10,12 @@ public class RoleMount extends RoleInterface { private float offsetX; private float offsetY; private float offsetZ; + private static final float MIN_JUMP_STRENGTH = 0.1F; + private static final float MAX_JUMP_STRENGTH = 3.0F; + private boolean storedReturnToStart; + private float jumpStrength = 1.0F; + private boolean allowSprint = true; public RoleMount(EntityNPCInterface npc) { super(npc); @@ -24,6 +29,8 @@ public class RoleMount extends RoleInterface { compound.setFloat("MountOffsetY", offsetY); compound.setFloat("MountOffsetZ", offsetZ); compound.setBoolean("MountReturnFlag", storedReturnToStart); + compound.setFloat("MountJumpStrength", jumpStrength); + compound.setBoolean("MountAllowSprint", allowSprint); return compound; } @@ -37,6 +44,12 @@ public class RoleMount extends RoleInterface { } else { storedReturnToStart = npc.ais.returnToStart; } + if (compound.hasKey("MountJumpStrength")) { + setJumpStrength(compound.getFloat("MountJumpStrength")); + } else { + jumpStrength = 1.0F; + } + allowSprint = !compound.hasKey("MountAllowSprint") || compound.getBoolean("MountAllowSprint"); npc.ais.returnToStart = false; } @@ -92,6 +105,22 @@ public class RoleMount extends RoleInterface { return offsetZ; } + public void setJumpStrength(float value) { + this.jumpStrength = ValueUtil.clamp(value, MIN_JUMP_STRENGTH, MAX_JUMP_STRENGTH); + } + + public float getJumpStrength() { + return jumpStrength; + } + + public void setSprintAllowed(boolean allowSprint) { + this.allowSprint = allowSprint; + } + + public boolean isSprintAllowed() { + return allowSprint; + } + public void setReturnToStartPreference(boolean value) { this.storedReturnToStart = value; npc.ais.returnToStart = false; diff --git a/src/main/resources/assets/customnpcs/lang/cs_CZ.lang b/src/main/resources/assets/customnpcs/lang/cs_CZ.lang index e9cd29b99..e574a1fb1 100644 --- a/src/main/resources/assets/customnpcs/lang/cs_CZ.lang +++ b/src/main/resources/assets/customnpcs/lang/cs_CZ.lang @@ -443,5 +443,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/de_DE.lang b/src/main/resources/assets/customnpcs/lang/de_DE.lang index 38f3d3377..86269b7b0 100644 --- a/src/main/resources/assets/customnpcs/lang/de_DE.lang +++ b/src/main/resources/assets/customnpcs/lang/de_DE.lang @@ -875,5 +875,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index c3edc664e..6026ed59a 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -421,6 +421,8 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/es_AR.lang b/src/main/resources/assets/customnpcs/lang/es_AR.lang index 5ca50fc49..f0d9533a2 100644 --- a/src/main/resources/assets/customnpcs/lang/es_AR.lang +++ b/src/main/resources/assets/customnpcs/lang/es_AR.lang @@ -503,5 +503,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/es_MX.lang b/src/main/resources/assets/customnpcs/lang/es_MX.lang index fd58878af..9b3ee6a1f 100644 --- a/src/main/resources/assets/customnpcs/lang/es_MX.lang +++ b/src/main/resources/assets/customnpcs/lang/es_MX.lang @@ -503,5 +503,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/fr_FR.lang b/src/main/resources/assets/customnpcs/lang/fr_FR.lang index 6229aa1b9..6fc66154c 100644 --- a/src/main/resources/assets/customnpcs/lang/fr_FR.lang +++ b/src/main/resources/assets/customnpcs/lang/fr_FR.lang @@ -545,5 +545,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/hu_HU.lang b/src/main/resources/assets/customnpcs/lang/hu_HU.lang index e3112252c..63ee943af 100644 --- a/src/main/resources/assets/customnpcs/lang/hu_HU.lang +++ b/src/main/resources/assets/customnpcs/lang/hu_HU.lang @@ -545,5 +545,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/id_ID.lang b/src/main/resources/assets/customnpcs/lang/id_ID.lang index a7de30101..2b53a9639 100644 --- a/src/main/resources/assets/customnpcs/lang/id_ID.lang +++ b/src/main/resources/assets/customnpcs/lang/id_ID.lang @@ -320,5 +320,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/ko_KR.lang b/src/main/resources/assets/customnpcs/lang/ko_KR.lang index 64b370445..89f7c8d7d 100644 --- a/src/main/resources/assets/customnpcs/lang/ko_KR.lang +++ b/src/main/resources/assets/customnpcs/lang/ko_KR.lang @@ -800,5 +800,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/nl_NL.lang b/src/main/resources/assets/customnpcs/lang/nl_NL.lang index 6998ad909..acae2f273 100644 --- a/src/main/resources/assets/customnpcs/lang/nl_NL.lang +++ b/src/main/resources/assets/customnpcs/lang/nl_NL.lang @@ -235,5 +235,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/pl_PL.lang b/src/main/resources/assets/customnpcs/lang/pl_PL.lang index 0526906d6..ff860e0ab 100644 --- a/src/main/resources/assets/customnpcs/lang/pl_PL.lang +++ b/src/main/resources/assets/customnpcs/lang/pl_PL.lang @@ -501,5 +501,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/pt_BR.lang b/src/main/resources/assets/customnpcs/lang/pt_BR.lang index 3e5411213..066697e8c 100644 --- a/src/main/resources/assets/customnpcs/lang/pt_BR.lang +++ b/src/main/resources/assets/customnpcs/lang/pt_BR.lang @@ -501,5 +501,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/ru_RU.lang b/src/main/resources/assets/customnpcs/lang/ru_RU.lang index f190a84f0..a34739f0d 100644 --- a/src/main/resources/assets/customnpcs/lang/ru_RU.lang +++ b/src/main/resources/assets/customnpcs/lang/ru_RU.lang @@ -1024,5 +1024,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/sv_SE.lang b/src/main/resources/assets/customnpcs/lang/sv_SE.lang index adf43d88c..70a29ebc9 100644 --- a/src/main/resources/assets/customnpcs/lang/sv_SE.lang +++ b/src/main/resources/assets/customnpcs/lang/sv_SE.lang @@ -311,5 +311,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/zh_CN.lang b/src/main/resources/assets/customnpcs/lang/zh_CN.lang index 41799f778..00fb8c796 100644 --- a/src/main/resources/assets/customnpcs/lang/zh_CN.lang +++ b/src/main/resources/assets/customnpcs/lang/zh_CN.lang @@ -1247,5 +1247,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s diff --git a/src/main/resources/assets/customnpcs/lang/zh_TW.lang b/src/main/resources/assets/customnpcs/lang/zh_TW.lang index 6b864af53..a4f3d4ae5 100644 --- a/src/main/resources/assets/customnpcs/lang/zh_TW.lang +++ b/src/main/resources/assets/customnpcs/lang/zh_TW.lang @@ -317,5 +317,7 @@ role.mount=Mount role.mount.offsetx=Seat Offset X role.mount.offsety=Seat Offset Y role.mount.offsetz=Seat Offset Z +role.mount.jumpheight=Jump Strength +role.mount.sprint=Allow Sprinting role.mount.reset=Reset Position role.mount.walkspeed=Walking speed: %s From f65662efafd3a86e9f73d681429334d2dac58cb1 Mon Sep 17 00:00:00 2001 From: Kam Date: Thu, 6 Nov 2025 02:34:47 -0500 Subject: [PATCH 6/6] Preserve airborne momentum when mounts dismount riders --- .../npcs/entity/EntityNPCInterface.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 4f0abbe61..96310a01e 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -2270,12 +2270,26 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } private void stabilizeDismountedRider(Entity rider) { - rider.motionX = 0.0D; - rider.motionY = 0.0D; - rider.motionZ = 0.0D; - rider.fallDistance = 0.0F; + boolean wasOnGround = rider.onGround; + double previousMotionX = rider.motionX; + double previousMotionY = rider.motionY; + double previousMotionZ = rider.motionZ; + float previousFall = rider.fallDistance; + + if (wasOnGround) { + rider.motionX = 0.0D; + rider.motionY = 0.0D; + rider.motionZ = 0.0D; + rider.fallDistance = 0.0F; + rider.onGround = true; + } else { + rider.motionX = previousMotionX; + rider.motionY = previousMotionY; + rider.motionZ = previousMotionZ; + rider.fallDistance = previousFall; + } + rider.velocityChanged = true; - rider.onGround = true; } private void haltMountedMotion() {