From 947af8727d1e50c82cbb50176d71c0975e3f0c3d Mon Sep 17 00:00:00 2001 From: 19 <84217661+19-creator@users.noreply.github.com> Date: Fri, 6 Jun 2025 15:19:17 -0500 Subject: [PATCH] Fixed barriers not allowing ally players in (#868) Had to edit telekinesis because it was had errors do to syntax. See comments in forcefield class for more information Co-authored-by: WinDanesz <31292708+WinDanesz@users.noreply.github.com> --- .../entity/construct/EntityForcefield.java | 42 ++++++++++++------- .../wizardry/spell/Telekinesis.java | 2 +- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java b/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java index 6f9f9ea1..e92efb11 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityForcefield.java @@ -146,23 +146,28 @@ public class EntityForcefield extends EntityMagicConstruct implements ICustomHit if(EntityUtils.isLiving(target)) nudgeVelocity = 0.25; Vec3d extraVelocity = targetRelativePos.normalize().scale(nudgeVelocity); - // ...make it bounce off! - target.motionX = target.motionX * -BOUNCINESS + extraVelocity.x; - target.motionY = target.motionY * -BOUNCINESS + extraVelocity.y; - target.motionZ = target.motionZ * -BOUNCINESS + extraVelocity.z; - - // Prevents the forcefield bouncing things into the floor - if(target.onGround && target.motionY < 0) target.motionY = 0.1; - - // How far the target needs to move towards the centre (negative means away from the centre) - double distanceTowardsCentre = -(targetRelativePos.length() - radius) - (radius - nextTickDistance); - Vec3d targetNewPos = target.getPositionVector().add(targetRelativePos.normalize().scale(distanceTowardsCentre)); - target.setPosition(targetNewPos.x, targetNewPos.y, targetNewPos.z); - - world.playSound(target.posX, target.posY, target.posZ, WizardrySounds.ENTITY_FORCEFIELD_DEFLECT, - WizardrySounds.SPELLS, 0.3f, 1.3f, false); - + //Moved up the check by "19" so that way allied players aren't being moved out of the forcefield because + //allied players aren't synced to client like minions. Minions are only synced because it's saved to their + //entity data which is synced in their serialize/deserialize methods if(!world.isRemote){ + // ...make it bounce off! + + target.motionX = target.motionX * -BOUNCINESS + extraVelocity.x; + target.motionY = target.motionY * -BOUNCINESS + extraVelocity.y; + target.motionZ = target.motionZ * -BOUNCINESS + extraVelocity.z; + + // Prevents the forcefield bouncing things into the floor + if(target.onGround && target.motionY < 0) target.motionY = 0.1; + + // How far the target needs to move towards the centre (negative means away from the centre) + double distanceTowardsCentre = -(targetRelativePos.length() - radius) - (radius - nextTickDistance); + Vec3d targetNewPos = target.getPositionVector().add(targetRelativePos.normalize().scale(distanceTowardsCentre)); + target.setPosition(targetNewPos.x, targetNewPos.y, targetNewPos.z); + + world.playSound(target.posX, target.posY, target.posZ, WizardrySounds.ENTITY_FORCEFIELD_DEFLECT, + WizardrySounds.SPELLS, 0.3f, 1.3f, false); + + // Player motion is handled on that player's client so needs packets if(target instanceof EntityPlayerMP){ ((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target)); @@ -174,6 +179,11 @@ public class EntityForcefield extends EntityMagicConstruct implements ICustomHit }else{ + //This is a super lazy way to make sure the visual isn't playing for players and probably won't display the visual + //for players if their velocity towards the forcefield is high. But it prevents the visual being spammed when ally player + //is in forcefield so it's fine #19 + if(target instanceof EntityPlayer && target.getPositionVector().distanceTo(this.getPositionVector()) < this.getRadius()) return; + Vec3d relativeImpactPos = targetRelativePos.normalize().scale(radius); float yaw = (float)Math.atan2(relativeImpactPos.x, -relativeImpactPos.z); diff --git a/src/main/java/electroblob/wizardry/spell/Telekinesis.java b/src/main/java/electroblob/wizardry/spell/Telekinesis.java index 0ac201cd..d27f1fbd 100644 --- a/src/main/java/electroblob/wizardry/spell/Telekinesis.java +++ b/src/main/java/electroblob/wizardry/spell/Telekinesis.java @@ -38,7 +38,7 @@ public class Telekinesis extends SpellRay { } else if (target instanceof EntityPlayer && (Wizardry.settings.telekineticDisarmament && !ItemArtefact.isArtefactActive((EntityPlayer) target, WizardryItems.amulet_anchoring))) { - EntityPlayer player = (EntityPlayer) target; + EntityPlayer player = (EntityPlayer) target; // IDEA: Disarm the offhand if the mainhand is empty or otherwise harmless?