Skip to content

Commit

Permalink
Protect axolotls from buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 11, 2021
1 parent 53e2b50 commit d515c6b
Showing 1 changed file with 16 additions and 0 deletions.
Expand Up @@ -17,15 +17,20 @@
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
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.ai.control.MoveControl;
import net.minecraft.world.entity.ai.navigation.GroundPathNavigation;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
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.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -163,6 +168,17 @@ public boolean isLeashed() {
return false; // shouldLeash
}

@Override
public InteractionResult mobInteract(Player entityhuman, InteractionHand enumhand) {
if (npc == null || !npc.isProtected())
return super.mobInteract(entityhuman, enumhand);
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.getItem() == Items.BUCKET) {
return InteractionResult.FAIL;
}
return super.mobInteract(entityhuman, enumhand);
}

@Override
public boolean onClimbable() {
if (npc == null || !npc.isFlyable()) {
Expand Down

0 comments on commit d515c6b

Please sign in to comment.