mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 20:25:19 +01:00
Upgrade to MethodHandles
This commit is contained in:
parent
ae96a02e49
commit
0ec8ea68e8
@ -79,7 +79,7 @@ public class ProfileFetcher {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
request.setResult(NMS.fillProfileProperties(profile, true), ProfileFetchResult.SUCCESS);
|
request.setResult(NMS.fillProfileProperties(profile, true), ProfileFetchResult.SUCCESS);
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
if (Messaging.isDebugging()) {
|
if (Messaging.isDebugging()) {
|
||||||
Messaging.debug("Profile lookup for player '" + profile.getName() + "' failed: "
|
Messaging.debug("Profile lookup for player '" + profile.getName() + "' failed: "
|
||||||
+ getExceptionMsg(e) + " " + isTooManyRequests(e));
|
+ getExceptionMsg(e) + " " + isTooManyRequests(e));
|
||||||
@ -134,7 +134,7 @@ public class ProfileFetcher {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getExceptionMsg(Exception e) {
|
private static String getExceptionMsg(Throwable e) {
|
||||||
return Throwables.getRootCause(e).getMessage();
|
return Throwables.getRootCause(e).getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,8 +155,7 @@ public class ProfileFetcher {
|
|||||||
|| (cause != null && cause.contains("did not find"));
|
|| (cause != null && cause.contains("did not find"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isTooManyRequests(Exception e) {
|
private static boolean isTooManyRequests(Throwable e) {
|
||||||
|
|
||||||
String message = e.getMessage();
|
String message = e.getMessage();
|
||||||
String cause = e.getCause() != null ? e.getCause().getMessage() : null;
|
String cause = e.getCause() != null ? e.getCause().getMessage() : null;
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.citizensnpcs.util;
|
package net.citizensnpcs.util;
|
||||||
|
|
||||||
|
import java.lang.invoke.MethodHandle;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
@ -55,7 +57,7 @@ public class NMS {
|
|||||||
* Yggdrasil's default implementation of this method silently fails instead of throwing
|
* Yggdrasil's default implementation of this method silently fails instead of throwing
|
||||||
* an Exception like it should.
|
* an Exception like it should.
|
||||||
*/
|
*/
|
||||||
public static GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
|
public static GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
|
||||||
return BRIDGE.fillProfileProperties(profile, requireSecure);
|
return BRIDGE.fillProfileProperties(profile, requireSecure);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,10 +108,44 @@ public class NMS {
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MethodHandle getFinalSetter(Class<?> clazz, String field) {
|
||||||
|
return getFinalSetter(clazz, field, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MethodHandle getFinalSetter(Class<?> clazz, String field, boolean log) {
|
||||||
|
Field f = getFinalField(clazz, field, log);
|
||||||
|
if (f == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return LOOKUP.unreflectSetter(f);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (log) {
|
||||||
|
Messaging.logTr(Messages.ERROR_GETTING_FIELD, field, e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static GameProfileRepository getGameProfileRepository() {
|
public static GameProfileRepository getGameProfileRepository() {
|
||||||
return BRIDGE.getGameProfileRepository();
|
return BRIDGE.getGameProfileRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MethodHandle getGetter(Class<?> clazz, String name) {
|
||||||
|
return getGetter(clazz, name, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MethodHandle getGetter(Class<?> clazz, String name, boolean log) {
|
||||||
|
try {
|
||||||
|
return LOOKUP.unreflectGetter(getField(clazz, name, log));
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (log) {
|
||||||
|
Messaging.logTr(Messages.ERROR_GETTING_FIELD, name, e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static float getHeadYaw(org.bukkit.entity.Entity entity) {
|
public static float getHeadYaw(org.bukkit.entity.Entity entity) {
|
||||||
return BRIDGE.getHeadYaw(entity);
|
return BRIDGE.getHeadYaw(entity);
|
||||||
}
|
}
|
||||||
@ -133,6 +169,19 @@ public class NMS {
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MethodHandle getMethodHandle(Class<?> clazz, String method, boolean log, Class<?>... params) {
|
||||||
|
if (clazz == null)
|
||||||
|
return null;
|
||||||
|
try {
|
||||||
|
return LOOKUP.unreflect(getMethod(clazz, method, log, params));
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (log) {
|
||||||
|
Messaging.logTr(Messages.ERROR_GETTING_METHOD, method, e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static NPC getNPC(Entity entity) {
|
public static NPC getNPC(Entity entity) {
|
||||||
return BRIDGE.getNPC(entity);
|
return BRIDGE.getNPC(entity);
|
||||||
}
|
}
|
||||||
@ -145,6 +194,21 @@ public class NMS {
|
|||||||
return BRIDGE.getProfile(meta);
|
return BRIDGE.getProfile(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MethodHandle getSetter(Class<?> clazz, String name) {
|
||||||
|
return getSetter(clazz, name, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MethodHandle getSetter(Class<?> clazz, String name, boolean log) {
|
||||||
|
try {
|
||||||
|
return LOOKUP.unreflectSetter(getField(clazz, name, log));
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (log) {
|
||||||
|
Messaging.logTr(Messages.ERROR_GETTING_FIELD, name, e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getSound(String flag) throws CommandException {
|
public static String getSound(String flag) throws CommandException {
|
||||||
return BRIDGE.getSound(flag);
|
return BRIDGE.getSound(flag);
|
||||||
}
|
}
|
||||||
@ -344,5 +408,7 @@ public class NMS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static NMSBridge BRIDGE;
|
private static NMSBridge BRIDGE;
|
||||||
|
|
||||||
|
private static MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
|
||||||
private static Field MODIFIERS_FIELD = NMS.getField(Field.class, "modifiers");
|
private static Field MODIFIERS_FIELD = NMS.getField(Field.class, "modifiers");
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public interface NMSBridge {
|
|||||||
|
|
||||||
public void attack(LivingEntity attacker, LivingEntity target);
|
public void attack(LivingEntity attacker, LivingEntity target);
|
||||||
|
|
||||||
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception;
|
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable;
|
||||||
|
|
||||||
public BlockBreaker getBlockBreaker(Entity entity, Block targetBlock, BlockBreakerConfiguration config);
|
public BlockBreaker getBlockBreaker(Entity entity, Block targetBlock, BlockBreakerConfiguration config);
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftChicken;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftChicken;
|
||||||
@ -15,7 +13,6 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.DamageSource;
|
import net.minecraft.server.v1_14_R1.DamageSource;
|
||||||
@ -223,17 +220,7 @@ public class ChickenController extends MobEntityController {
|
|||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
this.eggLayTime = 100; // egg timer
|
this.eggLayTime = 100; // egg timer
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
super.movementTick();
|
super.movementTick();
|
||||||
} catch (NoSuchMethodError ex) {
|
|
||||||
try {
|
|
||||||
MOVEMENT_TICK.invoke(this);
|
|
||||||
} catch (Throwable ex2) {
|
|
||||||
ex2.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Method MOVEMENT_TICK = NMS.getMethod(EntityChicken.class, "k", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||||
@ -15,7 +13,6 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.DamageSource;
|
import net.minecraft.server.v1_14_R1.DamageSource;
|
||||||
@ -185,15 +182,7 @@ public class GuardianController extends MobEntityController {
|
|||||||
@Override
|
@Override
|
||||||
public void movementTick() {
|
public void movementTick() {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
try {
|
|
||||||
super.movementTick();
|
super.movementTick();
|
||||||
} catch (NoSuchMethodError ex) {
|
|
||||||
try {
|
|
||||||
MOVEMENT_TICK.invoke(this);
|
|
||||||
} catch (Throwable ex2) {
|
|
||||||
ex2.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
NMSImpl.updateAI(this);
|
NMSImpl.updateAI(this);
|
||||||
npc.update();
|
npc.update();
|
||||||
@ -208,8 +197,6 @@ public class GuardianController extends MobEntityController {
|
|||||||
NMSImpl.setSize(this, justCreated);
|
NMSImpl.setSize(this, justCreated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Method MOVEMENT_TICK = NMS.getMethod(EntityGuardian.class, "k", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GuardianNPC extends CraftGuardian implements NPCHolder {
|
public static class GuardianNPC extends CraftGuardian implements NPCHolder {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftElderGuardian;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftElderGuardian;
|
||||||
@ -15,7 +13,6 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.DamageSource;
|
import net.minecraft.server.v1_14_R1.DamageSource;
|
||||||
@ -185,15 +182,7 @@ public class GuardianElderController extends MobEntityController {
|
|||||||
@Override
|
@Override
|
||||||
public void movementTick() {
|
public void movementTick() {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
try {
|
|
||||||
super.movementTick();
|
super.movementTick();
|
||||||
} catch (NoSuchMethodError ex) {
|
|
||||||
try {
|
|
||||||
MOVEMENT_TICK.invoke(this);
|
|
||||||
} catch (Throwable ex2) {
|
|
||||||
ex2.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
NMSImpl.updateAI(this);
|
NMSImpl.updateAI(this);
|
||||||
npc.update();
|
npc.update();
|
||||||
@ -208,8 +197,6 @@ public class GuardianElderController extends MobEntityController {
|
|||||||
NMSImpl.setSize(this, justCreated);
|
NMSImpl.setSize(this, justCreated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Method MOVEMENT_TICK = NMS.getMethod(EntityGuardianElder.class, "k", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GuardianElderNPC extends CraftElderGuardian implements NPCHolder {
|
public static class GuardianElderNPC extends CraftElderGuardian implements NPCHolder {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||||
@ -15,7 +13,6 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.ControllerLook;
|
import net.minecraft.server.v1_14_R1.ControllerLook;
|
||||||
@ -196,15 +193,7 @@ public class PhantomController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void movementTick() {
|
public void movementTick() {
|
||||||
try {
|
|
||||||
super.movementTick();
|
super.movementTick();
|
||||||
} catch (NoSuchMethodError ex) {
|
|
||||||
try {
|
|
||||||
MOVEMENT_TICK.invoke(this);
|
|
||||||
} catch (Throwable ex2) {
|
|
||||||
ex2.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.isProtected()) {
|
if (npc.isProtected()) {
|
||||||
this.setOnFire(0);
|
this.setOnFire(0);
|
||||||
@ -225,8 +214,6 @@ public class PhantomController extends MobEntityController {
|
|||||||
this.world.getWorldData().setDifficulty(EnumDifficulty.PEACEFUL);
|
this.world.getWorldData().setDifficulty(EnumDifficulty.PEACEFUL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Method MOVEMENT_TICK = NMS.getMethod(EntityPhantom.class, "k", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PhantomNPC extends CraftPhantom implements NPCHolder {
|
public static class PhantomNPC extends CraftPhantom implements NPCHolder {
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||||
|
|
||||||
import net.minecraft.server.v1_14_R1.Vec3D;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||||
@ -17,7 +13,6 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.DamageSource;
|
import net.minecraft.server.v1_14_R1.DamageSource;
|
||||||
@ -27,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.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||||
|
import net.minecraft.server.v1_14_R1.Vec3D;
|
||||||
import net.minecraft.server.v1_14_R1.World;
|
import net.minecraft.server.v1_14_R1.World;
|
||||||
|
|
||||||
public class ShulkerController extends MobEntityController {
|
public class ShulkerController extends MobEntityController {
|
||||||
@ -61,15 +57,6 @@ public class ShulkerController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void e(Vec3D vec3d) {
|
|
||||||
if (npc == null || !npc.isFlyable()) {
|
|
||||||
super.e(vec3d);
|
|
||||||
} else {
|
|
||||||
NMSImpl.flyingMoveLogic(this, vec3d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(float f, float f1) {
|
public void b(float f, float f1) {
|
||||||
if (npc == null || !npc.isFlyable()) {
|
if (npc == null || !npc.isFlyable()) {
|
||||||
@ -98,6 +85,15 @@ public class ShulkerController extends MobEntityController {
|
|||||||
return npc == null ? super.d(save) : false;
|
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
|
@Override
|
||||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
@ -160,6 +156,15 @@ public class ShulkerController extends MobEntityController {
|
|||||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
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
|
@Override
|
||||||
public boolean isLeashed() {
|
public boolean isLeashed() {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
@ -176,15 +181,7 @@ public class ShulkerController extends MobEntityController {
|
|||||||
@Override
|
@Override
|
||||||
public void movementTick() {
|
public void movementTick() {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
try {
|
|
||||||
super.movementTick();
|
super.movementTick();
|
||||||
} catch (NoSuchMethodError ex) {
|
|
||||||
try {
|
|
||||||
MOVEMENT_TICK.invoke(this);
|
|
||||||
} catch (Throwable ex2) {
|
|
||||||
ex2.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,15 +190,6 @@ public class ShulkerController extends MobEntityController {
|
|||||||
return new EntityAIBodyControl(this);
|
return new EntityAIBodyControl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSize() {
|
|
||||||
if (npc == null) {
|
|
||||||
super.updateSize();
|
|
||||||
} else {
|
|
||||||
NMSImpl.setSize(this, justCreated);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
@ -212,15 +200,13 @@ public class ShulkerController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isClimbing() {
|
public void updateSize() {
|
||||||
if (npc == null || !npc.isFlyable()) {
|
if (npc == null) {
|
||||||
return super.isClimbing();
|
super.updateSize();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
NMSImpl.setSize(this, justCreated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Method MOVEMENT_TICK = NMS.getMethod(EntityShulker.class, "k", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ShulkerNPC extends CraftShulker implements NPCHolder {
|
public static class ShulkerNPC extends CraftShulker implements NPCHolder {
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||||
|
|
||||||
import net.minecraft.server.v1_14_R1.Vec3D;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||||
@ -17,7 +13,6 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.DamageSource;
|
import net.minecraft.server.v1_14_R1.DamageSource;
|
||||||
@ -26,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.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||||
|
import net.minecraft.server.v1_14_R1.Vec3D;
|
||||||
import net.minecraft.server.v1_14_R1.World;
|
import net.minecraft.server.v1_14_R1.World;
|
||||||
|
|
||||||
public class SnowmanController extends MobEntityController {
|
public class SnowmanController extends MobEntityController {
|
||||||
@ -60,15 +56,6 @@ public class SnowmanController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void e(Vec3D vec3d) {
|
|
||||||
if (npc == null || !npc.isFlyable()) {
|
|
||||||
super.e(vec3d);
|
|
||||||
} else {
|
|
||||||
NMSImpl.flyingMoveLogic(this, vec3d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(float f, float f1) {
|
public void b(float f, float f1) {
|
||||||
if (npc == null || !npc.isFlyable()) {
|
if (npc == null || !npc.isFlyable()) {
|
||||||
@ -97,6 +84,15 @@ public class SnowmanController extends MobEntityController {
|
|||||||
return npc == null ? super.d(save) : false;
|
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
|
@Override
|
||||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
@ -159,6 +155,15 @@ public class SnowmanController extends MobEntityController {
|
|||||||
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
|
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
|
@Override
|
||||||
public boolean isLeashed() {
|
public boolean isLeashed() {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
@ -186,15 +191,7 @@ public class SnowmanController extends MobEntityController {
|
|||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
this.world.getGameRules().set("mobGriefing", "false", this.world.getMinecraftServer());
|
this.world.getGameRules().set("mobGriefing", "false", this.world.getMinecraftServer());
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
super.movementTick();
|
super.movementTick();
|
||||||
} catch (NoSuchMethodError ex) {
|
|
||||||
try {
|
|
||||||
MOVEMENT_TICK.invoke(this);
|
|
||||||
} catch (Throwable ex2) {
|
|
||||||
ex2.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
this.world.getGameRules().set("mobGriefing", Boolean.toString(allowsGriefing),
|
this.world.getGameRules().set("mobGriefing", Boolean.toString(allowsGriefing),
|
||||||
this.world.getMinecraftServer());
|
this.world.getMinecraftServer());
|
||||||
@ -209,17 +206,6 @@ public class SnowmanController extends MobEntityController {
|
|||||||
NMSImpl.setSize(this, justCreated);
|
NMSImpl.setSize(this, justCreated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isClimbing() {
|
|
||||||
if (npc == null || !npc.isFlyable()) {
|
|
||||||
return super.isClimbing();
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Method MOVEMENT_TICK = NMS.getMethod(EntitySnowman.class, "k", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SnowmanNPC extends CraftSnowman implements NPCHolder {
|
public static class SnowmanNPC extends CraftSnowman implements NPCHolder {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.util;
|
package net.citizensnpcs.nms.v1_14_R1.util;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
@ -57,17 +57,15 @@ public class EmptyAdvancementDataPlayer extends AdvancementDataPlayer {
|
|||||||
data.a();
|
data.a();
|
||||||
data.data.clear();
|
data.data.clear();
|
||||||
try {
|
try {
|
||||||
((Set<?>) G.get(data)).clear();
|
((Set<?>) G.invoke(data)).clear();
|
||||||
((Set<?>) H.get(data)).clear();
|
((Set<?>) H.invoke(data)).clear();
|
||||||
((Set<?>) I.get(data)).clear();
|
((Set<?>) I.invoke(data)).clear();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Field G = NMS.getField(AdvancementDataPlayer.class, "g");
|
private static final MethodHandle G = NMS.getGetter(AdvancementDataPlayer.class, "g");
|
||||||
private static final Field H = NMS.getField(AdvancementDataPlayer.class, "h");
|
private static final MethodHandle H = NMS.getGetter(AdvancementDataPlayer.class, "h");
|
||||||
private static final Field I = NMS.getField(AdvancementDataPlayer.class, "i");
|
private static final MethodHandle I = NMS.getGetter(AdvancementDataPlayer.class, "i");
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.util;
|
package net.citizensnpcs.nms.v1_14_R1.util;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import net.citizensnpcs.util.BoundingBox;
|
import net.citizensnpcs.util.BoundingBox;
|
||||||
import net.citizensnpcs.util.NMS;
|
|
||||||
import net.minecraft.server.v1_14_R1.AxisAlignedBB;
|
import net.minecraft.server.v1_14_R1.AxisAlignedBB;
|
||||||
|
|
||||||
public class NMSBoundingBox {
|
public class NMSBoundingBox {
|
||||||
@ -12,32 +9,12 @@ public class NMSBoundingBox {
|
|||||||
|
|
||||||
public static BoundingBox wrap(AxisAlignedBB bb) {
|
public static BoundingBox wrap(AxisAlignedBB bb) {
|
||||||
double minX = 0, minY = 0, minZ = 0, maxX = 0, maxY = 0, maxZ = 0;
|
double minX = 0, minY = 0, minZ = 0, maxX = 0, maxY = 0, maxZ = 0;
|
||||||
try {
|
|
||||||
minX = bb.minX;
|
minX = bb.minX;
|
||||||
minY = bb.minY;
|
minY = bb.minY;
|
||||||
minZ = bb.minZ;
|
minZ = bb.minZ;
|
||||||
maxX = bb.maxX;
|
maxX = bb.maxX;
|
||||||
maxY = bb.maxY;
|
maxY = bb.maxY;
|
||||||
maxZ = bb.maxZ;
|
maxZ = bb.maxZ;
|
||||||
} catch (NoSuchFieldError ex) {
|
|
||||||
try {
|
|
||||||
minX = a.getDouble(bb);
|
|
||||||
minY = b.getDouble(bb);
|
|
||||||
minZ = c.getDouble(bb);
|
|
||||||
maxX = d.getDouble(bb);
|
|
||||||
maxY = e.getDouble(bb);
|
|
||||||
maxZ = f.getDouble(bb);
|
|
||||||
} catch (Exception ex2) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
return new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Field a = NMS.getFinalField(AxisAlignedBB.class, "a", false);
|
|
||||||
private static final Field b = NMS.getFinalField(AxisAlignedBB.class, "b", false);
|
|
||||||
private static final Field c = NMS.getFinalField(AxisAlignedBB.class, "c", false);
|
|
||||||
private static final Field d = NMS.getFinalField(AxisAlignedBB.class, "d", false);
|
|
||||||
private static final Field e = NMS.getFinalField(AxisAlignedBB.class, "e", false);
|
|
||||||
private static final Field f = NMS.getFinalField(AxisAlignedBB.class, "f", false);
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.util;
|
package net.citizensnpcs.nms.v1_14_R1.util;
|
||||||
|
|
||||||
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -248,7 +247,6 @@ import net.minecraft.server.v1_14_R1.PlayerChunkMap.EntityTracker;
|
|||||||
import net.minecraft.server.v1_14_R1.RegistryBlocks;
|
import net.minecraft.server.v1_14_R1.RegistryBlocks;
|
||||||
import net.minecraft.server.v1_14_R1.ReportedException;
|
import net.minecraft.server.v1_14_R1.ReportedException;
|
||||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||||
import net.minecraft.server.v1_14_R1.SoundEffects;
|
|
||||||
import net.minecraft.server.v1_14_R1.Vec3D;
|
import net.minecraft.server.v1_14_R1.Vec3D;
|
||||||
import net.minecraft.server.v1_14_R1.WorldServer;
|
import net.minecraft.server.v1_14_R1.WorldServer;
|
||||||
|
|
||||||
@ -315,7 +313,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Exception {
|
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
|
||||||
if (Bukkit.isPrimaryThread())
|
if (Bukkit.isPrimaryThread())
|
||||||
throw new IllegalStateException("NMS.fillProfileProperties cannot be invoked from the main thread.");
|
throw new IllegalStateException("NMS.fillProfileProperties cannot be invoked from the main thread.");
|
||||||
|
|
||||||
@ -407,10 +405,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
@Override
|
@Override
|
||||||
public GameProfile getProfile(SkullMeta meta) {
|
public GameProfile getProfile(SkullMeta meta) {
|
||||||
if (SKULL_PROFILE_FIELD == null) {
|
if (SKULL_PROFILE_FIELD == null) {
|
||||||
try {
|
SKULL_PROFILE_FIELD = NMS.getField(meta.getClass(), "profile", false);
|
||||||
SKULL_PROFILE_FIELD = meta.getClass().getDeclaredField("profile");
|
if (SKULL_PROFILE_FIELD == null) {
|
||||||
SKULL_PROFILE_FIELD.setAccessible(true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -526,20 +522,21 @@ public class NMSImpl implements NMSBridge {
|
|||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
EntitySize size = null;
|
EntitySize size = null;
|
||||||
try {
|
try {
|
||||||
size = (EntitySize) SIZE_FIELD.get(handle);
|
size = (EntitySize) SIZE_FIELD_GETTER.invoke(handle);
|
||||||
|
|
||||||
if (handle instanceof EntityHorse) {
|
if (handle instanceof EntityHorse) {
|
||||||
SIZE_FIELD.set(handle, new EntitySize(Math.min(0.99F, size.width), size.height, false));
|
SIZE_FIELD_SETTER.invoke(handle,
|
||||||
|
new EntitySize(Math.min(0.99F, size.width), size.height, false));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (!function.apply(navigation)) {
|
if (!function.apply(navigation)) {
|
||||||
reason = CancelReason.STUCK;
|
reason = CancelReason.STUCK;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
SIZE_FIELD.set(handle, size);
|
SIZE_FIELD_SETTER.invoke(handle, size);
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
// minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
|
// minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
|
||||||
// make it just fit on 1 so hack around it a bit.
|
// make it just fit on 1 so hack around it a bit.
|
||||||
@ -976,10 +973,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
@Override
|
@Override
|
||||||
public void setProfile(SkullMeta meta, GameProfile profile) {
|
public void setProfile(SkullMeta meta, GameProfile profile) {
|
||||||
if (SKULL_PROFILE_FIELD == null) {
|
if (SKULL_PROFILE_FIELD == null) {
|
||||||
try {
|
SKULL_PROFILE_FIELD = NMS.getField(meta.getClass(), "profile", false);
|
||||||
SKULL_PROFILE_FIELD = meta.getClass().getDeclaredField("profile");
|
if (SKULL_PROFILE_FIELD == null) {
|
||||||
SKULL_PROFILE_FIELD.setAccessible(true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1036,10 +1031,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (JUMP_FIELD == null || !(entity instanceof LivingEntity))
|
if (JUMP_FIELD == null || !(entity instanceof LivingEntity))
|
||||||
return false;
|
return false;
|
||||||
try {
|
try {
|
||||||
return JUMP_FIELD.getBoolean(NMSImpl.getHandle(entity));
|
return (boolean) JUMP_FIELD.invoke(NMSImpl.getHandle(entity));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1049,13 +1042,10 @@ public class NMSImpl implements NMSBridge {
|
|||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
if (ENTITY_REGISTRY == null)
|
if (ENTITY_REGISTRY == null)
|
||||||
return;
|
return;
|
||||||
Field field = NMS.getFinalField(EntityTypes.class, "REGISTRY", false);
|
MethodHandle field = NMS.getFinalSetter(IRegistry.class, "ENTITY_TYPE");
|
||||||
if (field == null) {
|
|
||||||
field = NMS.getFinalField(IRegistry.class, "ENTITY_TYPE");
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
field.set(null, ENTITY_REGISTRY.getWrapped());
|
field.invoke(null, ENTITY_REGISTRY.getWrapped());
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,9 +1112,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
EntityInsentient handle = (EntityInsentient) en;
|
EntityInsentient handle = (EntityInsentient) en;
|
||||||
WorldServer worldHandle = ((CraftWorld) world).getHandle();
|
WorldServer worldHandle = ((CraftWorld) world).getHandle();
|
||||||
try {
|
try {
|
||||||
NAVIGATION_WORLD_FIELD.set(handle.getNavigation(), worldHandle);
|
NAVIGATION_WORLD_FIELD.invoke(handle.getNavigation(), worldHandle);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Messaging.logTr(Messages.ERROR_UPDATING_NAVIGATION_WORLD, e.getMessage());
|
Messaging.logTr(Messages.ERROR_UPDATING_NAVIGATION_WORLD, e.getMessage());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1144,11 +1136,9 @@ public class NMSImpl implements NMSBridge {
|
|||||||
EntityInsentient handle = (EntityInsentient) en;
|
EntityInsentient handle = (EntityInsentient) en;
|
||||||
NavigationAbstract navigation = handle.getNavigation();
|
NavigationAbstract navigation = handle.getNavigation();
|
||||||
try {
|
try {
|
||||||
AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
|
AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.invoke(navigation);
|
||||||
inst.setValue(pathfindingRange);
|
inst.setValue(pathfindingRange);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1227,8 +1217,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
public static void checkAndUpdateHeight(EntityLiving living, DataWatcherObject<?> datawatcherobject) {
|
public static void checkAndUpdateHeight(EntityLiving living, DataWatcherObject<?> datawatcherobject) {
|
||||||
EntitySize size;
|
EntitySize size;
|
||||||
try {
|
try {
|
||||||
size = (EntitySize) SIZE_FIELD.get(living);
|
size = (EntitySize) SIZE_FIELD_GETTER.invoke(living);
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
living.a(datawatcherobject);
|
living.a(datawatcherobject);
|
||||||
return;
|
return;
|
||||||
@ -1247,10 +1237,12 @@ public class NMSImpl implements NMSBridge {
|
|||||||
return;
|
return;
|
||||||
for (PathfinderGoalSelector selector : goalSelectors) {
|
for (PathfinderGoalSelector selector : goalSelectors) {
|
||||||
try {
|
try {
|
||||||
Collection<?> list = (Collection<?>) GOAL_FIELD.get(selector);
|
Collection<?> list = (Collection<?>) GOAL_FIELD.invoke(selector);
|
||||||
list.clear();
|
list.clear();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
|
Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Messaging.logTr(Messages.ERROR_CLEARING_GOALS, e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1324,10 +1316,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
double d6 = d4 - d5;
|
double d6 = d4 - d5;
|
||||||
float f4 = (float) (d6 * 10.0D - 3.0D);
|
float f4 = (float) (d6 * 10.0D - 3.0D);
|
||||||
if (f4 > 0.0F) {
|
if (f4 > 0.0F) {
|
||||||
|
try {
|
||||||
entity.a(/* TODO ?implement properly entity.getSoundFall((int) f4)*/f4 > 4
|
entity.a((SoundEffect) ENTITY_GET_SOUND_FALL.invoke(entity, (int) f4), 1.0F, 1.0F);
|
||||||
? SoundEffects.ENTITY_GENERIC_BIG_FALL
|
} catch (Throwable e) {
|
||||||
: SoundEffects.ENTITY_GENERIC_SMALL_FALL, 1.0F, 1.0F);
|
e.printStackTrace();
|
||||||
|
}
|
||||||
entity.damageEntity(DamageSource.FLY_INTO_WALL, f4);
|
entity.damageEntity(DamageSource.FLY_INTO_WALL, f4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1341,21 +1334,19 @@ public class NMSImpl implements NMSBridge {
|
|||||||
entity.locZ);
|
entity.locZ);
|
||||||
float f5 = entity.world.getType(blockposition).getBlock().m();
|
float f5 = entity.world.getType(blockposition).getBlock().m();
|
||||||
f1 = entity.onGround ? f5 * 0.91F : 0.91F;
|
f1 = entity.onGround ? f5 * 0.91F : 0.91F;
|
||||||
entity.a(/* TODO ?implement properly entity.r(f5)*/ entity.onGround
|
|
||||||
? entity.da() * (0.21600002F / (f5 * f5 * f5))
|
|
||||||
: entity.aO, vec3d);
|
|
||||||
try {
|
try {
|
||||||
|
entity.a((float) ENTITY_R.invoke(entity, f5), vec3d);
|
||||||
entity.setMot((Vec3D) ISCLIMBING_METHOD.invoke(entity, entity.getMot()));
|
entity.setMot((Vec3D) ISCLIMBING_METHOD.invoke(entity, entity.getMot()));
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
entity.move(EnumMoveType.SELF, entity.getMot());
|
entity.move(EnumMoveType.SELF, entity.getMot());
|
||||||
vec3d2 = entity.getMot();
|
vec3d2 = entity.getMot();
|
||||||
try {
|
try {
|
||||||
if ((entity.positionChanged || JUMP_FIELD.getBoolean(entity)) && entity.isClimbing()) {
|
if ((entity.positionChanged || (boolean) JUMP_FIELD.invoke(entity)) && entity.isClimbing()) {
|
||||||
vec3d2 = new Vec3D(vec3d2.x, 0.2D, vec3d2.z);
|
vec3d2 = new Vec3D(vec3d2.x, 0.2D, vec3d2.z);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1457,17 +1448,19 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (entity.getType() == EntityType.WITHER) {
|
if (entity.getType() == EntityType.WITHER) {
|
||||||
bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
|
bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
|
||||||
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
|
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
|
||||||
bserver = ((EnderDragonBattle) ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity))).bossBattle;
|
bserver = ((EnderDragonBattle) ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity))).bossBattle;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (bserver == null) {
|
if (bserver == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
|
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
|
||||||
try {
|
try {
|
||||||
CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
|
CRAFT_BOSSBAR_HANDLE_FIELD.invoke(ret, bserver);
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1500,10 +1493,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (RABBIT_FIELD == null)
|
if (RABBIT_FIELD == null)
|
||||||
return null;
|
return null;
|
||||||
try {
|
try {
|
||||||
return (DataWatcherObject<Integer>) RABBIT_FIELD.get(null);
|
return (DataWatcherObject<Integer>) RABBIT_FIELD.invoke(null);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -1579,10 +1570,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
public static void setAdvancement(Player entity, AdvancementDataPlayer instance) {
|
public static void setAdvancement(Player entity, AdvancementDataPlayer instance) {
|
||||||
try {
|
try {
|
||||||
ADVANCEMENT_PLAYER_FIELD.set(getHandle(entity), instance);
|
ADVANCEMENT_PLAYER_FIELD.invoke(getHandle(entity), instance);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1590,9 +1579,9 @@ public class NMSImpl implements NMSBridge {
|
|||||||
public static void setNotInSchool(EntityFish entity) {
|
public static void setNotInSchool(EntityFish entity) {
|
||||||
try {
|
try {
|
||||||
if (ENTITY_FISH_NUM_IN_SCHOOL != null) {
|
if (ENTITY_FISH_NUM_IN_SCHOOL != null) {
|
||||||
ENTITY_FISH_NUM_IN_SCHOOL.set(entity, 2);
|
ENTITY_FISH_NUM_IN_SCHOOL.invoke(entity, 2);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Throwable ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1603,12 +1592,12 @@ public class NMSImpl implements NMSBridge {
|
|||||||
|
|
||||||
public static void setSize(Entity entity, boolean justCreated) {
|
public static void setSize(Entity entity, boolean justCreated) {
|
||||||
try {
|
try {
|
||||||
EntitySize entitysize = (EntitySize) SIZE_FIELD.get(entity);
|
EntitySize entitysize = (EntitySize) SIZE_FIELD_GETTER.invoke(entity);
|
||||||
EntityPose entitypose = entity.Z();
|
EntityPose entitypose = entity.Z();
|
||||||
EntitySize entitysize1 = entity.a(entitypose);
|
EntitySize entitysize1 = entity.a(entitypose);
|
||||||
SIZE_FIELD.set(entity, entitysize1);
|
SIZE_FIELD_SETTER.invoke(entity, entitysize1);
|
||||||
HEAD_HEIGHT.set(entity, HEAD_HEIGHT_METHOD.invoke(entity, entitypose, entitysize1));
|
HEAD_HEIGHT.invoke(entity, HEAD_HEIGHT_METHOD.invoke(entity, entitypose, entitysize1));
|
||||||
if (entitysize1.width < entitysize.width && false /* CITIZENS ADDITION ?reason */) {
|
if (entitysize1.width < entitysize.width && false /* TODO: PREVIOUS CITIZENS ADDITION ?reason */) {
|
||||||
double d0 = entitysize1.width / 2.0D;
|
double d0 = entitysize1.width / 2.0D;
|
||||||
entity.a(new AxisAlignedBB(entity.locX - d0, entity.locY, entity.locZ - d0, entity.locX + d0,
|
entity.a(new AxisAlignedBB(entity.locX - d0, entity.locY, entity.locZ - d0, entity.locX + d0,
|
||||||
entity.locY + entitysize1.height, entity.locZ + d0));
|
entity.locY + entitysize1.height, entity.locZ + d0));
|
||||||
@ -1622,11 +1611,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
entity.move(EnumMoveType.SELF, new Vec3D(f, 0.0D, f));
|
entity.move(EnumMoveType.SELF, new Vec3D(f, 0.0D, f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1652,35 +1637,41 @@ public class NMSImpl implements NMSBridge {
|
|||||||
navigation.c();
|
navigation.c();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Field ADVANCEMENT_PLAYER_FIELD = NMS.getFinalField(EntityPlayer.class, "advancementDataPlayer");
|
private static final MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class,
|
||||||
|
"advancementDataPlayer");
|
||||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
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.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
|
||||||
EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST);
|
EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST);
|
||||||
private static final Method BLOCK_POSITION_B_D = NMS.getMethod(BlockPosition.PooledBlockPosition.class, "c", false,
|
private static final MethodHandle BLOCK_POSITION_B_D = NMS.getMethodHandle(BlockPosition.PooledBlockPosition.class,
|
||||||
double.class, double.class, double.class);
|
"c", false, double.class, double.class, double.class);
|
||||||
private static Map<Class<?>, EntityTypes<?>> CITIZENS_ENTITY_TYPES = Maps.newHashMap();
|
private static final Map<Class<?>, EntityTypes<?>> CITIZENS_ENTITY_TYPES = Maps.newHashMap();
|
||||||
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
private static final MethodHandle CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getSetter(CraftBossBar.class, "handle");
|
||||||
private static final float DEFAULT_SPEED = 1F;
|
private static final float DEFAULT_SPEED = 1F;
|
||||||
private static final Field ENDERDRAGON_BATTLE_FIELD = NMS.getField(EntityEnderDragon.class, "bP");
|
private static final MethodHandle ENDERDRAGON_BATTLE_FIELD = NMS.getGetter(EntityEnderDragon.class, "bP");
|
||||||
private static Field ENTITY_FISH_NUM_IN_SCHOOL = NMS.getField(EntityFishSchool.class, "c", false);
|
private static final MethodHandle ENTITY_FISH_NUM_IN_SCHOOL = NMS.getSetter(EntityFishSchool.class, "c", false);
|
||||||
|
private static final MethodHandle ENTITY_GET_SOUND_FALL = NMS.getMethodHandle(EntityLiving.class, "getSoundFall",
|
||||||
|
true, int.class);
|
||||||
|
private static final MethodHandle ENTITY_R = NMS.getMethodHandle(EntityLiving.class, "r", true, float.class);
|
||||||
private static CustomEntityRegistry ENTITY_REGISTRY;
|
private static CustomEntityRegistry ENTITY_REGISTRY;
|
||||||
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
private static final Location FROM_LOCATION = new Location(null, 0, 0, 0);
|
||||||
public static Field GOAL_FIELD = NMS.getField(PathfinderGoalSelector.class, "d");
|
private static final MethodHandle GOAL_FIELD = NMS.getGetter(PathfinderGoalSelector.class, "d");
|
||||||
private static final Field HEAD_HEIGHT = NMS.getField(Entity.class, "headHeight");
|
private static final MethodHandle HEAD_HEIGHT = NMS.getSetter(Entity.class, "headHeight");
|
||||||
private static final Method HEAD_HEIGHT_METHOD = NMS.getMethod(Entity.class, "getHeadHeight", true,
|
private static final MethodHandle HEAD_HEIGHT_METHOD = NMS.getMethodHandle(Entity.class, "getHeadHeight", true,
|
||||||
EntityPose.class, EntitySize.class);
|
EntityPose.class, EntitySize.class);
|
||||||
private static Method ISCLIMBING_METHOD = NMS.getMethod(EntityLiving.class, "f", true, Vec3D.class);
|
private static final MethodHandle ISCLIMBING_METHOD = NMS.getMethodHandle(EntityLiving.class, "f", true,
|
||||||
private static final Field JUMP_FIELD = NMS.getField(EntityLiving.class, "jumping");
|
Vec3D.class);
|
||||||
private static Method MAKE_REQUEST;
|
private static final MethodHandle JUMP_FIELD = NMS.getGetter(EntityLiving.class, "jumping");
|
||||||
private static Field NAVIGATION_WORLD_FIELD = NMS.getField(NavigationAbstract.class, "b");
|
private static final MethodHandle MAKE_REQUEST = NMS.getMethodHandle(YggdrasilAuthenticationService.class,
|
||||||
|
"makeRequest", true, URL.class, Object.class, Class.class);
|
||||||
|
private static final MethodHandle NAVIGATION_WORLD_FIELD = NMS.getSetter(NavigationAbstract.class, "b");
|
||||||
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
|
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
|
||||||
private static Field PATHFINDING_RANGE = NMS.getField(NavigationAbstract.class, "p");
|
private static final MethodHandle PATHFINDING_RANGE = NMS.getGetter(NavigationAbstract.class, "p");
|
||||||
private static final Field RABBIT_FIELD = NMS.getField(EntityRabbit.class, "bz");
|
private static final MethodHandle RABBIT_FIELD = NMS.getGetter(EntityRabbit.class, "bz");
|
||||||
private static final Random RANDOM = Util.getFastRandom();
|
private static final Random RANDOM = Util.getFastRandom();
|
||||||
private static final Field SIZE_FIELD = NMS.getField(Entity.class, "size");
|
private static final MethodHandle SIZE_FIELD_GETTER = NMS.getGetter(Entity.class, "size");
|
||||||
|
private static final MethodHandle SIZE_FIELD_SETTER = NMS.getSetter(Entity.class, "size");
|
||||||
private static Field SKULL_PROFILE_FIELD;
|
private static Field SKULL_PROFILE_FIELD;
|
||||||
static {
|
static {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Field field = NMS.getFinalField(IRegistry.class, "ENTITY_TYPE");
|
Field field = NMS.getFinalField(IRegistry.class, "ENTITY_TYPE");
|
||||||
ENTITY_REGISTRY = new CustomEntityRegistry((RegistryBlocks<EntityTypes<?>>) field.get(null));
|
ENTITY_REGISTRY = new CustomEntityRegistry((RegistryBlocks<EntityTypes<?>>) field.get(null));
|
||||||
@ -1688,13 +1679,5 @@ public class NMSImpl implements NMSBridge {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage());
|
Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
MAKE_REQUEST = YggdrasilAuthenticationService.class.getDeclaredMethod("makeRequest", URL.class,
|
|
||||||
Object.class, Class.class);
|
|
||||||
MAKE_REQUEST.setAccessible(true);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.util;
|
package net.citizensnpcs.nms.v1_14_R1.util;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC;
|
import net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC;
|
||||||
import net.citizensnpcs.util.NMS;
|
|
||||||
import net.minecraft.server.v1_14_R1.AttributeInstance;
|
import net.minecraft.server.v1_14_R1.AttributeInstance;
|
||||||
import net.minecraft.server.v1_14_R1.Block;
|
import net.minecraft.server.v1_14_R1.Block;
|
||||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
@ -17,7 +15,6 @@ import net.minecraft.server.v1_14_R1.GenericAttributes;
|
|||||||
import net.minecraft.server.v1_14_R1.IBlockAccess;
|
import net.minecraft.server.v1_14_R1.IBlockAccess;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.MathHelper;
|
import net.minecraft.server.v1_14_R1.MathHelper;
|
||||||
import net.minecraft.server.v1_14_R1.MethodProfiler;
|
|
||||||
import net.minecraft.server.v1_14_R1.NavigationAbstract;
|
import net.minecraft.server.v1_14_R1.NavigationAbstract;
|
||||||
import net.minecraft.server.v1_14_R1.PathEntity;
|
import net.minecraft.server.v1_14_R1.PathEntity;
|
||||||
import net.minecraft.server.v1_14_R1.PathMode;
|
import net.minecraft.server.v1_14_R1.PathMode;
|
||||||
@ -581,11 +578,4 @@ public class PlayerNavigation extends NavigationAbstract {
|
|||||||
return new EntityInsentient(EntityTypes.VILLAGER, world) {
|
return new EntityInsentient(EntityTypes.VILLAGER, world) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long getMonotonicMillis() {
|
|
||||||
return SystemUtils.getMonotonicMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Method PROFILER_ENTER = NMS.getMethod(MethodProfiler.class, "a", false, String.class);
|
|
||||||
private static final Method PROFILER_EXIT = NMS.getMethod(MethodProfiler.class, "e", false);
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package net.citizensnpcs.nms.v1_14_R1.util;
|
package net.citizensnpcs.nms.v1_14_R1.util;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -38,10 +36,8 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
|
|
||||||
private int getA(PlayerChunkMap map2) {
|
private int getA(PlayerChunkMap map2) {
|
||||||
try {
|
try {
|
||||||
return A.getInt(map2);
|
return (int) A.invoke(map2);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -49,12 +45,8 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
|
|
||||||
private int getb(ChunkCoordIntPair chunkcoordintpair, EntityPlayer entityplayer, boolean b) {
|
private int getb(ChunkCoordIntPair chunkcoordintpair, EntityPlayer entityplayer, boolean b) {
|
||||||
try {
|
try {
|
||||||
return (int) B.invoke(map, chunkcoordintpair, entityplayer, b);
|
return (int) B.invoke(chunkcoordintpair, entityplayer, b);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -63,11 +55,7 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
private PlayerChunk getVisibleChunk(long pair) {
|
private PlayerChunk getVisibleChunk(long pair) {
|
||||||
try {
|
try {
|
||||||
return (PlayerChunk) GET_VISIBLE_CHUNK.invoke(map, pair);
|
return (PlayerChunk) GET_VISIBLE_CHUNK.invoke(map, pair);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -107,10 +95,8 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
|
|
||||||
private static int getD(EntityTracker entry) {
|
private static int getD(EntityTracker entry) {
|
||||||
try {
|
try {
|
||||||
return D.getInt(TRACKER_ENTRY.get(entry));
|
return (int) D.invoke(TRACKER_ENTRY.invoke(entry));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -118,10 +104,8 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
|
|
||||||
private static boolean getE(EntityTracker entry) {
|
private static boolean getE(EntityTracker entry) {
|
||||||
try {
|
try {
|
||||||
return E.getBoolean(TRACKER_ENTRY.get(entry));
|
return (boolean) E.invoke(TRACKER_ENTRY.invoke(entry));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -129,10 +113,8 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
|
|
||||||
private static int getI(EntityTracker entry) {
|
private static int getI(EntityTracker entry) {
|
||||||
try {
|
try {
|
||||||
return (Integer) I.get(entry);
|
return (Integer) I.invoke(entry);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -140,10 +122,8 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
|
|
||||||
private static Entity getTracker(EntityTracker entry) {
|
private static Entity getTracker(EntityTracker entry) {
|
||||||
try {
|
try {
|
||||||
return (Entity) TRACKER.get(entry);
|
return (Entity) TRACKER.invoke(entry);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -151,23 +131,21 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
|
|
||||||
private static EntityTrackerEntry getTrackerEntry(EntityTracker entry) {
|
private static EntityTrackerEntry getTrackerEntry(EntityTracker entry) {
|
||||||
try {
|
try {
|
||||||
return (EntityTrackerEntry) TRACKER_ENTRY.get(entry);
|
return (EntityTrackerEntry) TRACKER_ENTRY.invoke(entry);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Field A = NMS.getField(PlayerChunkMap.class, "A");
|
private static final MethodHandle A = NMS.getGetter(PlayerChunkMap.class, "A");
|
||||||
private static Method B = NMS.getMethod(PlayerChunkMap.class, "b", true, ChunkCoordIntPair.class,
|
private static final MethodHandle B = NMS.getMethodHandle(PlayerChunkMap.class, "b", true, ChunkCoordIntPair.class,
|
||||||
EntityPlayer.class, boolean.class);
|
EntityPlayer.class, boolean.class);
|
||||||
private static Field D = NMS.getField(EntityTrackerEntry.class, "d");
|
private static final MethodHandle D = NMS.getGetter(EntityTrackerEntry.class, "d");
|
||||||
private static Field E = NMS.getField(EntityTrackerEntry.class, "e");
|
private static final MethodHandle E = NMS.getGetter(EntityTrackerEntry.class, "e");
|
||||||
private static final Method GET_VISIBLE_CHUNK = NMS.getMethod(PlayerChunkMap.class, "getVisibleChunk", true,
|
private static final MethodHandle GET_VISIBLE_CHUNK = NMS.getMethodHandle(PlayerChunkMap.class, "getVisibleChunk",
|
||||||
long.class);
|
true, long.class);
|
||||||
private static Field I = NMS.getField(EntityTracker.class, "trackingDistance");
|
private static final MethodHandle I = NMS.getGetter(EntityTracker.class, "trackingDistance");
|
||||||
private static Field TRACKER = NMS.getField(EntityTracker.class, "tracker");
|
private static final MethodHandle TRACKER = NMS.getGetter(EntityTracker.class, "tracker");
|
||||||
private static Field TRACKER_ENTRY = NMS.getField(EntityTracker.class, "trackerEntry");
|
private static final MethodHandle TRACKER_ENTRY = NMS.getGetter(EntityTracker.class, "trackerEntry");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user