Fix axolotl/dolphin movement speed being too slow with minecraft AI, remove nonfunctional makeBrain override

This commit is contained in:
fullwall 2024-08-18 23:03:03 +08:00
parent 8ee9ecb5ed
commit 4f923c904a
12 changed files with 47 additions and 64 deletions

View File

@ -487,7 +487,8 @@ public class CitizensNPC extends AbstractNPC {
NMS.activate(getEntity());
}
}
boolean shouldSwim = data().get(NPC.Metadata.SWIM, SwimmingExaminer.isWaterMob(getEntity()))
boolean shouldSwim = data().get(NPC.Metadata.SWIM,
!useMinecraftAI() && SwimmingExaminer.isWaterMob(getEntity()))
&& MinecraftBlockExaminer.isLiquid(loc.getBlock().getType());
if (navigator.isNavigating()) {
if (shouldSwim) {
@ -610,7 +611,7 @@ public class CitizensNPC extends AbstractNPC {
}
}
private static SetMultimap<ChunkCoord, NPC> CHUNK_LOADERS = HashMultimap.create();
private static final SetMultimap<ChunkCoord, NPC> CHUNK_LOADERS = HashMultimap.create();
private static boolean SUPPORT_GLOWING = false;
private static boolean SUPPORT_NODAMAGE_TICKS = false;
private static boolean SUPPORT_PICKUP_ITEMS = false;

View File

@ -6,10 +6,7 @@ import org.bukkit.craftbukkit.v1_17_R1.entity.CraftAxolotl;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
import org.bukkit.util.Vector;
import com.mojang.serialization.Dynamic;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_17_R1.util.EntityMoveControl;
import net.citizensnpcs.nms.v1_17_R1.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_17_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_17_R1.util.NMSImpl;
@ -26,7 +23,6 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
@ -171,13 +167,6 @@ public class AxolotlController extends MobEntityController {
return NMSBoundingBox.makeBB(npc, super.makeBoundingBox());
}
@Override
protected Brain makeBrain(Dynamic dynamic) {
if (npc == null || npc.useMinecraftAI())
return super.makeBrain(dynamic);
return brainProvider().makeBrain(dynamic);
}
@Override
public InteractionResult mobInteract(Player entityhuman, InteractionHand enumhand) {
if (npc == null || !npc.isProtected())
@ -226,9 +215,13 @@ public class AxolotlController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new EntityMoveControl(this);
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -7,7 +7,6 @@ import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
import org.bukkit.util.Vector;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_17_R1.util.EntityMoveControl;
import net.citizensnpcs.nms.v1_17_R1.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_17_R1.util.NMSBoundingBox;
import net.citizensnpcs.nms.v1_17_R1.util.NMSImpl;
@ -52,9 +51,7 @@ public class DolphinController extends MobEntityController {
public static class EntityDolphinNPC extends Dolphin implements NPCHolder {
private boolean inProtectedTick;
private final CitizensNPC npc;
private MoveControl oldMoveController;
public EntityDolphinNPC(EntityType<? extends Dolphin> types, Level level) {
@ -212,9 +209,13 @@ public class DolphinController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new EntityMoveControl(this);
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -6,8 +6,6 @@ import org.bukkit.craftbukkit.v1_18_R2.entity.CraftAxolotl;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
import org.bukkit.util.Vector;
import com.mojang.serialization.Dynamic;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_18_R2.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_18_R2.util.NMSBoundingBox;
@ -26,7 +24,6 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
@ -60,7 +57,6 @@ public class AxolotlController extends MobEntityController {
public static class EntityAxolotlNPC extends Axolotl implements NPCHolder {
private final CitizensNPC npc;
private MoveControl oldMoveController;
public EntityAxolotlNPC(EntityType<? extends Axolotl> types, Level level) {
@ -171,13 +167,6 @@ public class AxolotlController extends MobEntityController {
return NMSBoundingBox.makeBB(npc, super.makeBoundingBox());
}
@Override
protected Brain<?> makeBrain(Dynamic<?> dynamic) {
if (npc == null || npc.useMinecraftAI())
return super.makeBrain(dynamic);
return brainProvider().makeBrain(dynamic);
}
@Override
public InteractionResult mobInteract(Player entityhuman, InteractionHand enumhand) {
if (npc == null || !npc.isProtected())
@ -233,9 +222,13 @@ public class AxolotlController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -52,9 +52,7 @@ public class DolphinController extends MobEntityController {
public static class EntityDolphinNPC extends Dolphin implements NPCHolder {
private boolean inProtectedTick;
private final CitizensNPC npc;
private MoveControl oldMoveController;
public EntityDolphinNPC(EntityType<? extends Dolphin> types, Level level) {
@ -219,9 +217,13 @@ public class DolphinController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -6,8 +6,6 @@ import org.bukkit.craftbukkit.v1_19_R3.entity.CraftAxolotl;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftEntity;
import org.bukkit.util.Vector;
import com.mojang.serialization.Dynamic;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_19_R3.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_19_R3.util.NMSBoundingBox;
@ -27,7 +25,6 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
@ -172,13 +169,6 @@ public class AxolotlController extends MobEntityController {
return NMSBoundingBox.makeBB(npc, super.makeBoundingBox());
}
@Override
protected Brain<?> makeBrain(Dynamic<?> dynamic) {
if (npc == null || npc.useMinecraftAI())
return super.makeBrain(dynamic);
return brainProvider().makeBrain(dynamic);
}
@Override
public InteractionResult mobInteract(Player entityhuman, InteractionHand enumhand) {
if (npc == null || !npc.isProtected())
@ -234,9 +224,13 @@ public class AxolotlController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -220,9 +220,13 @@ public class DolphinController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -5,8 +5,6 @@ import org.bukkit.craftbukkit.v1_20_R4.CraftServer;
import org.bukkit.craftbukkit.v1_20_R4.entity.CraftAxolotl;
import org.bukkit.craftbukkit.v1_20_R4.entity.CraftEntity;
import com.mojang.serialization.Dynamic;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_20_R4.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_20_R4.util.NMSBoundingBox;
@ -25,7 +23,6 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
@ -170,13 +167,6 @@ public class AxolotlController extends MobEntityController {
return NMSBoundingBox.makeBB(npc, super.makeBoundingBox());
}
@Override
protected Brain<?> makeBrain(Dynamic<?> dynamic) {
if (npc == null || npc.useMinecraftAI())
return super.makeBrain(dynamic);
return brainProvider().makeBrain(dynamic);
}
@Override
public InteractionResult mobInteract(Player entityhuman, InteractionHand enumhand) {
if (npc == null || !npc.isProtected())
@ -224,9 +214,13 @@ public class AxolotlController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -208,9 +208,13 @@ public class DolphinController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -5,8 +5,6 @@ import org.bukkit.craftbukkit.v1_21_R1.CraftServer;
import org.bukkit.craftbukkit.v1_21_R1.entity.CraftAxolotl;
import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity;
import com.mojang.serialization.Dynamic;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_21_R1.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_21_R1.util.NMSBoundingBox;
@ -24,7 +22,6 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
@ -59,7 +56,6 @@ public class AxolotlController extends MobEntityController {
public static class EntityAxolotlNPC extends Axolotl implements NPCHolder {
private final CitizensNPC npc;
private MoveControl oldMoveController;
public EntityAxolotlNPC(EntityType<? extends Axolotl> types, Level level) {
@ -177,13 +173,6 @@ public class AxolotlController extends MobEntityController {
return NMSBoundingBox.makeBB(npc, super.makeBoundingBox());
}
@Override
protected Brain<?> makeBrain(Dynamic<?> dynamic) {
if (npc == null || npc.useMinecraftAI())
return super.makeBrain(dynamic);
return brainProvider().makeBrain(dynamic);
}
@Override
public InteractionResult mobInteract(Player entityhuman, InteractionHand enumhand) {
if (npc == null || !npc.isProtected())
@ -224,9 +213,13 @@ public class AxolotlController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -208,9 +208,13 @@ public class DolphinController extends MobEntityController {
NMSImpl.updateMinecraftAIState(npc, this);
if (npc.useMinecraftAI() && this.moveControl != this.oldMoveController) {
this.moveControl = this.oldMoveController;
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() * 10);
}
if (!npc.useMinecraftAI() && this.moveControl == this.oldMoveController) {
this.moveControl = new MoveControl(this);
this.getAttribute(Attributes.MOVEMENT_SPEED)
.setBaseValue(this.getAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 10);
}
npc.update();
}

View File

@ -2316,9 +2316,9 @@ public class NMSImpl implements NMSBridge {
}
public static boolean moveFish(NPC npc, Mob handle, Vec3 vec3d) {
if (npc == null)
if (npc == null || npc.useMinecraftAI())
return false;
if (!npc.useMinecraftAI() && handle.isInWater() && !npc.getNavigator().isNavigating()) {
if (handle.isInWater() && !npc.getNavigator().isNavigating()) {
handle.moveRelative(handle instanceof Dolphin || handle instanceof Axolotl ? handle.getSpeed()
: handle instanceof Turtle ? 0.1F : 0.01F, vec3d);
handle.move(MoverType.SELF, handle.getDeltaMovement());