Fix rabbit evil variant not setting goals with useMinecraftAI turned on

This commit is contained in:
fullwall 2024-04-07 13:22:40 +08:00
parent 3563413c06
commit 809ef01b5d
8 changed files with 75 additions and 41 deletions

View File

@ -222,14 +222,19 @@ public class RabbitController extends MobEntityController {
} }
@Override @Override
public void setRabbitType(int i) { public void setRabbitType(int type) {
if (npc != null) { if (npc == null) {
if (NMSImpl.getRabbitTypeField() == null) super.setRabbitType(type);
return;
this.datawatcher.set(NMSImpl.getRabbitTypeField(), i);
return; return;
} }
super.setRabbitType(i); if (npc.useMinecraftAI()) {
if (goalSelector.c().count() == 0) {
initPathfinder(); // make sure the evil goals include the default AI goals
}
super.setRabbitType(type);
} else if (NMSImpl.getRabbitTypeField() != null) {
datawatcher.set(NMSImpl.getRabbitTypeField(), type);
}
} }
} }

View File

@ -222,14 +222,19 @@ public class RabbitController extends MobEntityController {
} }
@Override @Override
public void setRabbitType(int i) { public void setRabbitType(int type) {
if (npc != null) { if (npc == null) {
if (NMSImpl.getRabbitTypeField() == null) super.setRabbitType(type);
return;
this.datawatcher.set(NMSImpl.getRabbitTypeField(), i);
return; return;
} }
super.setRabbitType(i); if (npc.useMinecraftAI()) {
if (goalSelector.c().count() == 0) {
initPathfinder(); // make sure the evil goals include the default AI goals
}
super.setRabbitType(type);
} else if (NMSImpl.getRabbitTypeField() != null) {
datawatcher.set(NMSImpl.getRabbitTypeField(), type);
}
} }
} }

View File

@ -222,14 +222,19 @@ public class RabbitController extends MobEntityController {
} }
@Override @Override
public void setRabbitType(int i) { public void setRabbitType(int type) {
if (npc != null) { if (npc == null) {
if (NMSImpl.getRabbitTypeField() == null) super.setRabbitType(type);
return;
this.datawatcher.set(NMSImpl.getRabbitTypeField(), i);
return; return;
} }
super.setRabbitType(i); if (npc.useMinecraftAI()) {
if (goalSelector.d().count() == 0) {
initPathfinder(); // make sure the evil goals include the default AI goals
}
super.setRabbitType(type);
} else if (NMSImpl.getRabbitTypeField() != null) {
datawatcher.set(NMSImpl.getRabbitTypeField(), type);
}
} }
} }

View File

@ -206,14 +206,19 @@ public class RabbitController extends MobEntityController {
} }
@Override @Override
public void setRabbitType(int i) { public void setRabbitType(int type) {
if (npc != null) { if (npc == null) {
if (NMSImpl.getRabbitTypeField() == null) super.setRabbitType(type);
return;
this.entityData.set(NMSImpl.getRabbitTypeField(), i);
return; return;
} }
super.setRabbitType(i); if (npc.useMinecraftAI()) {
if (goalSelector.getAvailableGoals().size() == 0) {
registerGoals(); // make sure the evil goals include the default AI goals
}
super.setRabbitType(type);
} else if (NMSImpl.getRabbitTypeField() != null) {
entityData.set(NMSImpl.getRabbitTypeField(), type);
}
} }
@Override @Override

View File

@ -207,14 +207,19 @@ public class RabbitController extends MobEntityController {
} }
@Override @Override
public void setRabbitType(int i) { public void setRabbitType(int type) {
if (npc != null) { if (npc == null) {
if (NMSImpl.getRabbitTypeField() == null) super.setRabbitType(type);
return;
this.entityData.set(NMSImpl.getRabbitTypeField(), i);
return; return;
} }
super.setRabbitType(i); if (npc.useMinecraftAI()) {
if (goalSelector.getAvailableGoals().size() == 0) {
registerGoals(); // make sure the evil goals include the default AI goals
}
super.setRabbitType(type);
} else if (NMSImpl.getRabbitTypeField() != null) {
entityData.set(NMSImpl.getRabbitTypeField(), type);
}
} }
@Override @Override

View File

@ -209,13 +209,18 @@ public class RabbitController extends MobEntityController {
@Override @Override
public void setVariant(Variant variant) { public void setVariant(Variant variant) {
if (npc != null) { if (npc == null) {
if (NMSImpl.getRabbitTypeField() == null) super.setVariant(variant);
return;
this.entityData.set(NMSImpl.getRabbitTypeField(), variant.id());
return; return;
} }
super.setVariant(variant); if (npc.useMinecraftAI()) {
if (goalSelector.getAvailableGoals().size() == 0) {
registerGoals(); // make sure the evil goals include the default AI goals
}
super.setVariant(variant);
} else if (NMSImpl.getRabbitTypeField() != null) {
entityData.set(NMSImpl.getRabbitTypeField(), variant.id());
}
} }
@Override @Override

View File

@ -199,13 +199,18 @@ public class RabbitController extends MobEntityController {
@Override @Override
public void setVariant(Variant variant) { public void setVariant(Variant variant) {
if (npc != null) { if (npc == null) {
if (NMSImpl.RABBIT_TYPE_DATAWATCHER == null) super.setVariant(variant);
return;
this.entityData.set(NMSImpl.RABBIT_TYPE_DATAWATCHER, variant.id());
return; return;
} }
super.setVariant(variant); if (npc.useMinecraftAI()) {
if (goalSelector.getAvailableGoals().size() == 0) {
registerGoals(); // make sure the evil goals include the default AI goals
}
super.setVariant(variant);
} else if (NMSImpl.RABBIT_TYPE_DATAWATCHER != null) {
entityData.set(NMSImpl.RABBIT_TYPE_DATAWATCHER, variant.id());
}
} }
@Override @Override

View File

@ -2553,7 +2553,6 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle ADVANCEMENTS_PLAYER_SETTER = NMS.getFirstFinalSetter(ServerPlayer.class, private static final MethodHandle ADVANCEMENTS_PLAYER_SETTER = NMS.getFirstFinalSetter(ServerPlayer.class,
PlayerAdvancements.class); PlayerAdvancements.class);
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP = NMS.getFirstGetter(AttributeSupplier.class, Map.class); private static final MethodHandle ATTRIBUTE_PROVIDER_MAP = NMS.getFirstGetter(AttributeSupplier.class, Map.class);
private static final MethodHandle ATTRIBUTE_PROVIDER_MAP_SETTER = NMS.getFirstFinalSetter(AttributeSupplier.class, private static final MethodHandle ATTRIBUTE_PROVIDER_MAP_SETTER = NMS.getFirstFinalSetter(AttributeSupplier.class,
Map.class); Map.class);