mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Fix Guardians, EnderDragon looking and update how bats/silverfish/endermite looking is handled
This commit is contained in:
parent
bc9374d30c
commit
3a612d64b7
@ -111,7 +111,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
super.A_();
|
||||
if (npc == null)
|
||||
return;
|
||||
livingEntityBaseTick();
|
||||
livingEntityBaseTick();
|
||||
if (updateCounter + 1 > Setting.PACKET_UPDATE_DELAY.asInt()) {
|
||||
updateEffects = true;
|
||||
}
|
||||
@ -122,7 +122,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
g(0, 0);
|
||||
}
|
||||
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
@ -141,6 +140,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
npc.update();
|
||||
}
|
||||
|
||||
private float bodyControla(float paramFloat1, float paramFloat2, float paramFloat3) {
|
||||
float f = MathHelper.g(paramFloat1 - paramFloat2);
|
||||
if (f < -paramFloat3) {
|
||||
f = -paramFloat3;
|
||||
}
|
||||
if (f >= paramFloat3) {
|
||||
f = paramFloat3;
|
||||
}
|
||||
return paramFloat1 - f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_11_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
@ -284,6 +294,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return skinTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float h(float f, float f1) {
|
||||
return f1;
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
|
@ -53,15 +53,6 @@ public class GuardianController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
if (npc == null) {
|
||||
super.A_();
|
||||
} else {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.DEATH_SOUND_METADATA);
|
||||
@ -182,6 +173,16 @@ public class GuardianController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void n() {
|
||||
if (npc == null) {
|
||||
super.n();
|
||||
} else {
|
||||
NMSImpl.updateAI(this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
|
@ -53,15 +53,6 @@ public class GuardianElderController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
if (npc == null) {
|
||||
super.A_();
|
||||
} else {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.DEATH_SOUND_METADATA);
|
||||
@ -182,6 +173,16 @@ public class GuardianElderController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void n() {
|
||||
if (npc == null) {
|
||||
super.n();
|
||||
} else {
|
||||
NMSImpl.updateAI(this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
|
@ -187,9 +187,8 @@ public class HorseController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc == null) {
|
||||
super.M();
|
||||
} else {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||
npc.update();
|
||||
}
|
||||
|
@ -188,9 +188,8 @@ public class HorseDonkeyController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc == null) {
|
||||
super.M();
|
||||
} else {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||
npc.update();
|
||||
}
|
||||
|
@ -188,9 +188,8 @@ public class HorseMuleController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc == null) {
|
||||
super.M();
|
||||
} else {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||
npc.update();
|
||||
}
|
||||
|
@ -188,9 +188,8 @@ public class HorseSkeletonController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc == null) {
|
||||
super.M();
|
||||
} else {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||
npc.update();
|
||||
}
|
||||
|
@ -188,9 +188,8 @@ public class HorseZombieController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc == null) {
|
||||
super.M();
|
||||
} else {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||
npc.update();
|
||||
}
|
||||
|
@ -55,15 +55,6 @@ public class PolarBearController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
super.A_();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateAI(this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.DEATH_SOUND_METADATA);
|
||||
@ -159,6 +150,14 @@ public class PolarBearController extends MobEntityController {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PolarBearNPC extends CraftPolarBear implements NPCHolder {
|
||||
|
@ -142,10 +142,8 @@ public class VexController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc == null) {
|
||||
super.M();
|
||||
} else {
|
||||
NMSImpl.updateAI(this);
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@ -334,6 +335,15 @@ public class NMSImpl implements NMSBridge {
|
||||
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f);
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
if (handle.locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return handle.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfileRepository getGameProfileRepository() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer().getGameProfileRepository();
|
||||
@ -620,7 +630,8 @@ public class NMSImpl implements NMSBridge {
|
||||
@Override
|
||||
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly) {
|
||||
Entity handle = NMSImpl.getHandle(entity);
|
||||
if (headOnly || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
|
||||
if (headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())
|
||||
|| (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
|
||||
Location fromLocation = entity.getLocation(FROM_LOCATION);
|
||||
double xDiff, yDiff, zDiff;
|
||||
xDiff = to.getX() - fromLocation.getX();
|
||||
@ -634,22 +645,27 @@ public class NMSImpl implements NMSBridge {
|
||||
double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
|
||||
if (zDiff < 0.0)
|
||||
yaw += Math.abs(180 - yaw) * 2;
|
||||
|
||||
if (headOnly) {
|
||||
setHeadYaw(entity, (float) yaw - 90);
|
||||
if (handle instanceof EntityEnderDragon) {
|
||||
yaw = getDragonYaw(handle, to.getX(), to.getZ());
|
||||
} else {
|
||||
look(entity, (float) yaw - 90, (float) pitch);
|
||||
yaw = yaw - 90;
|
||||
}
|
||||
if (headOnly) {
|
||||
setHeadYaw(entity, (float) yaw);
|
||||
} else {
|
||||
look(entity, (float) yaw, (float) pitch);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (handle instanceof EntityInsentient) {
|
||||
((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), to.getYaw(),
|
||||
to.getPitch());
|
||||
|
||||
while (((EntityInsentient) handle).aP >= 180F) {
|
||||
((EntityInsentient) handle).aP -= 360F;
|
||||
while (((EntityLiving) handle).aP >= 180F) {
|
||||
((EntityLiving) handle).aP -= 360F;
|
||||
}
|
||||
while (((EntityInsentient) handle).aP < -180F) {
|
||||
((EntityInsentient) handle).aP += 360F;
|
||||
while (((EntityLiving) handle).aP < -180F) {
|
||||
((EntityLiving) handle).aP += 360F;
|
||||
}
|
||||
} else if (handle instanceof EntityHumanNPC) {
|
||||
((EntityHumanNPC) handle).setTargetLook(to);
|
||||
@ -659,8 +675,21 @@ 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);
|
||||
if (handle instanceof EntityInsentient) {
|
||||
((EntityInsentient) handle).getControllerLook().a(target, 10.0F, ((EntityInsentient) handle).N());
|
||||
if (handle instanceof EntityEnderDragon || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) {
|
||||
if (to instanceof LivingEntity) {
|
||||
look(from, ((LivingEntity) to).getEyeLocation(), false);
|
||||
} else {
|
||||
look(from, to.getLocation(), false);
|
||||
}
|
||||
} else if (handle instanceof EntityInsentient) {
|
||||
((EntityInsentient) handle).getControllerLook().a(target, ((EntityInsentient) handle).cL(),
|
||||
((EntityInsentient) handle).N());
|
||||
while (((EntityLiving) handle).aP >= 180F) {
|
||||
((EntityLiving) handle).aP -= 360F;
|
||||
}
|
||||
while (((EntityLiving) handle).aP < -180F) {
|
||||
((EntityLiving) handle).aP += 360F;
|
||||
}
|
||||
} else if (handle instanceof EntityHumanNPC) {
|
||||
((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F);
|
||||
}
|
||||
@ -1396,8 +1425,10 @@ public class NMSImpl implements NMSBridge {
|
||||
navigation.l();
|
||||
}
|
||||
|
||||
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.SILVERFISH, EntityType.ENDERMITE,
|
||||
EntityType.ENDER_DRAGON, EntityType.BAT);
|
||||
|
||||
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
||||
private static final float DEFAULT_SPEED = 1F;
|
||||
private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");
|
||||
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bJ");
|
||||
|
Loading…
Reference in New Issue
Block a user