Added Pixie Jars

This commit is contained in:
Matt Caughey 2013-11-17 00:50:30 -05:00
parent 617413b0bc
commit 7f2cea1927
6 changed files with 98 additions and 3 deletions

View file

@ -8,7 +8,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityBird extends EntityFlyingMob
public class EntityBird extends EntityFlyingCreature
{
public int courseChangeCooldown;
public double waypointX;

View file

@ -9,7 +9,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class EntityPixie extends EntityFlyingMob
public class EntityPixie extends EntityFlyingCreature
{
public int courseChangeCooldown;
public double waypointX;

View file

@ -1,15 +1,19 @@
package biomesoplenty.items;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.FakePlayer;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Fluids;
import biomesoplenty.api.Items;
import biomesoplenty.entities.EntityPixie;
public class ItemJarEmpty extends Item
{
@ -76,4 +80,43 @@ public class ItemJarEmpty extends Item
return par1ItemStack;
}
}
/**
* 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 EntityPixie)
{
EntityPixie entitypixie = (EntityPixie)par3EntityLivingBase;
entitypixie.setDead();
--par1ItemStack.stackSize;
if (par2EntityPlayer.inventory.getFirstEmptyStack() >= 0)
{
EntityItem entityitem = new EntityItem(par2EntityPlayer.worldObj, par2EntityPlayer.posX, par2EntityPlayer.posY, par2EntityPlayer.posZ, new ItemStack(Items.jarFilled.get(), 1, 2));
if (!par2EntityPlayer.worldObj.isRemote)
{
par2EntityPlayer.worldObj.spawnEntityInWorld(entityitem);
if (!(par2EntityPlayer instanceof FakePlayer))
{
entityitem.onCollideWithPlayer(par2EntityPlayer);
}
}
}
else
{
par2EntityPlayer.dropPlayerItem(new ItemStack(Items.jarFilled.get(), 1, 2));
}
return true;
}
else
{
return false;
}
}
}

View file

@ -4,17 +4,23 @@ import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingData;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Items;
import biomesoplenty.configuration.configfile.BOPConfigurationIDs;
import biomesoplenty.entities.EntityPixie;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemJarFilled extends Item
{
private static String[] jars = {"jarhoney", "jarpoison"};
private static String[] jars = {"jarhoney", "jarpoison", "jarpixie"};
@SideOnly(Side.CLIENT)
private Icon[] textures;
@ -66,4 +72,49 @@ public class ItemJarFilled extends Item
subTypes.add(new ItemStack(itemId, 1, meta));
}
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (par1ItemStack.getItemDamage() == 2)
{
if (par3EntityPlayer.ridingEntity != null)
return par1ItemStack;
else
{
if (par3EntityPlayer.dimension == 0 || par3EntityPlayer.dimension == BOPConfigurationIDs.promisedLandDimID)
{
--par1ItemStack.stackSize;
if (par1ItemStack.stackSize <= 0)
{
return new ItemStack(Items.jarEmpty.get(), 1, 0);
}
if (!par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.jarEmpty.get(), 1, 0)))
{
par3EntityPlayer.dropPlayerItem(new ItemStack(Items.jarEmpty.get(), 1, 0));
}
EntityPixie pixie = new EntityPixie(par2World);
pixie.setLocationAndAngles((double)par3EntityPlayer.posX, (double)par3EntityPlayer.posY + 1.0F, (double)par3EntityPlayer.posZ, 0.0F, 0.0F);
pixie.onSpawnWithEgg((EntityLivingData)null);
par2World.spawnEntityInWorld(pixie);
pixie.playLivingSound();
}
else
{
if (!par3EntityPlayer.worldObj.isRemote)
{
par3EntityPlayer.addChatMessage("\u00a75Pixies cannot survive in this environment!");
}
}
}
}
return par1ItemStack;
}
}

View file

@ -325,6 +325,7 @@ item.bop.miscItems.pixiedust.name=Pixie Dust
item.bop.jarEmpty.name=Empty Jar
item.bop.jarFilled.jarhoney.name=Honey Jar
item.bop.jarFilled.jarpoison.name=Poison Extract Jar
item.bop.jarFilled.jarpixie.name=Pixie Jar
item.bop.gems.amethyst.name=Amethyst
item.bop.gems.ruby.name=Ruby

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B