Java 类net.minecraft.entity.passive.EntityPig 实例源码

项目:DecompiledMinecraft    文件:ItemCarrotOnAStick.java   
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.isRiding() && playerIn.ridingEntity instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.ridingEntity;

        if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7)
        {
            entitypig.getAIControlledByPlayer().boostSpeed();
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.fishing_rod);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return itemstack;
            }
        }
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
项目:DecompiledMinecraft    文件:ItemSaddle.java   
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
{
    if (target instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)target;

        if (!entitypig.getSaddled() && !entitypig.isChild())
        {
            entitypig.setSaddled(true);
            entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F);
            --stack.stackSize;
        }

        return true;
    }
    else
    {
        return false;
    }
}
项目:DecompiledMinecraft    文件:ItemCarrotOnAStick.java   
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.isRiding() && playerIn.ridingEntity instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.ridingEntity;

        if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7)
        {
            entitypig.getAIControlledByPlayer().boostSpeed();
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.fishing_rod);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return itemstack;
            }
        }
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
项目:DecompiledMinecraft    文件:ItemSaddle.java   
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
{
    if (target instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)target;

        if (!entitypig.getSaddled() && !entitypig.isChild())
        {
            entitypig.setSaddled(true);
            entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F);
            --stack.stackSize;
        }

        return true;
    }
    else
    {
        return false;
    }
}
项目:BaseClient    文件:ItemCarrotOnAStick.java   
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.isRiding() && playerIn.ridingEntity instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.ridingEntity;

        if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7)
        {
            entitypig.getAIControlledByPlayer().boostSpeed();
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.fishing_rod);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return itemstack;
            }
        }
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
项目:BaseClient    文件:ItemSaddle.java   
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
{
    if (target instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)target;

        if (!entitypig.getSaddled() && !entitypig.isChild())
        {
            entitypig.setSaddled(true);
            entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F);
            --stack.stackSize;
        }

        return true;
    }
    else
    {
        return false;
    }
}
项目:BaseClient    文件:ItemCarrotOnAStick.java   
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.isRiding() && playerIn.ridingEntity instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.ridingEntity;

        if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7)
        {
            entitypig.getAIControlledByPlayer().boostSpeed();
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.fishing_rod);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return itemstack;
            }
        }
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
项目:BaseClient    文件:ItemSaddle.java   
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
{
    if (target instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)target;

        if (!entitypig.getSaddled() && !entitypig.isChild())
        {
            entitypig.setSaddled(true);
            entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F);
            --stack.stackSize;
        }

        return true;
    }
    else
    {
        return false;
    }
}
项目:connor41-etfuturum2    文件:ServerEventHandler.java   
@SubscribeEvent
public void spawnEvent(EntityJoinWorldEvent event) {
    if (event.entity instanceof EntityPig) {
        EntityPig pig = (EntityPig) event.entity;
        if (EtFuturum.enableBeetroot)
            pig.tasks.addTask(4, new EntityAITempt(pig, 1.2, ModItems.beetroot, false));
    } else if (event.entity instanceof EntityChicken) {
        EntityChicken chicken = (EntityChicken) event.entity;
        if (EtFuturum.enableBeetroot)
            chicken.tasks.addTask(3, new EntityAITempt(chicken, 1.0D, ModItems.beetroot_seeds, false));
    } else if (event.entity instanceof EntityWolf) {
        EntityWolf wolf = (EntityWolf) event.entity;
        if (EtFuturum.enableRabbit)
            wolf.targetTasks.addTask(4, new EntityAITargetNonTamed(wolf, EntityRabbit.class, 200, false));
    } else if (event.entity instanceof EntityVillager) {
        EntityVillager villager = (EntityVillager) event.entity;
        for (Object obj : villager.tasks.taskEntries) {
            EntityAITaskEntry entry = (EntityAITaskEntry) obj;
            if (entry.action instanceof EntityAIOpenDoor) {
                villager.tasks.removeTask(entry.action);
                villager.tasks.addTask(entry.priority, new EntityAIOpenCustomDoor(villager, true));
                break;
            }
        }
    }
}
项目:connor41-etfuturum2    文件:ServerEventHandler.java   
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
    ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
    if (stack == null)
        return;
    if (!(event.target instanceof EntityAnimal))
        return;

    EntityAnimal animal = (EntityAnimal) event.target;
    if (!animal.isChild()) {
        if (animal instanceof EntityPig) {
            if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
                setAnimalInLove(animal, event.entityPlayer, stack);
        } else if (animal instanceof EntityChicken)
            if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
                setAnimalInLove(animal, event.entityPlayer, stack);
    } else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
        feedBaby(animal, event.entityPlayer, stack);
}
项目:Backmemed    文件:ItemSaddle.java   
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand)
{
    if (target instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)target;

        if (!entitypig.getSaddled() && !entitypig.isChild())
        {
            entitypig.setSaddled(true);
            entitypig.world.playSound(playerIn, entitypig.posX, entitypig.posY, entitypig.posZ, SoundEvents.ENTITY_PIG_SADDLE, SoundCategory.NEUTRAL, 0.5F, 1.0F);
            stack.func_190918_g(1);
        }

        return true;
    }
    else
    {
        return false;
    }
}
项目:CustomWorldGen    文件:ItemCarrotOnAStick.java   
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (playerIn.isRiding() && playerIn.getRidingEntity() instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.getRidingEntity();

        if (itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7 && entitypig.boost())
        {
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.FISHING_ROD);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return new ActionResult(EnumActionResult.SUCCESS, itemstack);
            }

            return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
        }
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
项目:CustomWorldGen    文件:ItemSaddle.java   
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand)
{
    if (target instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)target;

        if (!entitypig.getSaddled() && !entitypig.isChild())
        {
            entitypig.setSaddled(true);
            entitypig.worldObj.playSound(playerIn, entitypig.posX, entitypig.posY, entitypig.posZ, SoundEvents.ENTITY_PIG_SADDLE, SoundCategory.NEUTRAL, 0.5F, 1.0F);
            --stack.stackSize;
        }

        return true;
    }
    else
    {
        return false;
    }
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_rotationYaw_is_readable() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint();

  mc().executeCommand("/summon minecraft:pig %s %s %s {CustomName:testpig,NoAI:1}", pos.getX(),
      pos.getY(), pos.getZ());
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; print(string.format('%.5f',p.rotationYaw))");

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  String expectedRotationYaw =
      String.format("%.5f", ((EntityPig) actEntities.get(0)).renderYawOffset);
  assertThat(act.getMessage()).isEqualTo(expectedRotationYaw);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_rotationYaw_is_writable() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint();
  float expectedRotationYaw = 45f;
  mc().executeCommand("/summon minecraft:pig %s %s %s {CustomName:testpig,NoAI:1}", pos.getX(),
      pos.getY(), pos.getZ());
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; p.rotationYaw=%s; print('ok')",
      expectedRotationYaw);

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  float actualRotationYaw = ((EntityPig) actEntities.get(0)).rotationYaw;
  assertThat(actualRotationYaw).isEqualTo(expectedRotationYaw);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_rotationPitch_is_readable() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint();

  mc().executeCommand("/summon minecraft:pig %s %s %s {CustomName:testpig,NoAI:1}", pos.getX(),
      pos.getY(), pos.getZ());
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; print(string.format('%.5f',p.rotationPitch))");

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  String expectedRotationPitch =
      String.format("%.5f", ((EntityPig) actEntities.get(0)).rotationPitch);
  assertThat(act.getMessage()).isEqualTo(expectedRotationPitch);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_rotationPitch_is_writable() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint();
  float expectedRotationPitch = 45f;
  mc().executeCommand("/summon minecraft:pig %s %s %s {CustomName:testpig,NoAI:1}", pos.getX(),
      pos.getY(), pos.getZ());
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; p.rotationPitch=%s; print('ok')",
      expectedRotationPitch);

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  float actualRotationPitch = ((EntityPig) actEntities.get(0)).rotationPitch;
  assertThat(actualRotationPitch).isEqualTo(expectedRotationPitch);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_eyeHeight_is_readable() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint();

  mc().executeCommand("/summon minecraft:pig %s %s %s {CustomName:testpig}", pos.getX(),
      pos.getY(), pos.getZ());
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; print(string.format('%.5f',p.eyeHeight))");

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  String expectedEyeHeight =
      String.format("%.5f", ((EntityPig) actEntities.get(0)).getEyeHeight());
  assertThat(act.getMessage()).isEqualTo(expectedEyeHeight);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_motion_is_writable() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint();

  mc().executeCommand("/summon minecraft:pig %s %s %s {CustomName:testpig}", pos.getX(),
      pos.getY(), pos.getZ());
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; p.motion=Vec3(0,10,0); print('ok')");

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  double actualMotion = ((EntityPig) actEntities.get(0)).motionY;
  assertThat(actualMotion).isGreaterThan(0);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_tags_is_writable() throws Exception {
  // Given:
  String initialTag = "initialtag";
  String newTag1 = "newtag1";
  String newTag2 = "newtag2";
  BlockPos pos = mc().getWorldSpawnPoint();

  mc().executeCommand("/summon minecraft:pig %s %s %s {CustomName:testpig,Tags:[0:\"%s\"]}",
      pos.getX(), pos.getY(), pos.getZ(), initialTag);
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; p.tags={'%s','%s'}; print('ok')", newTag1,
      newTag2);

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  Set<String> actualTags = ((EntityPig) actEntities.get(0)).getTags();
  assertThat(actualTags).containsOnly(newTag1, newTag2);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_addTag() throws Exception {
  // Given:
  String initialTag = "initialtag";
  String newTag = "newtag";

  BlockPos pos = mc().getWorldSpawnPoint();

  mc().executeCommand("/summon minecraft:pig %s %s %s {CustomName:testpig,Tags:[0:\"%s\"]}",
      pos.getX(), pos.getY(), pos.getZ(), initialTag);
  mc().clearEvents();

  // When:
  mc().executeCommand("/lua p=Entities.find('@e[name=testpig]')[1]; p:addTag('%s'); print('ok')",
      newTag);

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  Set<String> actualTags = ((EntityPig) actEntities.get(0)).getTags();
  assertThat(actualTags).containsOnly(initialTag, newTag);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_removeTag() throws Exception {
  // Given:
  String initialTag = "initialtag";

  BlockPos pos = mc().getWorldSpawnPoint();

  mc().executeCommand("/summon minecraft:pig %s %s %s {CustomName:testpig,Tags:[0:\"%s\"]}",
      pos.getX(), pos.getY(), pos.getZ(), initialTag);
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; p:removeTag('%s'); print('ok')", initialTag);

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  Set<String> actualTags = ((EntityPig) actEntities.get(0)).getTags();
  assertThat(actualTags).isEmpty();
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_move_forward() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint().up();
  float rotation = 90;
  BlockPos expectedPos = pos.west();

  mc().executeCommand(
      "/summon minecraft:pig %s %s %s {CustomName:testpig,NoAI:1,Rotation:[0:%sf,1:0f]}",
      pos.getX(), pos.getY(), pos.getZ(), rotation);
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; p:move('forward'); print('ok')");

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  BlockPos actPos = ((EntityPig) actEntities.get(0)).getPosition();
  assertThat(actPos).isEqualTo(expectedPos);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_move_back() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint().up();
  float rotation = 90;
  BlockPos expectedPos = pos.east();

  mc().executeCommand(
      "/summon minecraft:pig %s %s %s {CustomName:testpig,NoAI:1,Rotation:[0:%sf,1:0f]}",
      pos.getX(), pos.getY(), pos.getZ(), rotation);
  mc().clearEvents();

  // When:
  mc().executeCommand("/lua p=Entities.find('@e[name=testpig]')[1]; p:move('back'); print('ok')");

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  BlockPos actPos = ((EntityPig) actEntities.get(0)).getPosition();
  assertThat(actPos).isEqualTo(expectedPos);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_move_left() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint().up();
  float rotation = 90;
  BlockPos expectedPos = pos.south();

  mc().executeCommand(
      "/summon minecraft:pig %s %s %s {CustomName:testpig,NoAI:1,Rotation:[0:%sf,1:0f]}",
      pos.getX(), pos.getY(), pos.getZ(), rotation);
  mc().clearEvents();

  // When:
  mc().executeCommand("/lua p=Entities.find('@e[name=testpig]')[1]; p:move('left'); print('ok')");

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  BlockPos actPos = ((EntityPig) actEntities.get(0)).getPosition();
  assertThat(actPos).isEqualTo(expectedPos);
}
项目:wizards-of-lua    文件:EntityTest.java   
@Test
public void test_move_right() throws Exception {
  // Given:
  BlockPos pos = mc().getWorldSpawnPoint().up();
  float rotation = 90;
  BlockPos expectedPos = pos.north();

  mc().executeCommand(
      "/summon minecraft:pig %s %s %s {CustomName:testpig,NoAI:1,Rotation:[0:%sf,1:0f]}",
      pos.getX(), pos.getY(), pos.getZ(), rotation);
  mc().clearEvents();

  // When:
  mc().executeCommand(
      "/lua p=Entities.find('@e[name=testpig]')[1]; p:move('right'); print('ok')");

  // Then:
  ServerLog4jEvent act = mc().waitFor(ServerLog4jEvent.class);
  assertThat(act.getMessage()).isEqualTo("ok");
  List<Entity> actEntities = mc().findEntities("@e[name=testpig]");
  assertThat(actEntities).hasSize(1);
  BlockPos actPos = ((EntityPig) actEntities.get(0)).getPosition();
  assertThat(actPos).isEqualTo(expectedPos);
}
项目:Tannery    文件:EntityDropsHandler.java   
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event)
{
    Entity e = event.entity;
    List<EntityItem> drops = event.drops;
    // Remove all drops from cows, sheep and pigs, add carcass drop
    if (e instanceof EntityCow || e instanceof EntityPig || e instanceof EntitySheep)
    {
        EntityAnimal a = (EntityAnimal) e;
        Iterator<EntityItem> it = drops.iterator();
        while (it.hasNext())
        {
            EntityItem i = it.next();
            it.remove();
        }

        if (a.getGrowingAge() == 0)
        {
            if (a instanceof EntityCow) a.dropItem(TanneryItems.bloodyCowCarcass, 1);
            else if (a instanceof EntityPig) a.dropItem(TanneryItems.bloodyPigCarcass, 1);
            else if (a instanceof EntitySheep) a.dropItem(TanneryItems.bloodySheepCarcass, 1);
        }
    }
}
项目:Minecraft-Flux    文件:EntityActionEnergy.java   
@Override
public long inputEnergy(long amount, boolean simulate) {
    if (!simulate && !charged) {
        if (creature instanceof EntityPig) {
            final EntityPigZombie pigman = new EntityPigZombie(creature.world);
            pigman.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_AXE));
            pigman.setLocationAndAngles(creature.posX, creature.posY, creature.posZ, creature.rotationYaw, creature.rotationPitch);
            pigman.setNoAI(creature.isAIDisabled());
            if (creature.hasCustomName()) {
                pigman.setCustomNameTag(creature.getCustomNameTag());
                pigman.setAlwaysRenderNameTag(creature.getAlwaysRenderNameTag());
            }
            creature.world.spawnEntity(pigman);
            creature.setDead();
        } else if (creature instanceof EntityCreeper)
            creature.onStruckByLightning(null);
        charged = true;
        return 1;
    }
    return charged ? 0 : 1;
}
项目:Et-Futurum    文件:ServerEventHandler.java   
@SubscribeEvent
public void spawnEvent(EntityJoinWorldEvent event) {
    if (event.entity instanceof EntityPig) {
        EntityPig pig = (EntityPig) event.entity;
        if (EtFuturum.enableBeetroot)
            pig.tasks.addTask(4, new EntityAITempt(pig, 1.2, ModItems.beetroot, false));
    } else if (event.entity instanceof EntityChicken) {
        EntityChicken chicken = (EntityChicken) event.entity;
        if (EtFuturum.enableBeetroot)
            chicken.tasks.addTask(3, new EntityAITempt(chicken, 1.0D, ModItems.beetroot_seeds, false));
    } else if (event.entity instanceof EntityWolf) {
        EntityWolf wolf = (EntityWolf) event.entity;
        if (EtFuturum.enableRabbit)
            wolf.targetTasks.addTask(4, new EntityAITargetNonTamed(wolf, EntityRabbit.class, 200, false));
    } else if (event.entity instanceof EntityVillager) {
        EntityVillager villager = (EntityVillager) event.entity;
        for (Object obj : villager.tasks.taskEntries) {
            EntityAITaskEntry entry = (EntityAITaskEntry) obj;
            if (entry.action instanceof EntityAIOpenDoor) {
                villager.tasks.removeTask(entry.action);
                villager.tasks.addTask(entry.priority, new EntityAIOpenCustomDoor(villager, true));
                break;
            }
        }
    }
}
项目:Et-Futurum    文件:ServerEventHandler.java   
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
    ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
    if (stack == null)
        return;
    if (!(event.target instanceof EntityAnimal))
        return;

    EntityAnimal animal = (EntityAnimal) event.target;
    if (!animal.isChild()) {
        if (animal instanceof EntityPig) {
            if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
                setAnimalInLove(animal, event.entityPlayer, stack);
        } else if (animal instanceof EntityChicken)
            if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
                setAnimalInLove(animal, event.entityPlayer, stack);
    } else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
        feedBaby(animal, event.entityPlayer, stack);
}
项目:It-s-About-Time-Minecraft-Mod    文件:EntityVelociraptor.java   
public EntityVelociraptor(World world)
  {
      super(world);
      this.setSize(1F, 0.6F);
      isCarnivore = true;
      minSize = 0.2F;
maxSize = 1.4F;
adultAge = 10;
maxAge = 16;
      this.tasks.addTask(8, new EntityAITempt(this, 1.2D, Items.chicken, false));
      this.tasks.addTask(10, new MobAIWatchClosestWhenAwake(this, EntityPlayer.class, 8.0F));
      this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityChicken.class, 200, false));
      this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityCow.class, 200, false));
      this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false));
      this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityCompsognathus.class, 200, false));
      this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityPig.class, 200, false));

      this.setTamed(false);
  }
项目:Resilience-Client-Source    文件:ItemCarrotOnAStick.java   
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
    if (par3EntityPlayer.isRiding() && par3EntityPlayer.ridingEntity instanceof EntityPig)
    {
        EntityPig var4 = (EntityPig)par3EntityPlayer.ridingEntity;

        if (var4.getAIControlledByPlayer().isControlledByPlayer() && par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage() >= 7)
        {
            var4.getAIControlledByPlayer().boostSpeed();
            par1ItemStack.damageItem(7, par3EntityPlayer);

            if (par1ItemStack.stackSize == 0)
            {
                ItemStack var5 = new ItemStack(Items.fishing_rod);
                var5.setTagCompound(par1ItemStack.stackTagCompound);
                return var5;
            }
        }
    }

    return par1ItemStack;
}
项目:Resilience-Client-Source    文件:ItemSaddle.java   
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase)
{
    if (par3EntityLivingBase instanceof EntityPig)
    {
        EntityPig var4 = (EntityPig)par3EntityLivingBase;

        if (!var4.getSaddled() && !var4.isChild())
        {
            var4.setSaddled(true);
            var4.worldObj.playSoundAtEntity(var4, "mob.horse.leather", 0.5F, 1.0F);
            --par1ItemStack.stackSize;
        }

        return true;
    }
    else
    {
        return false;
    }
}
项目:ZeroQuest    文件:BiomeGenRedSeed.java   
public BiomeGenRedSeed(int id) {
    super(id);
    this.waterColorMultiplier = 0x003333;
    this.theBiomeDecorator.treesPerChunk = -999;
    this.theBiomeDecorator.flowersPerChunk = 4;
    this.theBiomeDecorator.grassPerChunk = 10;
    this.flowers.clear();
    this.addFlower(Blocks.red_flower,    4,  3);
    this.addFlower(Blocks.red_flower,    5,  3);
    this.addFlower(Blocks.red_flower,    6,  3);
    this.addFlower(Blocks.red_flower,    7,  3);
    this.addFlower(ModBlocks.nileBlackFlower,    0, 20);
    this.addFlower(ModBlocks.nileBlackFlower,    3, 20);
    this.addFlower(ModBlocks.nileBlackFlower,    8, 20);
    this.addFlower(ModBlocks.nileBlackFlower, 0, 30);
    this.spawnableMonsterList.clear();
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityHorse.class, 5, 2, 6));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityRedZertum.class, 100, 4, 4));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityPig.class, 5, 1, 5)); 
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 100, 4, 4));
}
项目:ZeroQuest    文件:BiomeGenBioZone.java   
public BiomeGenBioZone(int id) {
    super(id);
    this.theBiomeDecorator.generateLakes = true;
    this.theBiomeDecorator.treesPerChunk = 4;
    this.spawnableMonsterList.clear();
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySlime.class, 100, 4, 4));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityZertum.class, 100, 4, 4));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityBat.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityPig.class, 5, 1, 5)); 
}
项目:ZeroQuest    文件:BiomeGenNileSavanna.java   
public BiomeGenNileSavanna(int p_i45383_1_)
{
    super(p_i45383_1_);
    this.theBiomeDecorator.treesPerChunk = 1;
    this.theBiomeDecorator.flowersPerChunk = 4;
    this.theBiomeDecorator.grassPerChunk = 20;
    this.spawnableMonsterList.clear();
    this.spawnableCreatureList.clear();
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityZertum.class, 100, 4, 4));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityKortor.class, 100, 2, 3));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityPig.class, 5, 1, 5)); 
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 100, 4, 4));
    this.waterColorMultiplier = 0x0099cc;
}
项目:ZeroQuest    文件:BiomeGenBlueNile.java   
public BiomeGenBlueNile(int id) {
    super(id);
    //topBlock = (byte)ModBlocks.nileGrass.blockID;
    //fillerBlock = (byte)ModBlocks.nileDirt.blockID;
    this.waterColorMultiplier = 0x003333;
    this.theBiomeDecorator.treesPerChunk = 9;
    this.theBiomeDecorator.grassPerChunk = 3;
    this.theBiomeDecorator.flowersPerChunk = 2;
    this.theBiomeDecorator.generateLakes = true;
    this.spawnableMonsterList.clear();
    this.spawnableCreatureList.add(new SpawnListEntry(EntityZertum.class, 100, 4, 4));
    this.spawnableCreatureList.add(new SpawnListEntry(EntityBat.class, 5, 1, 5));
    this.spawnableCreatureList.add(new SpawnListEntry(EntityChicken.class, 5, 1, 5));
    this.spawnableCreatureList.add(new SpawnListEntry(EntityCow.class, 5, 1, 5));
    this.spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 5, 1, 5)); 
}
项目:ZeroQuest    文件:BiomeGenDarkLand.java   
public BiomeGenDarkLand(int id) {
    super(id);
    //topBlock = (byte)ModBlocks.nileGrass.blockID;
    //fillerBlock = (byte)ModBlocks.nileDirt.blockID;
    this.waterColorMultiplier = 0x666600;
    this.theBiomeDecorator.treesPerChunk = 1;
    this.theBiomeDecorator.grassPerChunk = 1;
    this.theBiomeDecorator.flowersPerChunk = -999;
    this.theBiomeDecorator.generateLakes = true;
    this.spawnableMonsterList.clear();
    this.spawnableCreatureList.add(new SpawnListEntry(EntityDarkZertum.class, 100, 4, 4));
    this.spawnableCreatureList.add(new SpawnListEntry(EntityBat.class, 5, 1, 5));
    this.spawnableCreatureList.add(new SpawnListEntry(EntityChicken.class, 5, 1, 5));
    this.spawnableCreatureList.add(new SpawnListEntry(EntityCow.class, 5, 1, 5));
    this.spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 5, 1, 5)); 
}
项目:ZeroQuest    文件:BiomeGenRedSeed.java   
public BiomeGenRedSeed(int id) {
    super(id);
    this.waterColorMultiplier = 0x003333;
    this.theBiomeDecorator.treesPerChunk = -999;
    this.theBiomeDecorator.flowersPerChunk = 4;
    this.theBiomeDecorator.grassPerChunk = 10;
    this.flowers.clear();
    this.addFlower(Blocks.red_flower.getDefaultState(), 4);
    this.addFlower(ModBlocks.nileBlackFlower.getDefaultState(), 90);
    this.spawnableMonsterList.clear();
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityHorse.class, 5, 2, 6));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityPig.class, 5, 1, 5)); 
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 100, 4, 4));
}
项目:ZeroQuest    文件:BiomeGenBioZone.java   
public BiomeGenBioZone(int id) {
    super(id);
    this.theBiomeDecorator.generateLakes = true;
    this.theBiomeDecorator.treesPerChunk = 4;
    this.spawnableMonsterList.clear();
    this.addFlower(ModBlocks.nileBlueFlower.getDefaultState(), 90);
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 100, 4, 4));
    this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySlime.class, 100, 4, 4));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityBat.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 5, 1, 5));
    this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityPig.class, 5, 1, 5)); 
}