Slime fixes

This commit is contained in:
paulevsGitch 2020-10-05 23:17:51 +03:00
parent cd0d5582a8
commit 3bc28083f0
8 changed files with 142 additions and 6 deletions

View file

@ -0,0 +1,5 @@
package ru.betterend.util;
public interface ISlime {
public void setSlimeSize(int size, boolean heal);
}

View file

@ -0,0 +1,39 @@
package ru.betterend.util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnRestriction;
import net.minecraft.entity.SpawnRestriction.Location;
import net.minecraft.entity.SpawnRestriction.SpawnPredicate;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.world.Heightmap.Type;
import ru.betterend.BetterEnd;
public class SpawnHelper {
private static Method regRestriction;
public static <T extends MobEntity> void restriction(EntityType<T> entity, Location location, Type heughtmapType, SpawnPredicate<T> predicate) {
try {
regRestriction.invoke(null, entity, location, heughtmapType, predicate);
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
BetterEnd.LOGGER.error(e.getMessage());
}
}
public static <T extends MobEntity> void restrictionLand(EntityType<T> entity, SpawnPredicate<T> predicate) {
restriction(entity, Location.ON_GROUND, Type.MOTION_BLOCKING, predicate);
}
static {
try {
regRestriction = SpawnRestriction.class.getDeclaredMethod("register", EntityType.class, Location.class, Type.class, SpawnPredicate.class);
regRestriction.setAccessible(true);
}
catch (NoSuchMethodException | SecurityException e) {
BetterEnd.LOGGER.error(e.getMessage());
}
}
}