Search in sources :

Example 1 with EntityPixie

use of biomesoplenty.common.entities.EntityPixie in project BiomesOPlenty by Glitchfiend.

the class ItemJarEmpty method itemInteractionForEntity.

@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase target, EnumHand hand) {
    // right clicking a pixie with an empty jar catches it in the jar
    if (target instanceof EntityPixie) {
        EntityPixie pixie = (EntityPixie) target;
        pixie.setDead();
        stack.setCount(stack.getCount() - 1);
        ItemStack pixieJar = new ItemStack(BOPItems.jar_filled, 1, ItemJarFilled.JarContents.PIXIE.ordinal());
        EntityItem pixieJarEntity = new EntityItem(player.world, player.posX, player.posY, player.posZ, pixieJar);
        if (!player.world.isRemote) {
            player.world.spawnEntity(pixieJarEntity);
            if (!(player instanceof FakePlayer)) {
                pixieJarEntity.onCollideWithPlayer(player);
            }
        }
        return true;
    }
    return false;
}
Also used : ItemStack(net.minecraft.item.ItemStack) EntityPixie(biomesoplenty.common.entities.EntityPixie) EntityItem(net.minecraft.entity.item.EntityItem) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Example 2 with EntityPixie

use of biomesoplenty.common.entities.EntityPixie in project BiomesOPlenty by Glitchfiend.

the class ItemJarFilled method releasePixie.

// TODO: should you get back an empty jar?
public boolean releasePixie(ItemStack stack, World world, EntityPlayer player, Vec3d releasePoint) {
    if (world.provider.isSurfaceWorld()) {
        EntityPixie pixie = new EntityPixie(world);
        pixie.setLocationAndAngles(releasePoint.x, releasePoint.y, releasePoint.z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360.0F), 0.0F);
        world.spawnEntity(pixie);
        pixie.playLivingSound();
        if (stack.hasDisplayName()) {
            pixie.setCustomNameTag(stack.getDisplayName());
        }
        return true;
    } else {
        player.sendMessage(new TextComponentString("\u00a75Pixies cannot survive in this environment!"));
        return false;
    }
}
Also used : EntityPixie(biomesoplenty.common.entities.EntityPixie) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

EntityPixie (biomesoplenty.common.entities.EntityPixie)2 EntityItem (net.minecraft.entity.item.EntityItem)1 ItemStack (net.minecraft.item.ItemStack)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1