org.bukkit.entity.PigZombie Java Examples

The following examples show how to use org.bukkit.entity.PigZombie. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NetherTerraFormEvents.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Comes AFTER the SpawnEvents{@link #onCreatureSpawn(CreatureSpawnEvent)} - so cancelled will have effect
 * @param e
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent e) {
    if (!spawnEnabled || e.getSpawnReason() != CreatureSpawnEvent.SpawnReason.NATURAL) {
        return;
    }
    if (!plugin.getWorldManager().isSkyNether(e.getLocation().getWorld())) {
        return;
    }
    if (e.getLocation().getBlockY() > plugin.getWorldManager().getNetherWorld().getMaxHeight()) {
        // Block spawning above nether...
        e.setCancelled(true);
        return;
    }
    if (e.getEntity() instanceof PigZombie) {
        Block block = e.getLocation().getBlock().getRelative(BlockFace.DOWN);
        if (isNetherFortressWalkway(block)) {
            e.setCancelled(true);
            double p = RND.nextDouble();
            if (p <= chanceWither && block.getRelative(BlockFace.UP, 3).getType() == Material.AIR) {
                WitherSkeleton mob = (WitherSkeleton) e.getLocation().getWorld().spawnEntity(
                    e.getLocation(), EntityType.WITHER_SKELETON);
                mob.getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD, 1));
            } else if (p <= chanceWither+chanceBlaze) {
                e.getLocation().getWorld().spawnEntity(e.getLocation(), EntityType.BLAZE);
            } else if (p <= chanceWither+chanceBlaze+chanceSkeleton) {
                e.getLocation().getWorld().spawnEntity(e.getLocation(), EntityType.SKELETON);
            } else {
                e.setCancelled(false); // Spawn PigZombie
            }
        }
    }
}
 
Example #2
Source File: BeastmastersBow.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
	public boolean effect(Event event, Player player) {
//		  List<String> lore = e.getBow().getItemMeta().getLore();
//		  if(!lore.contains(placeHolder)) {
//			  for(int i = descriptionSize; i != 0; i--)
//				  lore.remove(i);
//			  e.getProjectile().setMetadata("ce." + this.getOriginalName(), new FixedMetadataValue(main, writeType(lore)));
//			  player.setMetadata("ce.CanUnleashBeasts", null);
//		  } else
//			  e.getProjectile().setMetadata("ce." + this.getOriginalName(), null);
		  if(event instanceof EntityDamageByEntityEvent) {
		  EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
		  if(e.getDamager() != player)
			  return false;
		  Entity ent = e.getEntity();
		  Location loc = ent.getLocation();
		  World w = ent.getWorld();
			if(ent instanceof Silverfish || ent instanceof EnderDragon || ent instanceof Spider || ent instanceof Slime || ent instanceof Ghast || ent instanceof MagmaCube || ent instanceof CaveSpider || (ent instanceof Wolf && ((Wolf) ent).isAngry()) || ent instanceof PigZombie) {
					e.setDamage(e.getDamage()*DamageMultiplication);
					w.playEffect(loc, Effect.SMOKE, 50);
					w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 50);
					EffectManager.playSound(loc, "BLOCK_PISTON_RETRACT", 1.3f, 3f);
				return true;
			} else if (ent instanceof Player) {
				for(int i = 0; i < MaximumMobs; i++) {
					if(rand.nextInt(100) < MobAppearanceChance) {
						w.spawnEntity(loc, rand.nextInt(2) == 1 ? EntityType.SPIDER : EntityType.SLIME);
						w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 30);
						w.playEffect(loc, Effect.SMOKE, 30);
						EffectManager.playSound(loc, "BLOCK_ANVIL_BREAK", 0.3f, 0.1f);
					}
				}
			}
		}
		  return false;
	}
 
Example #3
Source File: PigZapEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
    super(pig);
    this.bolt = bolt;
    this.pigzombie = pigzombie;
}
 
Example #4
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public static PigZapEvent callPigZapEvent(net.minecraft.entity.Entity pig, net.minecraft.entity.Entity lightning, net.minecraft.entity.Entity pigzombie) {
    PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
    pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #5
Source File: EntityUtilTest.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void testGetEntity() {
    List<Entity> testList = new ArrayList<>();

    ArmorStand fakeArmorStand = mock(ArmorStand.class);
    Cow fakeCow = mock(Cow.class);
    Evoker fakeEvoker = mock(Evoker.class);
    Guardian fakeGuardian = mock(Guardian.class);
    Pig fakePig = mock(Pig.class);
    PigZombie fakePigZombie = mock(PigZombie.class);
    Pillager fakePillager = mock(Pillager.class);
    Sheep fakeSheep = mock(Sheep.class);
    Skeleton fakeSkeleton = mock(Skeleton.class);
    Turtle fakeTurtle = mock(Turtle.class);
    Villager fakeVillager = mock(Villager.class);
    WanderingTrader fakeWanderingTrader = mock(WanderingTrader.class);

    testList.add(fakeArmorStand);
    testList.add(fakeCow);
    testList.add(fakeEvoker);
    testList.add(fakeGuardian);
    testList.add(fakePig);
    testList.add(fakePigZombie);
    testList.add(fakePillager);
    testList.add(fakeSheep);
    testList.add(fakeSkeleton);
    testList.add(fakeTurtle);
    testList.add(fakeVillager);
    testList.add(fakeWanderingTrader);

    List<Sheep> sheepList = EntityUtil.getEntity(testList, Sheep.class);
    assertEquals(1, sheepList.size());
    assertEquals(fakeSheep, sheepList.get(0));

    List<Animals> animalsList = EntityUtil.getAnimals(testList);
    assertEquals(4, animalsList.size());
    assertTrue(animalsList.contains(fakeCow));
    assertTrue(animalsList.contains(fakePig));
    assertTrue(animalsList.contains(fakeSheep));
    assertTrue(animalsList.contains(fakeTurtle));

    List<Monster> monsterList = EntityUtil.getMonsters(testList);
    assertEquals(5, monsterList.size());
    assertTrue(monsterList.contains(fakeEvoker));
    assertTrue(monsterList.contains(fakeGuardian));
    assertTrue(monsterList.contains(fakePigZombie));
    assertTrue(monsterList.contains(fakePillager));
    assertTrue(monsterList.contains(fakeSkeleton));

    List<NPC> npcList = EntityUtil.getNPCs(testList);
    assertEquals(2, npcList.size());
    assertTrue(npcList.contains(fakeVillager));
    assertTrue(npcList.contains(fakeWanderingTrader));
}
 
Example #6
Source File: PigZapEvent.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the zombie pig that will replace the pig, provided the event is
 * not cancelled first.
 *
 * @return resulting entity
 */
public PigZombie getPigZombie() {
    return pigzombie;
}