Disable milking protected NPC cows

This commit is contained in:
fullwall 2020-05-09 22:15:22 +08:00
parent aa0752f7a2
commit 10cea99af1
16 changed files with 264 additions and 52 deletions

View File

@ -288,8 +288,9 @@ public class EventListen implements Listener {
Bukkit.getPluginManager().callEvent(new NPCDeathEvent(npc, event));
npc.despawn(DespawnReason.DEATH);
if (npc.data().get(NPC.RESPAWN_DELAY_METADATA, -1) >= 0) {
int delay = npc.data().get(NPC.RESPAWN_DELAY_METADATA, -1);
if (delay < 0)
return;
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
@ -299,7 +300,6 @@ public class EventListen implements Listener {
}
}, delay + 2);
}
}
@EventHandler
public void onEntityPortal(EntityPortalEvent event) {
@ -426,8 +426,7 @@ public class EventListen implements Listener {
if (team.getSize() == 1) {
Util.sendTeamPacketToOnlinePlayers(team, 1);
team.unregister();
}
else {
} else {
team.removePlayer(player);
}
}

View File

@ -139,10 +139,15 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
* @return whether the mount was successful
*/
public boolean mount(Player toMount) {
boolean found = NMS.getPassengers(npc.getEntity()).size() == 0;
for (Entity passenger : NMS.getPassengers(npc.getEntity())) {
List<Entity> passengers = NMS.getPassengers(npc.getEntity());
if (passengers.size() == 0) {
return false;
}
boolean found = false;
for (Entity passenger : passengers) {
if (passenger != null && passenger == toMount) {
found = true;
break;
}
}
if (!found) {

View File

@ -16,7 +16,11 @@ import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.EntityCow;
import net.minecraft.server.v1_10_R1.EntityHuman;
import net.minecraft.server.v1_10_R1.EnumHand;
import net.minecraft.server.v1_10_R1.IBlockData;
import net.minecraft.server.v1_10_R1.ItemStack;
import net.minecraft.server.v1_10_R1.Items;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.SoundEffect;
import net.minecraft.server.v1_10_R1.World;
@ -79,6 +83,17 @@ public class CowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand, itemstack);
if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild
&& !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand, itemstack);
}
@Override
protected SoundEffect bV() {
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);

View File

@ -15,8 +15,12 @@ import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.EntityHuman;
import net.minecraft.server.v1_10_R1.EntityMushroomCow;
import net.minecraft.server.v1_10_R1.EnumHand;
import net.minecraft.server.v1_10_R1.IBlockData;
import net.minecraft.server.v1_10_R1.ItemStack;
import net.minecraft.server.v1_10_R1.Items;
import net.minecraft.server.v1_10_R1.NBTTagCompound;
import net.minecraft.server.v1_10_R1.SoundEffect;
import net.minecraft.server.v1_10_R1.World;
@ -65,6 +69,17 @@ public class MushroomCowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand, itemstack);
if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild
&& !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand, itemstack);
}
@Override
protected SoundEffect bV() {
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);

View File

@ -16,7 +16,11 @@ import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.EntityCow;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.EnumHand;
import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.ItemStack;
import net.minecraft.server.v1_11_R1.Items;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
import net.minecraft.server.v1_11_R1.SoundEffect;
import net.minecraft.server.v1_11_R1.World;
@ -79,6 +83,17 @@ public class CowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
protected SoundEffect bW() {
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.DEATH_SOUND_METADATA);

View File

@ -15,8 +15,12 @@ import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.EntityMushroomCow;
import net.minecraft.server.v1_11_R1.EnumHand;
import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.ItemStack;
import net.minecraft.server.v1_11_R1.Items;
import net.minecraft.server.v1_11_R1.NBTTagCompound;
import net.minecraft.server.v1_11_R1.SoundEffect;
import net.minecraft.server.v1_11_R1.World;
@ -65,6 +69,17 @@ public class MushroomCowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
protected SoundEffect bW() {
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.DEATH_SOUND_METADATA);

View File

@ -17,7 +17,11 @@ import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityCow;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.EnumHand;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.Items;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.SoundEffect;
import net.minecraft.server.v1_12_R1.World;
@ -80,6 +84,17 @@ public class CowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
public void a(float f, float f1, float f2) {
if (npc == null || !npc.isFlyable()) {

View File

@ -16,8 +16,12 @@ import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.EntityMushroomCow;
import net.minecraft.server.v1_12_R1.EnumHand;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.Items;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.SoundEffect;
import net.minecraft.server.v1_12_R1.World;
@ -66,6 +70,17 @@ public class MushroomCowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
public void a(float f, float f1, float f2) {
if (npc == null || !npc.isFlyable()) {

View File

@ -17,7 +17,11 @@ import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_13_R2.BlockPosition;
import net.minecraft.server.v1_13_R2.DamageSource;
import net.minecraft.server.v1_13_R2.EntityCow;
import net.minecraft.server.v1_13_R2.EntityHuman;
import net.minecraft.server.v1_13_R2.EnumHand;
import net.minecraft.server.v1_13_R2.IBlockData;
import net.minecraft.server.v1_13_R2.ItemStack;
import net.minecraft.server.v1_13_R2.Items;
import net.minecraft.server.v1_13_R2.NBTTagCompound;
import net.minecraft.server.v1_13_R2.SoundEffect;
import net.minecraft.server.v1_13_R2.World;
@ -80,6 +84,17 @@ public class CowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
public void a(float f, float f1, float f2) {
if (npc == null || !npc.isFlyable()) {
@ -90,8 +105,10 @@ public class CowController extends MobEntityController {
}
@Override
protected SoundEffect cs() {
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
public void c(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
super.c(f, f1);
}
}
@Override
@ -104,6 +121,11 @@ public class CowController extends MobEntityController {
}
}
@Override
protected SoundEffect cs() {
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
}
@Override
protected SoundEffect d(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
@ -115,10 +137,8 @@ public class CowController extends MobEntityController {
}
@Override
public void c(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
super.c(f, f1);
}
protected SoundEffect D() {
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
}
@Override
@ -156,11 +176,6 @@ public class CowController extends MobEntityController {
// cancelled.
}
@Override
protected SoundEffect D() {
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
}
@Override
public CraftEntity getBukkitEntity() {
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
@ -174,6 +189,13 @@ public class CowController extends MobEntityController {
return npc;
}
@Override
protected void I() {
if (npc == null) {
super.I();
}
}
@Override
public boolean isLeashed() {
if (npc == null)
@ -187,13 +209,6 @@ public class CowController extends MobEntityController {
return false; // shouldLeash
}
@Override
protected void I() {
if (npc == null) {
super.I();
}
}
@Override
public void mobTick() {
super.mobTick();

View File

@ -16,8 +16,12 @@ import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_13_R2.BlockPosition;
import net.minecraft.server.v1_13_R2.DamageSource;
import net.minecraft.server.v1_13_R2.EntityHuman;
import net.minecraft.server.v1_13_R2.EntityMushroomCow;
import net.minecraft.server.v1_13_R2.EnumHand;
import net.minecraft.server.v1_13_R2.IBlockData;
import net.minecraft.server.v1_13_R2.ItemStack;
import net.minecraft.server.v1_13_R2.Items;
import net.minecraft.server.v1_13_R2.NBTTagCompound;
import net.minecraft.server.v1_13_R2.SoundEffect;
import net.minecraft.server.v1_13_R2.World;
@ -66,6 +70,17 @@ public class MushroomCowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
public void a(float f, float f1, float f2) {
if (npc == null || !npc.isFlyable()) {
@ -76,8 +91,10 @@ public class MushroomCowController extends MobEntityController {
}
@Override
protected SoundEffect cs() {
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
public void c(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
super.c(f, f1);
}
}
@Override
@ -89,6 +106,11 @@ public class MushroomCowController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
protected SoundEffect cs() {
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
}
@Override
protected SoundEffect d(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
@ -100,10 +122,8 @@ public class MushroomCowController extends MobEntityController {
}
@Override
public void c(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
super.c(f, f1);
}
protected SoundEffect D() {
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
}
@Override
@ -141,11 +161,6 @@ public class MushroomCowController extends MobEntityController {
// cancelled.
}
@Override
protected SoundEffect D() {
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
}
@Override
public CraftEntity getBukkitEntity() {
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
@ -159,6 +174,13 @@ public class MushroomCowController extends MobEntityController {
return npc;
}
@Override
protected void I() {
if (npc == null) {
super.I();
}
}
@Override
public boolean isLeashed() {
if (npc == null)
@ -172,13 +194,6 @@ public class MushroomCowController extends MobEntityController {
return false; // shouldLeash
}
@Override
protected void I() {
if (npc == null) {
super.I();
}
}
@Override
public void mobTick() {
super.mobTick();

View File

@ -18,8 +18,12 @@ import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.DamageSource;
import net.minecraft.server.v1_14_R1.DataWatcherObject;
import net.minecraft.server.v1_14_R1.EntityCow;
import net.minecraft.server.v1_14_R1.EntityHuman;
import net.minecraft.server.v1_14_R1.EntityTypes;
import net.minecraft.server.v1_14_R1.EnumHand;
import net.minecraft.server.v1_14_R1.IBlockData;
import net.minecraft.server.v1_14_R1.ItemStack;
import net.minecraft.server.v1_14_R1.Items;
import net.minecraft.server.v1_14_R1.NBTTagCompound;
import net.minecraft.server.v1_14_R1.SoundEffect;
import net.minecraft.server.v1_14_R1.Vec3D;
@ -82,6 +86,17 @@ public class CowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
public void b(float f, float f1) {
if (npc == null || !npc.isFlyable()) {

View File

@ -17,9 +17,13 @@ import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.DamageSource;
import net.minecraft.server.v1_14_R1.DataWatcherObject;
import net.minecraft.server.v1_14_R1.EntityHuman;
import net.minecraft.server.v1_14_R1.EntityMushroomCow;
import net.minecraft.server.v1_14_R1.EntityTypes;
import net.minecraft.server.v1_14_R1.EnumHand;
import net.minecraft.server.v1_14_R1.IBlockData;
import net.minecraft.server.v1_14_R1.ItemStack;
import net.minecraft.server.v1_14_R1.Items;
import net.minecraft.server.v1_14_R1.NBTTagCompound;
import net.minecraft.server.v1_14_R1.SoundEffect;
import net.minecraft.server.v1_14_R1.Vec3D;
@ -38,7 +42,6 @@ public class MushroomCowController extends MobEntityController {
public static class EntityMushroomCowNPC extends EntityMushroomCow implements NPCHolder {
boolean calledNMSHeight = false;
private final CitizensNPC npc;
public EntityMushroomCowNPC(EntityTypes<? extends EntityMushroomCow> types, World world) {
@ -71,6 +74,17 @@ public class MushroomCowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
public void b(float f, float f1) {
if (npc == null || !npc.isFlyable()) {

View File

@ -18,8 +18,12 @@ import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.DamageSource;
import net.minecraft.server.v1_15_R1.DataWatcherObject;
import net.minecraft.server.v1_15_R1.EntityCow;
import net.minecraft.server.v1_15_R1.EntityHuman;
import net.minecraft.server.v1_15_R1.EntityTypes;
import net.minecraft.server.v1_15_R1.EnumHand;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.ItemStack;
import net.minecraft.server.v1_15_R1.Items;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
import net.minecraft.server.v1_15_R1.SoundEffect;
import net.minecraft.server.v1_15_R1.Vec3D;
@ -82,6 +86,17 @@ public class CowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
public boolean b(float f, float f1) {
if (npc == null || !npc.isFlyable()) {

View File

@ -17,9 +17,13 @@ import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.DamageSource;
import net.minecraft.server.v1_15_R1.DataWatcherObject;
import net.minecraft.server.v1_15_R1.EntityHuman;
import net.minecraft.server.v1_15_R1.EntityMushroomCow;
import net.minecraft.server.v1_15_R1.EntityTypes;
import net.minecraft.server.v1_15_R1.EnumHand;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.ItemStack;
import net.minecraft.server.v1_15_R1.Items;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
import net.minecraft.server.v1_15_R1.SoundEffect;
import net.minecraft.server.v1_15_R1.Vec3D;
@ -38,7 +42,6 @@ public class MushroomCowController extends MobEntityController {
public static class EntityMushroomCowNPC extends EntityMushroomCow implements NPCHolder {
boolean calledNMSHeight = false;
private final CitizensNPC npc;
public EntityMushroomCowNPC(EntityTypes<? extends EntityMushroomCow> types, World world) {
@ -71,6 +74,17 @@ public class MushroomCowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman, enumhand);
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
return false;
}
return super.a(entityhuman, enumhand);
}
@Override
public boolean b(float f, float f1) {
if (npc == null || !npc.isFlyable()) {

View File

@ -17,6 +17,9 @@ import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.EntityCow;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.Items;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World;
@ -78,6 +81,18 @@ public class CowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman);
ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild
&& !this.isBaby()) {
return false;
}
return super.a(entityhuman);
}
@Override
protected String bo() {
return NMSImpl.getSoundEffect(npc, super.bo(), NPC.HURT_SOUND_METADATA);

View File

@ -16,7 +16,10 @@ import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.EntityMushroomCow;
import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.Items;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World;
@ -64,6 +67,18 @@ public class MushroomCowController extends MobEntityController {
}
}
@Override
public boolean a(EntityHuman entityhuman) {
if (npc == null || !npc.isProtected())
return super.a(entityhuman);
ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild
&& !this.isBaby()) {
return false;
}
return super.a(entityhuman);
}
@Override
protected String bo() {
return NMSImpl.getSoundEffect(npc, super.bo(), NPC.HURT_SOUND_METADATA);