Block gold ingot interaction with piglins for protected npcs

This commit is contained in:
fullwall 2023-11-27 22:51:16 +08:00
parent 9764695899
commit 543baf7fb8
5 changed files with 75 additions and 0 deletions

View File

@ -20,12 +20,17 @@ import net.minecraft.server.v1_16_R3.BlockPosition;
import net.minecraft.server.v1_16_R3.DamageSource;
import net.minecraft.server.v1_16_R3.Entity;
import net.minecraft.server.v1_16_R3.EntityBoat;
import net.minecraft.server.v1_16_R3.EntityHuman;
import net.minecraft.server.v1_16_R3.EntityMinecartAbstract;
import net.minecraft.server.v1_16_R3.EntityPiglin;
import net.minecraft.server.v1_16_R3.EntityTypes;
import net.minecraft.server.v1_16_R3.EnumHand;
import net.minecraft.server.v1_16_R3.EnumInteractionResult;
import net.minecraft.server.v1_16_R3.EnumPistonReaction;
import net.minecraft.server.v1_16_R3.FluidType;
import net.minecraft.server.v1_16_R3.IBlockData;
import net.minecraft.server.v1_16_R3.ItemStack;
import net.minecraft.server.v1_16_R3.Items;
import net.minecraft.server.v1_16_R3.NBTTagCompound;
import net.minecraft.server.v1_16_R3.SoundEffect;
import net.minecraft.server.v1_16_R3.Tag;
@ -84,6 +89,16 @@ public class PiglinController extends MobEntityController {
return res;
}
@Override
public EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.b(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.GOLD_INGOT)
return EnumInteractionResult.FAIL;
return super.b(entityhuman, enumhand);
}
@Override
public boolean b(float f, float f1) {
if (npc == null || !npc.isFlyable())

View File

@ -18,12 +18,17 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.Tag;
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.monster.piglin.Piglin;
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.level.material.Fluid;
@ -158,6 +163,16 @@ public class PiglinController extends MobEntityController {
return NMSBoundingBox.makeBB(npc, super.makeBoundingBox());
}
@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.is(Items.GOLD_INGOT))
return InteractionResult.FAIL;
return super.mobInteract(entityhuman, enumhand);
}
@Override
public boolean onClimbable() {
if (npc == null || !npc.isFlyable())

View File

@ -19,12 +19,17 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.TagKey;
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.monster.piglin.Piglin;
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.level.material.Fluid;
@ -159,6 +164,16 @@ public class PiglinController extends MobEntityController {
return NMSBoundingBox.makeBB(npc, super.makeBoundingBox());
}
@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.is(Items.GOLD_INGOT))
return InteractionResult.FAIL;
return super.mobInteract(entityhuman, enumhand);
}
@Override
public boolean onClimbable() {
if (npc == null || !npc.isFlyable())

View File

@ -20,12 +20,17 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.TagKey;
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.monster.piglin.Piglin;
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.level.material.Fluid;
@ -160,6 +165,16 @@ public class PiglinController extends MobEntityController {
return NMSBoundingBox.makeBB(npc, super.makeBoundingBox());
}
@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.is(Items.GOLD_INGOT))
return InteractionResult.FAIL;
return super.mobInteract(entityhuman, enumhand);
}
@Override
public boolean onClimbable() {
if (npc == null || !npc.isFlyable())

View File

@ -19,12 +19,17 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.TagKey;
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.monster.piglin.Piglin;
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.level.material.Fluid;
@ -159,6 +164,16 @@ public class PiglinController extends MobEntityController {
return NMSBoundingBox.makeBB(npc, super.makeBoundingBox());
}
@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.is(Items.GOLD_INGOT))
return InteractionResult.FAIL;
return super.mobInteract(entityhuman, enumhand);
}
@Override
public boolean onClimbable() {
if (npc == null || !npc.isFlyable())