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
public void setRabbitType(int i) {
if (npc != null) {
if (NMSImpl.getRabbitTypeField() == null)
return;
this.datawatcher.set(NMSImpl.getRabbitTypeField(), i);
public void setRabbitType(int type) {
if (npc == null) {
super.setRabbitType(type);
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
public void setRabbitType(int i) {
if (npc != null) {
if (NMSImpl.getRabbitTypeField() == null)
return;
this.datawatcher.set(NMSImpl.getRabbitTypeField(), i);
public void setRabbitType(int type) {
if (npc == null) {
super.setRabbitType(type);
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
public void setRabbitType(int i) {
if (npc != null) {
if (NMSImpl.getRabbitTypeField() == null)
return;
this.datawatcher.set(NMSImpl.getRabbitTypeField(), i);
public void setRabbitType(int type) {
if (npc == null) {
super.setRabbitType(type);
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
public void setRabbitType(int i) {
if (npc != null) {
if (NMSImpl.getRabbitTypeField() == null)
return;
this.entityData.set(NMSImpl.getRabbitTypeField(), i);
public void setRabbitType(int type) {
if (npc == null) {
super.setRabbitType(type);
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

View File

@ -207,14 +207,19 @@ public class RabbitController extends MobEntityController {
}
@Override
public void setRabbitType(int i) {
if (npc != null) {
if (NMSImpl.getRabbitTypeField() == null)
return;
this.entityData.set(NMSImpl.getRabbitTypeField(), i);
public void setRabbitType(int type) {
if (npc == null) {
super.setRabbitType(type);
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

View File

@ -209,13 +209,18 @@ public class RabbitController extends MobEntityController {
@Override
public void setVariant(Variant variant) {
if (npc != null) {
if (NMSImpl.getRabbitTypeField() == null)
return;
this.entityData.set(NMSImpl.getRabbitTypeField(), variant.id());
if (npc == null) {
super.setVariant(variant);
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

View File

@ -199,13 +199,18 @@ public class RabbitController extends MobEntityController {
@Override
public void setVariant(Variant variant) {
if (npc != null) {
if (NMSImpl.RABBIT_TYPE_DATAWATCHER == null)
return;
this.entityData.set(NMSImpl.RABBIT_TYPE_DATAWATCHER, variant.id());
if (npc == null) {
super.setVariant(variant);
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

View File

@ -2553,7 +2553,6 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle ADVANCEMENTS_PLAYER_SETTER = NMS.getFirstFinalSetter(ServerPlayer.class,
PlayerAdvancements.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,
Map.class);