diff --git a/src/main/java/electroblob/wizardry/potion/PotionContainment.java b/src/main/java/electroblob/wizardry/potion/PotionContainment.java index ef12241f..cfd83c3a 100644 --- a/src/main/java/electroblob/wizardry/potion/PotionContainment.java +++ b/src/main/java/electroblob/wizardry/potion/PotionContainment.java @@ -2,17 +2,14 @@ package electroblob.wizardry.potion; import electroblob.wizardry.Wizardry; import electroblob.wizardry.registry.WizardryPotions; +import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.util.EntityUtils; import electroblob.wizardry.util.GeometryUtils; import electroblob.wizardry.util.NBTExtras; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTUtil; -import net.minecraft.network.play.server.SPacketEntityVelocity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.fml.common.Mod; @@ -23,8 +20,6 @@ public class PotionContainment extends PotionMagicEffect { public static final String ENTITY_TAG = "containmentPos"; - private static final double RUBBERBAND_THRESHOLD = 0.24; - public PotionContainment(boolean isBadEffect, int liquidColour){ super(isBadEffect, liquidColour, new ResourceLocation(Wizardry.MODID, "textures/gui/potion_icons/containment.png")); this.setPotionName("potion." + Wizardry.MODID + ":containment"); @@ -41,7 +36,6 @@ public class PotionContainment extends PotionMagicEffect { @Override public void performEffect(EntityLivingBase target, int strength){ - float maxDistance = getContainmentDistance(strength); // Initialise the containment position to the entity's position if it wasn't set already @@ -63,59 +57,15 @@ public class PotionContainment extends PotionMagicEffect { if(target.getEntityBoundingBox().maxZ > origin.z + maxDistance) z = origin.z + maxDistance - target.width/2; if(target.getEntityBoundingBox().minZ < origin.z - maxDistance) z = origin.z - maxDistance + target.width/2; - if(x != target.posX || y != target.posY || z != target.posZ){ + if(x != target.posX || y != target.posY || z != target.posZ) + { + if(target.world.isRemote){ + EntityUtils.undoGravity(target); + target.addVelocity(0.15 * Math.signum(x - target.posX), 0.15 * Math.signum(y - target.posY), 0.15 * Math.signum(z - target.posZ)); -// if(target.world.isRemote){ -// -// if(x != target.posX){ -// for(int i = 0; i < 20; i++){ -// ParticleBuilder.create(ParticleBuilder.Type.DUST).pos( -// x, -// target.posY + target.height * target.world.rand.nextFloat(), -// target.posZ + target.width * (target.world.rand.nextFloat() - 0.5f)) -// .face(EnumFacing.EAST).clr(0.8f, 0.9f, 1).spawn(target.world); -// } -// } -// -// if(y != target.posY){ -// for(int i = 0; i < 20; i++){ -// ParticleBuilder.create(ParticleBuilder.Type.DUST).pos( -// target.posX + target.width * (target.world.rand.nextFloat() - 0.5f), -// y, -// target.posZ + target.width * (target.world.rand.nextFloat() - 0.5f)) -// .face(EnumFacing.UP).clr(0.8f, 0.9f, 1).spawn(target.world); -// } -// } -// -// if(z != target.posZ){ -// for(int i = 0; i < 20; i++){ -// ParticleBuilder.create(ParticleBuilder.Type.DUST).pos( -// target.posX + target.width * (target.world.rand.nextFloat() - 0.5f), -// target.posY + target.height * target.world.rand.nextFloat(), -// z) -// .face(EnumFacing.SOUTH).clr(0.8f, 0.9f, 1).spawn(target.world); -// } -// } -// } - - // Rubberbanding prevention (the 0.25 limit is from NetHandlerPlayServer, just search "moved wrongly" - if(target instanceof EntityPlayer){ - x = MathHelper.clamp(x, target.posX - RUBBERBAND_THRESHOLD, target.posX + RUBBERBAND_THRESHOLD); - y = MathHelper.clamp(y, target.posY - RUBBERBAND_THRESHOLD, target.posY + RUBBERBAND_THRESHOLD); - z = MathHelper.clamp(z, target.posZ - RUBBERBAND_THRESHOLD, target.posZ + RUBBERBAND_THRESHOLD); + target.world.playSound(target.posX, target.posY, target.posZ, WizardrySounds.ENTITY_FORCEFIELD_DEFLECT, + WizardrySounds.SPELLS, 0.3f, 1f, false); } - - EntityUtils.undoGravity(target); - target.addVelocity(0.35 * Math.signum(x - target.posX), 0.35 * Math.signum(y - target.posY), 0.35 * Math.signum(z - target.posZ)); - target.setPositionAndUpdate(x, y, z); // FIXME: This line must be causing the server rubberbanding, not sure why - // Player motion is handled on that player's client so needs packets - if(target instanceof EntityPlayerMP){ - ((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target)); - } -// -// target.world.playSound(target.posX, target.posY, target.posZ, WizardrySounds.ENTITY_FORCEFIELD_DEFLECT, -// WizardrySounds.SPELLS, 0.3f, 1f, false); - } // Need to do this here because it's the only way to hook into potion ending both client- and server-side