mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-21 18:15:51 +01:00
Fix entitytype lookup for old minecraft versions
This commit is contained in:
parent
172976e3d6
commit
158d4d328c
@ -1099,9 +1099,9 @@ public class NMSImpl implements NMSBridge {
|
||||
public void registerEntityClass(Class<?> clazz, Object raw) {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
EntityTypes<?> type = (EntityTypes<?>) raw;
|
||||
Class<?> search = clazz;
|
||||
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
|
||||
EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
|
||||
MinecraftKey key = ENTITY_REGISTRY.getKey(type);
|
||||
if (key == null) {
|
||||
continue;
|
||||
|
@ -25,7 +25,7 @@ import net.minecraft.server.v1_14_R1.World;
|
||||
public abstract class MobEntityController extends AbstractEntityController {
|
||||
private final Class<?> clazz;
|
||||
|
||||
protected MobEntityController(Class<?> clazz) {NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz));
|
||||
protected MobEntityController(Class<?> clazz) {NMS.registerEntityClass(clazz, null);
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
|
@ -1142,9 +1142,9 @@ public class NMSImpl implements NMSBridge {
|
||||
public void registerEntityClass(Class<?> clazz, Object raw) {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
EntityTypes<?> type = (EntityTypes<?>) raw;
|
||||
Class<?> search = clazz;
|
||||
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
|
||||
EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
|
||||
MinecraftKey key = ENTITY_REGISTRY.getKey(type);
|
||||
if (key == null || type == null) {
|
||||
continue;
|
||||
|
@ -25,7 +25,7 @@ import net.minecraft.server.v1_15_R1.World;
|
||||
public abstract class MobEntityController extends AbstractEntityController {
|
||||
private final Class<?> clazz;
|
||||
|
||||
protected MobEntityController(Class<?> clazz) {NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz));
|
||||
protected MobEntityController(Class<?> clazz) {NMS.registerEntityClass(clazz, null);
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
|
@ -1159,9 +1159,9 @@ public class NMSImpl implements NMSBridge {
|
||||
public void registerEntityClass(Class<?> clazz, Object raw) {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
EntityTypes<?> type = (EntityTypes<?>) raw;
|
||||
Class<?> search = clazz;
|
||||
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
|
||||
net.minecraft.server.v1_15_R1.EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
|
||||
MinecraftKey key = ENTITY_REGISTRY.getKey(type);
|
||||
if (key == null || type == null) {
|
||||
continue;
|
||||
|
@ -25,7 +25,7 @@ import net.minecraft.server.v1_16_R3.World;
|
||||
public abstract class MobEntityController extends AbstractEntityController {
|
||||
private final Class<?> clazz;
|
||||
|
||||
protected MobEntityController(Class<?> clazz) {NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz));
|
||||
protected MobEntityController(Class<?> clazz) {NMS.registerEntityClass(clazz, null);
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
|
@ -1182,9 +1182,9 @@ public class NMSImpl implements NMSBridge {
|
||||
public void registerEntityClass(Class<?> clazz, Object raw) {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
EntityTypes<?> type = (EntityTypes<?>) raw;
|
||||
Class<?> search = clazz;
|
||||
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
|
||||
net.minecraft.server.v1_16_R3.EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
|
||||
MinecraftKey key = ENTITY_REGISTRY.getKey(type);
|
||||
if (key == null || type == null) {
|
||||
continue;
|
||||
|
@ -25,7 +25,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
private final Class<?> clazz;
|
||||
|
||||
protected MobEntityController(Class<?> clazz) {
|
||||
NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz));
|
||||
NMS.registerEntityClass(clazz, null);
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
|
@ -1188,9 +1188,9 @@ public class NMSImpl implements NMSBridge {
|
||||
public void registerEntityClass(Class<?> clazz, Object raw) {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
net.minecraft.world.entity.EntityType<?> type = (net.minecraft.world.entity.EntityType) raw;
|
||||
Class<?> search = clazz;
|
||||
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
|
||||
net.minecraft.world.entity.EntityType<?> type = ENTITY_REGISTRY.findType(search);
|
||||
ResourceLocation key = ENTITY_REGISTRY.getKey(type);
|
||||
if (key == null || type == null) {
|
||||
continue;
|
||||
|
@ -25,7 +25,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
private final Class<?> clazz;
|
||||
|
||||
protected MobEntityController(Class<?> clazz) {
|
||||
NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz));
|
||||
NMS.registerEntityClass(clazz, null);
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
|
@ -1197,9 +1197,9 @@ public class NMSImpl implements NMSBridge {
|
||||
public void registerEntityClass(Class<?> clazz, Object raw) {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
net.minecraft.world.entity.EntityType<?> type = (net.minecraft.world.entity.EntityType) raw;
|
||||
Class<?> search = clazz;
|
||||
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
|
||||
net.minecraft.world.entity.EntityType<?> type = ENTITY_REGISTRY.findType(search);
|
||||
ResourceLocation key = ENTITY_REGISTRY.getKey(type);
|
||||
if (key == null || type == null) {
|
||||
continue;
|
||||
|
@ -25,7 +25,7 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
private final Class<?> clazz;
|
||||
|
||||
protected MobEntityController(Class<?> clazz) {
|
||||
NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz));
|
||||
NMS.registerEntityClass(clazz, null);
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
|
@ -1336,9 +1336,9 @@ public class NMSImpl implements NMSBridge {
|
||||
public void registerEntityClass(Class<?> clazz, Object raw) {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
net.minecraft.world.entity.EntityType<?> type = (net.minecraft.world.entity.EntityType) raw;
|
||||
Class<?> search = clazz;
|
||||
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
|
||||
net.minecraft.world.entity.EntityType<?> type = ENTITY_REGISTRY.findType(search);
|
||||
ResourceLocation key = ENTITY_REGISTRY.getKey(type);
|
||||
if (key == null || type == null) {
|
||||
continue;
|
||||
|
@ -25,15 +25,14 @@ public abstract class MobEntityController extends AbstractEntityController {
|
||||
private final Class<?> clazz;
|
||||
|
||||
protected MobEntityController(Class<?> clazz) {
|
||||
NMS.registerEntityClass(clazz, NMSImpl.getEntityType(clazz));
|
||||
NMS.registerEntityClass(clazz, null);
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createEntity(Location at, NPC npc) {
|
||||
EntityType<?> type = NMSImpl.getEntityType(clazz);
|
||||
net.minecraft.world.entity.Entity entity = createEntityFromClass(type, ((CraftWorld) at.getWorld()).getHandle(),
|
||||
npc);
|
||||
net.minecraft.world.entity.Entity entity = createEntityFromClass(NMSImpl.getEntityType(clazz),
|
||||
((CraftWorld) at.getWorld()).getHandle(), npc);
|
||||
if (entity instanceof Mob) {
|
||||
NMSImpl.clearGoals(npc, ((Mob) entity).goalSelector, ((Mob) entity).targetSelector);
|
||||
Mob mob = (Mob) entity;
|
||||
|
@ -1001,7 +1001,6 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
|
||||
private void loadEntityTypes() {
|
||||
|
||||
EntityControllers.setEntityControllerForType(EntityType.ALLAY, AllayController.class);
|
||||
EntityControllers.setEntityControllerForType(EntityType.AREA_EFFECT_CLOUD, AreaEffectCloudController.class);
|
||||
EntityControllers.setEntityControllerForType(EntityType.ARMADILLO, ArmadilloController.class);
|
||||
@ -1368,9 +1367,9 @@ public class NMSImpl implements NMSBridge {
|
||||
public void registerEntityClass(Class<?> clazz, Object raw) {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
net.minecraft.world.entity.EntityType<?> type = (net.minecraft.world.entity.EntityType) raw;
|
||||
Class<?> search = clazz;
|
||||
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
|
||||
net.minecraft.world.entity.EntityType<?> type = ENTITY_REGISTRY.findType(search);
|
||||
ResourceLocation key = ENTITY_REGISTRY.getKey(type);
|
||||
if (key == null || type == null)
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user