Enable pixie spawning

Oh hey. Um. I can fix this feature.
This commit is contained in:
SteveKunG 2014-12-14 09:59:27 +07:00
parent e340bbb201
commit 9fbb4900dc
1 changed files with 71 additions and 68 deletions

View File

@ -1,15 +1,25 @@
package biomesoplenty.common.items;
import biomesoplenty.BiomesOPlenty;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import java.util.List;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.content.BOPCItems;
import biomesoplenty.common.entities.EntityPixie;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemJarFilled extends Item
{
@ -21,7 +31,7 @@ public class ItemJarFilled extends Item
{
this.setMaxDamage(0);
this.setMaxStackSize(1);
this.setHasSubtypes(true);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@ -59,80 +69,73 @@ public class ItemJarFilled extends Item
}
@Override
//TODO: public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
//TODO: public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
{
for (int meta = 0; meta < jars.length; ++meta)
{
list.add(new ItemStack(item, 1, meta));
}
}
/*TODO: FEATURE
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int side, float xoffset, float yoffset, float zoffset)
{
if (itemStack.getItemDamage() == 2)
{
if (entityPlayer.dimension == 0 || entityPlayer.dimension == BOPConfigurationIDs.promisedLandDimID)
{
//TODO: getBlock()
Block block = world.getBlock(x, y, z);
x += Facing.offsetsXForSide[side];
y += Facing.offsetsYForSide[side];
z += Facing.offsetsZForSide[side];
double d0 = 0.0D;
//TODO: getRenderType()
if (side == 1 && block != null && block.getRenderType() == 11)
{
d0 = 0.5D;
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int side, float xoffset, float yoffset, float zoffset)
{
if (itemStack.getItemDamage() == 2)
{
if (entityPlayer.dimension == 0)
{
Block block = world.getBlock(x, y, z);
x += Facing.offsetsXForSide[side];
y += Facing.offsetsYForSide[side];
z += Facing.offsetsZForSide[side];
double d0 = 0.0D;
if (!world.isRemote)
{
EntityPixie entity = new EntityPixie(world);
entity.setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F);
entity.rotationYawHead = entity.rotationYaw;
entity.renderYawOffset = entity.rotationYaw;
entity.onSpawnWithEgg((IEntityLivingData)null);
world.spawnEntityInWorld(entity);
entity.playLivingSound();
if (side == 1 && block != null && block.getRenderType() == 11)
{
d0 = 0.5D;
}
if (itemStack.hasDisplayName())
{
((EntityLiving)entity).setCustomNameTag(itemStack.getDisplayName());
}
}
if (!world.isRemote)
{
EntityPixie entity = new EntityPixie(world);
entity.setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F);
entity.rotationYawHead = entity.rotationYaw;
entity.renderYawOffset = entity.rotationYaw;
entity.onSpawnWithEgg((IEntityLivingData)null);
world.spawnEntityInWorld(entity);
entity.playLivingSound();
if (!entityPlayer.capabilities.isCreativeMode)
{
--itemStack.stackSize;
if (itemStack.hasDisplayName())
{
((EntityLiving)entity).setCustomNameTag(itemStack.getDisplayName());
}
}
if (itemStack.stackSize <= 0)
{
itemStack = new ItemStack(BOPItemHelper.get("jarEmpty"), 1, 0);
}
if (!entityPlayer.capabilities.isCreativeMode)
{
--itemStack.stackSize;
if (!entityPlayer.inventory.addItemStackToInventory(new ItemStack(BOPItemHelper.get("jarEmpty"), 1, 0)))
{
//TODO: player.dropPlayerItem(ItemStack itemStack)?
entityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(BOPItemHelper.get("jarEmpty"), 1, 0), false);
}
}
if (itemStack.stackSize <= 0)
{
itemStack = new ItemStack(BOPCItems.jarEmpty, 1, 0);
}
}
else
{
if (!world.isRemote)
{
//TODO: addChatMessage
entityPlayer.addChatComponentMessage(new ChatComponentText("\u00a75Pixies cannot survive in this environment!"));
}
}
}
if (!entityPlayer.inventory.addItemStackToInventory(new ItemStack(BOPCItems.jarEmpty, 1, 0)))
{
entityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(BOPCItems.jarEmpty, 1, 0), false);
}
}
return true;
}
}*/
}
else
{
if (!world.isRemote)
{
entityPlayer.addChatComponentMessage(new ChatComponentText("\u00a75Pixies cannot survive in this environment!"));
}
}
}
return true;
}
}