Block minecraft warden/allay behaviours

This commit is contained in:
fullwall 2022-06-15 22:20:08 +08:00
parent 6a15bc2d5a
commit 849561337b
2 changed files with 17 additions and 1 deletions

View File

@ -17,10 +17,13 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
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.animal.allay.Allay;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.level.Level;
@ -151,6 +154,13 @@ public class AllayController extends MobEntityController {
return false; // shouldLeash
}
@Override
protected InteractionResult mobInteract(Player var0, InteractionHand var1) {
if (npc != null && npc.isProtected())
return InteractionResult.FAIL;
return super.mobInteract(var0, var1);
}
@Override
public boolean onClimbable() {
if (npc == null || !npc.isFlyable()) {

View File

@ -84,10 +84,16 @@ public class WardenController extends MobEntityController {
@Override
public void customServerAiStep() {
super.customServerAiStep();
if (npc != null) {
if (npc.useMinecraftAI()) {
super.customServerAiStep();
} else {
NMSImpl.updateAI(this);
}
NMSImpl.updateMinecraftAIState(npc, this);
npc.update();
} else {
super.customServerAiStep();
}
}