use of org.bukkit.entity.MushroomCow in project modules-extra by CubeEngine.
the class ListenerPlayerEntity method onPlayerInteractEntityEvent.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
if (!(event.getRightClicked() instanceof LivingEntity)) {
return;
}
Player player = event.getPlayer();
Entity entity = event.getRightClicked();
ActionPlayerEntity action;
if (player.getItemInHand().getType() == COAL && entity instanceof PoweredMinecart) {
action = this.newAction(UseFurnaceMinecart.class, entity.getWorld());
} else if (player.getItemInHand().getType() == INK_SACK && entity instanceof Sheep || entity instanceof Wolf) {
action = this.newAction(EntityDye.class, entity.getWorld());
if (action != null) {
((EntityDye) action).setColor(((Dye) player.getItemInHand().getData()).getColor());
}
} else if (player.getItemInHand().getType().equals(BOWL) && entity instanceof MushroomCow) {
action = this.newAction(EntityFillSoup.class, entity.getWorld());
} else {
return;
}
if (action != null) {
action.setEntity(entity);
action.setPlayer(player);
action.setLocation(entity.getLocation());
this.logAction(action);
}
}
use of org.bukkit.entity.MushroomCow in project StackMob-2 by Nathat23.
the class ShearEvent method onSheepShear.
@EventHandler
public void onSheepShear(PlayerShearEntityEvent event) {
if (!event.getEntity().hasMetadata(GlobalValues.METATAG)) {
return;
}
if (event.getEntity().getMetadata(GlobalValues.METATAG).get(0).asInt() <= 1) {
return;
}
Entity oldEntity = event.getEntity();
int stackSize = event.getEntity().getMetadata(GlobalValues.METATAG).get(0).asInt();
if (oldEntity instanceof Sheep) {
Sheep oldSheep = (Sheep) oldEntity;
if (sm.config.getCustomConfig().getBoolean("multiply.sheep-wool")) {
Wool wool = new Wool(oldSheep.getColor());
sm.dropTools.dropDrops(wool.toItemStack(1), sm.dropTools.calculateAmount(stackSize), oldEntity.getLocation());
ItemStack item = event.getPlayer().getItemInHand();
item.setDurability((short) (item.getDurability() + stackSize));
event.getPlayer().setItemInHand(item);
} else if (sm.config.getCustomConfig().getBoolean("divide-on.sheep-shear")) {
Sheep newEntity = (Sheep) sm.tools.duplicate(oldEntity, true);
newEntity.setSheared(false);
newEntity.setMetadata(GlobalValues.METATAG, new FixedMetadataValue(sm, stackSize - 1));
newEntity.setMetadata(GlobalValues.NO_SPAWN_STACK, new FixedMetadataValue(sm, true));
oldEntity.setMetadata(GlobalValues.METATAG, new FixedMetadataValue(sm, 1));
oldEntity.setCustomName(null);
}
}
if (oldEntity instanceof MushroomCow) {
if (sm.config.getCustomConfig().getBoolean("multiply.mooshroom-mushrooms")) {
ItemStack mushrooms = new ItemStack(Material.RED_MUSHROOM, 1);
sm.dropTools.dropDrops(mushrooms, (stackSize - 1) * 5, oldEntity.getLocation());
// SpawnEvent cow for the rest of the cows that where sheared.
Entity cow = oldEntity.getWorld().spawnEntity(oldEntity.getLocation(), EntityType.COW);
cow.setMetadata(GlobalValues.METATAG, new FixedMetadataValue(sm, stackSize - 1));
cow.setMetadata(GlobalValues.NO_SPAWN_STACK, new FixedMetadataValue(sm, true));
ItemStack item = event.getPlayer().getItemInHand();
item.setDurability((short) (item.getDurability() + stackSize));
event.getPlayer().setItemInHand(item);
} else if (sm.config.getCustomConfig().getBoolean("divide-on.mooshroom-shear")) {
Entity mushroomCow = oldEntity.getWorld().spawnEntity(oldEntity.getLocation(), EntityType.MUSHROOM_COW);
mushroomCow.setMetadata(GlobalValues.METATAG, new FixedMetadataValue(sm, stackSize - 1));
mushroomCow.setMetadata(GlobalValues.NO_SPAWN_STACK, new FixedMetadataValue(sm, true));
oldEntity.setCustomName(null);
}
}
}
use of org.bukkit.entity.MushroomCow in project EliteMobs by MagmaGuy.
the class MushroomCowHandler method onShear.
@EventHandler
public void onShear(PlayerShearEntityEvent event) {
if (event.getEntity() instanceof MushroomCow && EntityTracker.isSuperMob(event.getEntity())) {
MushroomCow mushroomCow = (MushroomCow) event.getEntity();
ItemStack mushroomStack = new ItemStack(RED_MUSHROOM, 5);
for (int i = 0; i < 50; i++) {
mushroomCow.getWorld().dropItem(mushroomCow.getLocation(), mushroomStack).setVelocity(ItemDropVelocity.ItemDropVelocity());
}
}
}
use of org.bukkit.entity.MushroomCow in project EliteMobs by MagmaGuy.
the class MushroomCowHandler method superDrops.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void superDrops(EntityDamageEvent event) {
if (event.getFinalDamage() < 1)
return;
if (event.getEntity() instanceof MushroomCow && EntityTracker.isSuperMob(event.getEntity())) {
Random random = new Random();
MushroomCow mushroomCow = (MushroomCow) event.getEntity();
double damage = event.getFinalDamage();
// health is hardcoded here, maybe change it at some point?
double dropChance = damage / 10;
double dropRandomizer = random.nextDouble();
// this rounds down
int dropMinAmount = (int) dropChance;
ItemStack beefStack = new ItemStack(BEEF, (random.nextInt(3) + 1));
// leather can drop 0, meaning that it could create visual artifacts. Have to filter that out.
ItemStack leatherStack = new ItemStack(LEATHER, (random.nextInt(2)));
for (int i = 0; i < dropMinAmount; i++) {
mushroomCow.getWorld().dropItem(mushroomCow.getLocation(), beefStack).setVelocity(ItemDropVelocity.ItemDropVelocity());
ExperienceOrb xpDrop = mushroomCow.getWorld().spawn(mushroomCow.getLocation(), ExperienceOrb.class);
xpDrop.setExperience(random.nextInt(3) + 1);
if (leatherStack.getAmount() != 0) {
mushroomCow.getWorld().dropItem(mushroomCow.getLocation(), leatherStack).setVelocity(ItemDropVelocity.ItemDropVelocity());
}
}
if (dropChance > dropRandomizer) {
mushroomCow.getWorld().dropItem(mushroomCow.getLocation(), beefStack).setVelocity(ItemDropVelocity.ItemDropVelocity());
ExperienceOrb xpDrop = mushroomCow.getWorld().spawn(mushroomCow.getLocation(), ExperienceOrb.class);
xpDrop.setExperience(random.nextInt(3) + 1);
if (leatherStack.getAmount() != 0) {
mushroomCow.getWorld().dropItem(mushroomCow.getLocation(), leatherStack).setVelocity(ItemDropVelocity.ItemDropVelocity());
}
}
}
}
Aggregations