From 7f2cea192764931a2995ef5330df727881a69b84 Mon Sep 17 00:00:00 2001 From: Matt Caughey Date: Sun, 17 Nov 2013 00:50:30 -0500 Subject: [PATCH] Added Pixie Jars --- common/biomesoplenty/entities/EntityBird.java | 2 +- .../biomesoplenty/entities/EntityPixie.java | 2 +- common/biomesoplenty/items/ItemJarEmpty.java | 43 ++++++++++++++ common/biomesoplenty/items/ItemJarFilled.java | 53 +++++++++++++++++- .../assets/biomesoplenty/lang/en_US.lang | 1 + .../biomesoplenty/textures/items/jarpixie.png | Bin 0 -> 356 bytes 6 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 resources/assets/biomesoplenty/textures/items/jarpixie.png diff --git a/common/biomesoplenty/entities/EntityBird.java b/common/biomesoplenty/entities/EntityBird.java index 948b2591b..256a3ac14 100644 --- a/common/biomesoplenty/entities/EntityBird.java +++ b/common/biomesoplenty/entities/EntityBird.java @@ -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; diff --git a/common/biomesoplenty/entities/EntityPixie.java b/common/biomesoplenty/entities/EntityPixie.java index 0de98d41a..e070bdd19 100644 --- a/common/biomesoplenty/entities/EntityPixie.java +++ b/common/biomesoplenty/entities/EntityPixie.java @@ -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; diff --git a/common/biomesoplenty/items/ItemJarEmpty.java b/common/biomesoplenty/items/ItemJarEmpty.java index 60756fb90..9be307a2e 100644 --- a/common/biomesoplenty/items/ItemJarEmpty.java +++ b/common/biomesoplenty/items/ItemJarEmpty.java @@ -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; + } + } } diff --git a/common/biomesoplenty/items/ItemJarFilled.java b/common/biomesoplenty/items/ItemJarFilled.java index 06e5abe49..4183c0ab4 100644 --- a/common/biomesoplenty/items/ItemJarFilled.java +++ b/common/biomesoplenty/items/ItemJarFilled.java @@ -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; + } } diff --git a/resources/assets/biomesoplenty/lang/en_US.lang b/resources/assets/biomesoplenty/lang/en_US.lang index 336fe5ddc..fbe3564bd 100644 --- a/resources/assets/biomesoplenty/lang/en_US.lang +++ b/resources/assets/biomesoplenty/lang/en_US.lang @@ -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 diff --git a/resources/assets/biomesoplenty/textures/items/jarpixie.png b/resources/assets/biomesoplenty/textures/items/jarpixie.png new file mode 100644 index 0000000000000000000000000000000000000000..07274849835591bee56ec7aa815a27e27d431a1f GIT binary patch literal 356 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsOo{I zi(`m||JezSdnwA!PC{xWt~$(696zWf#U!G literal 0 HcmV?d00001