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