Fix dolphins, pufferfish error and phantom looking

This commit is contained in:
fullwall 2019-07-01 16:47:36 +08:00
parent 74836f6cc3
commit b66fe9d18a
6 changed files with 50 additions and 56 deletions

View File

@ -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();
}

View File

@ -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();

View File

@ -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<EntityType> 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");

View File

@ -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;
}
}
}
}

View File

@ -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 {

View File

@ -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<EntityType> 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);