Improved auto-show handling and fix for #59

This commit is contained in:
Jitse Boonstra 2020-04-11 19:57:12 +02:00
parent c7a404b589
commit e47dbc51d0
2 changed files with 21 additions and 4 deletions

View File

@ -108,9 +108,23 @@ public class Hologram {
worldClass = worldClass.getSuperclass();
}
Reflection.ConstructorInvoker entityArmorStandConstructor = (version.isAboveOrEqual(MinecraftVersion.V1_14_R1) ?
Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass, double.class, double.class, double.class) :
Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass));
// Reflection.ConstructorInvoker entityArmorStandConstructor = (version.isAboveOrEqual(MinecraftVersion.V1_14_R1) ?
// Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass, double.class, double.class, double.class) :
// Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass));
// Replacement for issue #59
Reflection.ConstructorInvoker entityArmorStandConstructor = null;
try {
entityArmorStandConstructor = (version.isAboveOrEqual(MinecraftVersion.V1_14_R1) ?
Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass, double.class, double.class, double.class) :
Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass));
} catch (IllegalStateException exception) {
worldClass = worldClass.getSuperclass();
entityArmorStandConstructor = (version.isAboveOrEqual(MinecraftVersion.V1_14_R1) ?
Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass, double.class, double.class, double.class) :
Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass));
}
// end #59
for (String line : text) {
Object entityArmorStand = (version.isAboveOrEqual(MinecraftVersion.V1_14_R1) ?

View File

@ -62,7 +62,10 @@ public class PlayerListener implements Listener {
public void onPlayerMove(PlayerMoveEvent event) {
Location from = event.getFrom();
Location to = event.getTo();
if (to == null || (from.getBlockX() != to.getBlockX()
// 11/4/20: Added pitch and yaw to the if statement. If the change in this is 10 or more degrees, check the movement.
if (to == null || (Math.abs(from.getPitch() - to.getPitch()) <= 10
|| Math.abs(from.getYaw() - to.getYaw()) <= 10
|| from.getBlockX() != to.getBlockX()
|| from.getBlockY() != to.getBlockY()
|| from.getBlockZ() != to.getBlockZ()))
handleMove(event.getPlayer()); // Verify the player changed which block they are on. Since PlayerMoveEvent is one of the most called events, this is worth it.