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>
This commit is contained in:
@@ -146,23 +146,28 @@ public class EntityForcefield extends EntityMagicConstruct implements ICustomHit
|
|||||||
if(EntityUtils.isLiving(target)) nudgeVelocity = 0.25;
|
if(EntityUtils.isLiving(target)) nudgeVelocity = 0.25;
|
||||||
Vec3d extraVelocity = targetRelativePos.normalize().scale(nudgeVelocity);
|
Vec3d extraVelocity = targetRelativePos.normalize().scale(nudgeVelocity);
|
||||||
|
|
||||||
// ...make it bounce off!
|
//Moved up the check by "19" so that way allied players aren't being moved out of the forcefield because
|
||||||
target.motionX = target.motionX * -BOUNCINESS + extraVelocity.x;
|
//allied players aren't synced to client like minions. Minions are only synced because it's saved to their
|
||||||
target.motionY = target.motionY * -BOUNCINESS + extraVelocity.y;
|
//entity data which is synced in their serialize/deserialize methods
|
||||||
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);
|
|
||||||
|
|
||||||
if(!world.isRemote){
|
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
|
// Player motion is handled on that player's client so needs packets
|
||||||
if(target instanceof EntityPlayerMP){
|
if(target instanceof EntityPlayerMP){
|
||||||
((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target));
|
((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target));
|
||||||
@@ -174,6 +179,11 @@ public class EntityForcefield extends EntityMagicConstruct implements ICustomHit
|
|||||||
|
|
||||||
}else{
|
}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);
|
Vec3d relativeImpactPos = targetRelativePos.normalize().scale(radius);
|
||||||
|
|
||||||
float yaw = (float)Math.atan2(relativeImpactPos.x, -relativeImpactPos.z);
|
float yaw = (float)Math.atan2(relativeImpactPos.x, -relativeImpactPos.z);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class Telekinesis extends SpellRay {
|
|||||||
|
|
||||||
} else if (target instanceof EntityPlayer && (Wizardry.settings.telekineticDisarmament && !ItemArtefact.isArtefactActive((EntityPlayer) target, WizardryItems.amulet_anchoring))) {
|
} 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?
|
// IDEA: Disarm the offhand if the mainhand is empty or otherwise harmless?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user