From 383be360ffd46ab3be0bd400b6789c1926706f79 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Tue, 1 May 2018 21:39:15 -0400 Subject: [PATCH] Improved collision "i.e. actually made a non-retarded position update" for the Scroll of Icarus. --- .../item/soulBreath/ItemFlightScroll.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/item/soulBreath/ItemFlightScroll.java b/src/main/java/WayofTime/bloodmagic/item/soulBreath/ItemFlightScroll.java index 9d63d703..3eac2ed9 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soulBreath/ItemFlightScroll.java +++ b/src/main/java/WayofTime/bloodmagic/item/soulBreath/ItemFlightScroll.java @@ -86,7 +86,8 @@ public class ItemFlightScroll extends ItemSoulBreathContainer implements IMeshPr } } else { - + //TODO: Add an effect where it "draws back" like a bow in order to cast Levitation on a mob. + //Only Levitated mobs can be grabbed. } } @@ -269,8 +270,10 @@ public class ItemFlightScroll extends ItemSoulBreathContainer implements IMeshPr double offsetX = offset.x; double offsetY = offset.y; double offsetZ = offset.z; - double ownerSpeed = Math.sqrt(owner.motionX * owner.motionX + owner.motionY + owner.motionY + owner.motionZ + owner.motionZ); - double maxFollowSpeed = Math.max(ownerSpeed * 1.5, 0.5d); + double ownerSpeed = Math.sqrt(owner.motionX * owner.motionX + owner.motionY * owner.motionY + owner.motionZ * owner.motionZ); +// double ownerSpeed = Math.sqrt((owner.posX - owner.prevPosX) * (owner.posX - owner.prevPosX) + (owner.posY - owner.prevPosY) * (owner.posY - owner.prevPosY) + (owner.posZ - owner.prevPosZ) * (owner.posZ - owner.prevPosZ)); + + double speed = Math.max(ownerSpeed * 20, 2); //May just want to call it a day and set this to "2" livingEntity.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 20, 0, false, true)); @@ -278,10 +281,13 @@ public class ItemFlightScroll extends ItemSoulBreathContainer implements IMeshPr double wantedY = owner.posY + offsetY; double wantedZ = owner.posZ + offsetZ; -// livingEntity.posX = wantedX; -// livingEntity.posY = wantedY; -// livingEntity.posZ = wantedZ; - livingEntity.setPosition(wantedX, wantedY, wantedZ); + Vector3d vec = new Vector3d(wantedX - livingEntity.posX, wantedY - livingEntity.posY, wantedZ - livingEntity.posZ); + double vecDistance = Math.sqrt(vec.dot(vec)); + speed = Math.min(vecDistance, speed); + + vec.normalize(); + + livingEntity.setVelocity(vec.x * speed, vec.y * speed, vec.z * speed); } public void onEffectUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)