All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.EntityMushroomCow Maven / Gradle / Ivy

package net.minecraft.server;

import org.bukkit.entity.MushroomCow;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.jetbrains.annotations.NotNull;

public class EntityMushroomCow extends EntityCow {

  @NotNull
  @Override
  public MushroomCow getEntityBukkit() {
    return (MushroomCow) super.getEntityBukkit();
  }

  public EntityMushroomCow(World world) {
    super(world);
    this.setSize(0.9F, 1.3F);
    this.bn = Blocks.MYCELIUM;
  }

  public boolean interact(EntityHuman player) {
    ItemStack itemstack = player.inventory.getItemInHand();

    if (itemstack != null && itemstack.getItem() == Items.BOWL && this.getAge() >= 0) {
      if (itemstack.count == 1) {
        player.inventory.setItem(player.inventory.itemInHandIndex, new ItemStack(Items.MUSHROOM_STEW));
        return true;
      }

      if (player.inventory.pickup(new ItemStack(Items.MUSHROOM_STEW)) && !player.abilities.canInstantlyBuild) {
        player.inventory.splitStack(player.inventory.itemInHandIndex, 1);
        return true;
      }
    }

    if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
      // CraftBukkit start
      PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) player.getBukkitEntity(), this.getBukkitEntity());
      this.world.getServer().getPluginManager().callEvent(event);

      if (event.isCancelled()) {
        return false;
      }
      // CraftBukkit end
      this.die();
      this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
      if (!this.world.isClientSide) {
        EntityCow entitycow = new EntityCow(this.world);

        entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
        entitycow.setHealth(this.getHealth());
        entitycow.renderYawOffset = this.renderYawOffset;
        if (this.hasCustomName()) {
          entitycow.setCustomName(this.getCustomName());
        }

        this.world.addEntity(entitycow);

        for (int i = 0; i < 5; ++i) {
          this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM)));
        }

        itemstack.damageItem(1, player);
        this.playSound("mob.sheep.shear", 1.0F, 1.0F);
      }

      return true;
    } else {
      return super.interact(player);
    }
  }

  public EntityMushroomCow c(EntityAgeable entityageable) {
    return new EntityMushroomCow(this.world);
  }

  public EntityCow b(EntityAgeable entityageable) {
    return this.c(entityageable);
  }

  public EntityAgeable createChild(EntityAgeable entityageable) {
    return this.c(entityageable);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy