org.bukkit.entity.Pig Java Examples

The following examples show how to use org.bukkit.entity.Pig. 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: EntityPortalEventListenerTest.java    From PerWorldInventory with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void shouldTeleportBecauseNotItem() {
    // given
    Pig entity = mock(Pig.class);
    World world = mock(World.class);
    Location from = new Location(world, 1, 2, 3);
    World worldNether = mock(World.class);
    Location to = new Location(worldNether, 1, 2, 3);
    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(false));
}
 
Example #2
Source File: EntityPortalEventListenerTest.java    From PerWorldInventory with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void shouldTeleportBecauseNotItem() {
    // given
    Pig entity = mock(Pig.class);
    World world = mock(World.class);
    Location from = new Location(world, 1, 2, 3);
    World worldNether = mock(World.class);
    Location to = new Location(worldNether, 1, 2, 3);
    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(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: PigZapEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Pig getEntity() {
    return (Pig) entity;
}
 
Example #5
Source File: PigData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected boolean init(final @Nullable Class<? extends Pig> c, final @Nullable Pig e) {
	saddled = e == null ? 0 : e.hasSaddle() ? 1 : -1;
	return true;
}
 
Example #6
Source File: PigData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void set(final Pig entity) {
	if (saddled != 0)
		entity.setSaddle(saddled == 1);
}
 
Example #7
Source File: PigData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected boolean match(final Pig entity) {
	return saddled == 0 || entity.hasSaddle() == (saddled == 1);
}
 
Example #8
Source File: PigData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<? extends Pig> getType() {
	return Pig.class;
}
 
Example #9
Source File: EntityPigPet.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setSaddled(boolean flag) {
    ((Pig) getBukkitEntity()).setSaddle(flag);
}
 
Example #10
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 #11
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));
}