Helper fix
This commit is contained in:
parent
b36aae9e8b
commit
c4fbfbf236
1 changed files with 17 additions and 7 deletions
|
@ -15,11 +15,16 @@ public class SpawnHelper {
|
||||||
private static Method regRestriction;
|
private static Method regRestriction;
|
||||||
|
|
||||||
public static <T extends MobEntity> void restriction(EntityType<T> entity, Location location, Type heughtmapType, SpawnPredicate<T> predicate) {
|
public static <T extends MobEntity> void restriction(EntityType<T> entity, Location location, Type heughtmapType, SpawnPredicate<T> predicate) {
|
||||||
try {
|
if (regRestriction != null) {
|
||||||
regRestriction.invoke(null, entity, location, heughtmapType, predicate);
|
try {
|
||||||
|
regRestriction.invoke(null, entity, location, heughtmapType, predicate);
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||||
|
BetterEnd.LOGGER.error(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
else {
|
||||||
BetterEnd.LOGGER.error(e.getMessage());
|
BetterEnd.LOGGER.error("Unable to register spawn restriction, variable is not handled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,10 +34,15 @@ public class SpawnHelper {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
regRestriction = SpawnRestriction.class.getDeclaredMethod("register", EntityType.class, Location.class, Type.class, SpawnPredicate.class);
|
for (Method method: SpawnRestriction.class.getDeclaredMethods()) {
|
||||||
regRestriction.setAccessible(true);
|
if (method.getParameterCount() == 4) {
|
||||||
|
regRestriction = method;
|
||||||
|
regRestriction.setAccessible(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (NoSuchMethodException | SecurityException e) {
|
catch (SecurityException e) {
|
||||||
BetterEnd.LOGGER.error(e.getMessage());
|
BetterEnd.LOGGER.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue