org.bukkit.entity.Cow#org.bukkit.entity.PigZombie源码实例Demo

下面列出了org.bukkit.entity.Cow#org.bukkit.entity.PigZombie 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: uSkyBlock   文件: NetherTerraFormEvents.java
/**
 * 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
            }
        }
    }
}
 
源代码2 项目: ce   文件: BeastmastersBow.java
@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;
	}
 
源代码3 项目: Kettle   文件: PigZapEvent.java
public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
    super(pig);
    this.bolt = bolt;
    this.pigzombie = pigzombie;
}
 
源代码4 项目: Thermos   文件: CraftEventFactory.java
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;
}
 
源代码5 项目: uSkyBlock   文件: EntityUtilTest.java
@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));
}
 
源代码6 项目: Kettle   文件: PigZapEvent.java
/**
 * Gets the zombie pig that will replace the pig, provided the event is
 * not cancelled first.
 *
 * @return resulting entity
 */
public PigZombie getPigZombie() {
    return pigzombie;
}
 
 方法所在类