More getNmsField/Method calls
This commit is contained in:
@@ -544,13 +544,11 @@ public class PacketsManager {
|
||||
boolean hasInvun = false;
|
||||
Object nmsEntity = ReflectionManager.getNmsEntity(entity);
|
||||
try {
|
||||
Class entityClass = ReflectionManager.getNmsClass("Entity");
|
||||
if (entity instanceof LivingEntity) {
|
||||
hasInvun = entityClass.getField("noDamageTicks").getInt(nmsEntity) == ReflectionManager
|
||||
.getNmsClass("EntityLiving").getField("maxNoDamageTicks")
|
||||
.getInt(nmsEntity);
|
||||
hasInvun = ReflectionManager.getNmsField("Entity", "noDamageTicks").getInt(nmsEntity) ==
|
||||
ReflectionManager.getNmsField("EntityLiving", "maxNoDamageTicks").getInt(nmsEntity);
|
||||
} else {
|
||||
hasInvun = (Boolean) entityClass.getMethod("isInvulnerable").invoke(nmsEntity);
|
||||
hasInvun = (Boolean) ReflectionManager.getNmsMethod("Entity", "isInvulnerable").invoke(nmsEntity);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -581,18 +579,16 @@ public class PacketsManager {
|
||||
try {
|
||||
int typeId = soundLoc.getWorld().getBlockTypeIdAt(soundLoc.getBlockX(),
|
||||
soundLoc.getBlockY() - 1, soundLoc.getBlockZ());
|
||||
Class blockClass = ReflectionManager.getNmsClass("Block");
|
||||
Object block;
|
||||
if (LibVersion.is1_7()) {
|
||||
block = ReflectionManager.getNmsClass("RegistryMaterials")
|
||||
.getMethod("a", int.class)
|
||||
.invoke(blockClass.getField("REGISTRY").get(null), typeId);
|
||||
block = ReflectionManager.getNmsMethod("RegistryMaterials", "a", int.class)
|
||||
.invoke(ReflectionManager.getNmsField("Block", "REGISTRY").get(null), typeId);
|
||||
} else {
|
||||
block = ((Object[]) blockClass.getField("byId").get(null))[typeId];
|
||||
block = ((Object[]) ReflectionManager.getNmsField("Block", "byId").get(null))[typeId];
|
||||
}
|
||||
if (block != null) {
|
||||
Object step = blockClass.getField("stepSound").get(block);
|
||||
mods.write(0, step.getClass().getMethod("getStepSound").invoke(step));
|
||||
Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block);
|
||||
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound").invoke(step));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user