Merge pull request #378 from SteveKunG/patch-1

Enable pixie spawning
This commit is contained in:
Adubbz 2014-12-15 12:05:28 +11:00
commit 9d3225f23c
1 changed files with 71 additions and 68 deletions

View File

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