Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.reactioncraft.net.common;
- import java.util.List;
- import javax.annotation.Nullable;
- import com.reactioncraft.reactioncraft;
- import com.reactioncraft.core.ItemBase;
- import com.reactioncraft.core.ItemModelProvider;
- import com.reactioncraft.integration.instances.IntegratedItems;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityHanging;
- import net.minecraft.entity.EntityList;
- import net.minecraft.entity.EntityLiving;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.IEntityLivingData;
- import net.minecraft.entity.boss.EntityDragon;
- import net.minecraft.entity.boss.EntityDragonPart;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.*;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.nbt.NBTTagDouble;
- import net.minecraft.nbt.NBTTagFloat;
- import net.minecraft.nbt.NBTTagList;
- import net.minecraft.util.ActionResult;
- import net.minecraft.util.EnumActionResult;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.util.math.MathHelper;
- import net.minecraft.world.World;
- public class ItemCaughtEntity extends ItemBase implements ItemModelProvider
- {
- public ItemCaughtEntity(String string)
- {
- super(string);
- }
- @Override
- public void registerItemModel(Item item)
- {
- reactioncraft.proxy.registerItemRenderer(this, 0, "caught");
- }
- public String getItemDisplayName(ItemStack itemStack)
- {
- return itemStack.getTagCompound().getString("entity") == "player" ? "Caught " + itemStack.getTagCompound().getString("playerUser") + " DNA" : "Caught " + itemStack.getTagCompound().getString("entity");
- }
- /**
- * Called when a Block is right-clicked with this Item
- */
- public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
- {
- BlockPos blockpos = pos.offset(facing);
- ItemStack caught = new ItemStack(IntegratedItems.caught);
- Entity entity = EntityList.createEntityByName(caught.getTagCompound().getString("entity"), worldIn);
- if (playerIn.canPlayerEdit(blockpos, facing, stack))
- {
- //EntityHanging entityhanging = this.createEntity(worldIn, blockpos, facing);
- if (entity != null) //&& entityhanging.onValidSurface())
- {
- if (!worldIn.isRemote)
- {
- //entity.play();
- worldIn.spawnEntityInWorld(entity);
- }
- --stack.stackSize;
- }
- return EnumActionResult.SUCCESS;
- }
- else
- {
- return EnumActionResult.FAIL;
- }
- }
- @Override
- public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
- {
- if (itemStack.getTagCompound() != null)
- {
- list.add("Name: " + itemStack.getTagCompound().getString("entity"));
- }
- }
- // /**
- // * Spawns the creature specified by the egg's type in the location specified by
- // * the last three parameters.
- // * Parameters: world, entityID, x, y, z.
- // */
- // public Entity onItemUse(World parWorld, double parX, double parY, double parZ)
- // {
- //
- // ItemStack caught = new ItemStack(IntegratedItems.caught);
- //
- // Entity entity = EntityList.createEntityByName(caught.getTagCompound().getString("entity"), parWorld);
- //
- // if (!parWorld.isRemote) // never spawn entity on client side
- // {
- // if (entity instanceof EntityLiving)
- // {
- // entity = (EntityLiving) EntityList
- // .createEntityByName(name, parWorld);
- // entity.setLocationAndAngles(parX, parY, parZ, (parWorld.rand.nextFloat() * 360.0F), 0.0F);
- // parWorld.spawnEntityInWorld(entity);
- // ((EntityLiving) entity).onInitialSpawn(parWorld.getDifficultyForLocation(new BlockPos(entity)), (IEntityLivingData)null);
- // ((EntityLiving) entity).playLivingSound();
- // }
- // else
- // {
- // //DEBUG
- // System.out.println("Entity not found ");
- // }
- // }
- //
- // return entity;
- // }
- //
- public static NBTTagList newDoubleNBTList(double ... par1ArrayOfDouble)
- {
- NBTTagList var2 = new NBTTagList();
- double[] var3 = par1ArrayOfDouble;
- int var4 = par1ArrayOfDouble.length;
- for (int var5 = 0; var5 < var4; ++var5)
- {
- double var6 = var3[var5];
- var2.appendTag(new NBTTagDouble(var6));
- }
- return var2;
- }
- public static NBTTagList newFloatNBTList(float ... par1ArrayOfFloat)
- {
- NBTTagList var2 = new NBTTagList();
- float[] var3 = par1ArrayOfFloat;
- int var4 = par1ArrayOfFloat.length;
- for (int var5 = 0; var5 < var4; ++var5)
- {
- float var6 = var3[var5];
- var2.appendTag(new NBTTagFloat(var6));
- }
- return var2;
- }
- /**
- * allows items to add custom lines of information to the mouseover description
- */
- //public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
- //{
- // if (itemStack.getTagCompound() != null)
- // {
- // list.add("Caught " + itemStack.getTagCompound().getString("entity"));
- // }
- // else
- // {
- // list.add("Please craft to see results");
- // }
- // super.addInformation(itemStack, player, list, par4);
- //}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement