From b66fe9d18afcb6899885b984abdac61d1c41a5f1 Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 1 Jul 2019 16:47:36 +0800 Subject: [PATCH] Fix dolphins, pufferfish error and phantom looking --- .../v1_13_R2/entity/DolphinController.java | 4 +- .../v1_13_R2/entity/PufferFishController.java | 3 -- .../nms/v1_13_R2/util/NMSImpl.java | 7 +-- .../v1_14_R1/entity/DolphinController.java | 43 +++++++++---------- .../v1_14_R1/entity/PufferFishController.java | 42 ++++++++---------- .../nms/v1_14_R1/util/NMSImpl.java | 7 +-- 6 files changed, 50 insertions(+), 56 deletions(-) diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/DolphinController.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/DolphinController.java index 036dea5b7..0133371bb 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/DolphinController.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/DolphinController.java @@ -182,8 +182,8 @@ public class DolphinController extends MobEntityController { } @Override - public void mobTick() { - super.mobTick(); + public void tick() { + super.tick(); if (npc != null) { npc.update(); } diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/PufferFishController.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/PufferFishController.java index 020f8c088..1ac465971 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/PufferFishController.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/entity/PufferFishController.java @@ -170,9 +170,6 @@ public class PufferFishController extends MobEntityController { @Override public void mobTick() { - if (npc != null) { - NMSImpl.setNotInSchool(this); - } super.mobTick(); if (npc != null) { npc.update(); diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java index 286246846..2eaa9bc48 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java @@ -706,7 +706,8 @@ public class NMSImpl implements NMSBridge { double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff); double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ)); - double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90; + double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) + - (handle.getBukkitEntity().getType() == EntityType.PHANTOM ? 45 : 90); if (zDiff < 0.0) yaw += Math.abs(180 - yaw) * 2; if (handle instanceof EntityEnderDragon) { @@ -739,7 +740,6 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - BAD_CONTROLLER_LOOK.add(EntityType.SHULKER); if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); @@ -1625,7 +1625,8 @@ public class NMSImpl implements NMSBridge { private static MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class, "cf"); private static final Set BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, - EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST); + EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST, EntityType.SHULKER, + EntityType.PHANTOM); private static final Method BLOCK_POSITION_B_D = NMS.getMethod(BlockPosition.PooledBlockPosition.class, "e", false, double.class, double.class, double.class); private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle"); diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/DolphinController.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/DolphinController.java index 7731134d5..79101201e 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/DolphinController.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/DolphinController.java @@ -1,7 +1,5 @@ package net.citizensnpcs.nms.v1_14_R1.entity; -import net.minecraft.server.v1_14_R1.Vec3D; - import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_14_R1.CraftServer; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftDolphin; @@ -23,6 +21,7 @@ import net.minecraft.server.v1_14_R1.EntityTypes; import net.minecraft.server.v1_14_R1.IBlockData; import net.minecraft.server.v1_14_R1.NBTTagCompound; import net.minecraft.server.v1_14_R1.SoundEffect; +import net.minecraft.server.v1_14_R1.Vec3D; import net.minecraft.server.v1_14_R1.World; public class DolphinController extends MobEntityController { @@ -72,15 +71,6 @@ public class DolphinController extends MobEntityController { } } - @Override - public void e(Vec3D vec3d) { - if (npc == null || !npc.isFlyable()) { - super.e(vec3d); - } else { - NMSImpl.flyingMoveLogic(this, vec3d); - } - } - @Override public void b(float f, float f1) { if (npc == null || !npc.isFlyable()) { @@ -109,6 +99,15 @@ public class DolphinController extends MobEntityController { return npc == null ? super.d(save) : false; } + @Override + public void e(Vec3D vec3d) { + if (npc == null || !npc.isFlyable()) { + super.e(vec3d); + } else { + NMSImpl.flyingMoveLogic(this, vec3d); + } + } + @Override public void enderTeleportTo(double d0, double d1, double d2) { if (npc == null) { @@ -172,6 +171,15 @@ public class DolphinController extends MobEntityController { return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA); } + @Override + public boolean isClimbing() { + if (npc == null || !npc.isFlyable()) { + return super.isClimbing(); + } else { + return false; + } + } + @Override public boolean isLeashed() { if (npc == null) @@ -186,20 +194,11 @@ public class DolphinController extends MobEntityController { } @Override - public void mobTick() { - super.mobTick(); + public void tick() { + super.tick(); if (npc != null) { npc.update(); } } - - @Override - public boolean isClimbing() { - if (npc == null || !npc.isFlyable()) { - return super.isClimbing(); - } else { - return false; - } - } } } diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/PufferFishController.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/PufferFishController.java index 4855ca56f..8df634ea1 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/PufferFishController.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/entity/PufferFishController.java @@ -1,7 +1,5 @@ package net.citizensnpcs.nms.v1_14_R1.entity; -import net.minecraft.server.v1_14_R1.Vec3D; - import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_14_R1.CraftServer; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; @@ -24,6 +22,7 @@ import net.minecraft.server.v1_14_R1.EntityTypes; import net.minecraft.server.v1_14_R1.IBlockData; import net.minecraft.server.v1_14_R1.NBTTagCompound; import net.minecraft.server.v1_14_R1.SoundEffect; +import net.minecraft.server.v1_14_R1.Vec3D; import net.minecraft.server.v1_14_R1.World; public class PufferFishController extends MobEntityController { @@ -59,15 +58,6 @@ public class PufferFishController extends MobEntityController { } } - @Override - public void e(Vec3D vec3d) { - if (npc == null || !npc.isFlyable()) { - super.e(vec3d); - } else { - NMSImpl.flyingMoveLogic(this, vec3d); - } - } - @Override public void b(float f, float f1) { if (npc == null || !npc.isFlyable()) { @@ -96,6 +86,15 @@ public class PufferFishController extends MobEntityController { return npc == null ? super.d(save) : false; } + @Override + public void e(Vec3D vec3d) { + if (npc == null || !npc.isFlyable()) { + super.e(vec3d); + } else { + NMSImpl.flyingMoveLogic(this, vec3d); + } + } + @Override public void enderTeleportTo(double d0, double d1, double d2) { if (npc == null) { @@ -159,6 +158,15 @@ public class PufferFishController extends MobEntityController { return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA); } + @Override + public boolean isClimbing() { + if (npc == null || !npc.isFlyable()) { + return super.isClimbing(); + } else { + return false; + } + } + @Override public boolean isLeashed() { if (npc == null) @@ -174,23 +182,11 @@ public class PufferFishController extends MobEntityController { @Override public void mobTick() { - if (npc != null) { - NMSImpl.setNotInSchool(this); - } super.mobTick(); if (npc != null) { npc.update(); } } - - @Override - public boolean isClimbing() { - if (npc == null || !npc.isFlyable()) { - return super.isClimbing(); - } else { - return false; - } - } } public static class PufferFishNPC extends CraftPufferFish implements NPCHolder { diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java index e8ba9eec8..f2f9b6294 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java @@ -743,7 +743,8 @@ public class NMSImpl implements NMSBridge { double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff); double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ)); - double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90; + double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) + - (handle.getBukkitEntity().getType() == EntityType.PHANTOM ? 45 : 90); if (zDiff < 0.0) yaw += Math.abs(180 - yaw) * 2; if (handle instanceof EntityEnderDragon) { @@ -776,7 +777,6 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - BAD_CONTROLLER_LOOK.add(EntityType.SHULKER); if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); @@ -1668,7 +1668,8 @@ public class NMSImpl implements NMSBridge { "advancementDataPlayer"); private static final Set BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, - EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST); + EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST, EntityType.SHULKER, + EntityType.PHANTOM); private static final MethodHandle BEHAVIOR_MAP = NMS.getGetter(BehaviorController.class, "c"); private static final MethodHandle BLOCK_POSITION_B_D = NMS.getMethodHandle(BlockPosition.PooledBlockPosition.class, "c", false, double.class, double.class, double.class);