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