net.minecraft.entity.player.EntityPlayer Java Examples

The following examples show how to use net.minecraft.entity.player.EntityPlayer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemBackpack.java    From WearableBackpacks with MIT License 6 votes vote down vote up
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn,
                                        EntityLivingBase target, EnumHand hand) {
	// When right clicking a non-player entity with a backpack in
	// creative, make the target entity equip the held backpack.
	if (playerIn.world.isRemote || !playerIn.isCreative() ||
	    !BackpackRegistry.canEntityWearBackpacks(target) ||
	    (target instanceof EntityPlayer)) return false;
	
	// If the target entity is already wearing a backpack, call
	// onFaultyRemoval, which may for example drop the backpack's items.
	IBackpack backpack = BackpackHelper.getBackpack(target);
	if (backpack != null) backpack.getType().onFaultyRemoval(target, backpack);
	
	stack = stack.splitStack(1); // This reduces the held stack's size while
	                             // giving us a copy with a stack size of 1.
	// (Not necessary since in creative, but this is the right way to do things!)
	IBackpackData data = BackpackHelper.getBackpackType(stack).createBackpackData(stack);
	BackpackHelper.setEquippedBackpack(target, stack, data);
	
	return true;
}
 
Example #2
Source File: CapeHandler.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void resolve(EntityPlayer player, Point point) {
	float yaw = (float) Math.toRadians(player.renderYawOffset);
	float height;
	float back;
	if (player.isSneaking()) {
		height = 1.15F;
		back = getBack(player, 0.135F);
	} else {
		height = 1.38F;
		back = getBack(player, 0.14F);
	}
	float vx = MathHelper.cos(yaw) * x + MathHelper.cos(yaw - (float) Math.PI / 2) * back;
	float vz = MathHelper.sin(yaw) * x + MathHelper.sin(yaw - (float) Math.PI / 2) * back;
	point.posX = (float) player.posX + vx;
	point.posY = (float) player.posY + height + y;
	point.posZ = (float) player.posZ + vz;
}
 
Example #3
Source File: ComponentLightning.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer player, EntityLivingBase entityLiving) {
	if(player.worldObj.isRemote) {
		PacketBuffer out = new PacketBuffer(Unpooled.buffer());
			//System.out.println("Building packet...");
			out.writeInt(PacketHandlerServer.LIGHTNING);
			out.writeInt(player.getEntityId());
			//EntityPlayer par3EntityPlayer = (EntityPlayer) par3EntityLivingBase;
			out.writeInt(player.inventory.currentItem);
			//out.writeFloat(par3EntityPlayer.getHealth()+1);
			CToSMessage packet = new CToSMessage(out);
			DragonArtifacts.artifactNetworkWrapper.sendToServer(packet);
			//par1ItemStack.damageItem(1, par2EntityPlayer);
			return true;
		
	}
	return false;
}
 
Example #4
Source File: TilePlanetSelector.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public List<ModuleBase> getModules(int ID, EntityPlayer player) {

	List<ModuleBase> modules = new LinkedList<ModuleBase>();

	container = new ModulePlanetSelector(0, TextureResources.starryBG, this, true);
	container.setOffset(1000, 1000);
	modules.add(container);

	//Transfer discovery values
	if(!world.isRemote) {
		markDirty();
	}

	return modules;
}
 
Example #5
Source File: InputHandler.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean nudgeSelection(int amount, ToolMode mode, EntityPlayer player)
{
    if (mode.getUsesAreaSelection())
    {
        DataManager.getSelectionManager().moveSelectedElement(EntityUtils.getClosestLookingDirection(player), amount);
        return true;
    }
    else if (mode.getUsesSchematic())
    {
        EnumFacing direction = EntityUtils.getClosestLookingDirection(player);
        DataManager.getSchematicPlacementManager().nudgePositionOfCurrentSelection(direction, amount);
        return true;
    }

    return false;
}
 
Example #6
Source File: BlockBarrelDistillation.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
  public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
      if (world.isRemote) {
          return true;
      }
ItemStack stack = player.getHeldItem(hand);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityDistillation) {
    IFluidHandlerItem handler = FluidUtil.getFluidHandler(ItemHandlerHelper.copyStackWithSize(stack, 1));
    if (handler != null) {
        FluidUtil.interactWithFluidHandler(player, hand, tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side));
        return true;
    }
    player.openGui(SakuraMain.instance, SakuraGuiHandler.ID_DISTILLATION, world, pos.getX(), pos.getY(), pos.getZ());
    return true;
}
return true;
  }
 
Example #7
Source File: GTTileMagicEnergyAbsorber.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean isConvertingBookItem() {
	ItemStack inputStack = this.getStackInSlot(slotInput);
	int level = GTHelperStack.getBookEnchantmentLevel(inputStack);
	if (level > 0 && !this.isFull()) {
		int generate = world.rand.nextInt(20000 * level);
		ItemStack blankBook = GTMaterialGen.get(Items.BOOK);
		if (!GTHelperStack.canMerge(blankBook, this.getStackInSlot(slotOutput))) {
			return false;
		}
		this.addEnergy(generate);
		this.setStackInSlot(slotOutput, StackUtil.copyWithSize(blankBook, this.getStackInSlot(slotOutput).getCount()
				+ 1));
		inputStack.shrink(1);
		world.playSound((EntityPlayer) null, this.pos, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, 0.75F
				+ world.rand.nextFloat());
		return true;
	}
	return false;
}
 
Example #8
Source File: AdvancedFakePlayer.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static boolean isFakePlayer(EntityPlayer player) {
    if(!player.worldObj.isRemote) {
        if(player.getClass() != EntityPlayerMP.class) {
            return true;
        }
        EntityPlayerMP mp = (EntityPlayerMP) player;

        if(mp.playerNetServerHandler == null
                || !MinecraftServer.getServer().getConfigurationManager().playerEntityList.contains(player)
                || mp.getPlayerIP() == null || mp.getPlayerIP().trim().isEmpty()) {
            return true;
        }

        try {
            mp.playerNetServerHandler.netManager.getSocketAddress().toString();
        } catch (Exception e) {
            return true;
        }
    }
    return false;
}
 
Example #9
Source File: MessageQuestUpdate.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
private void processDonate(EntityPlayer player, Province province, IVillageLordInventory inventory) {
	ItemStack donation = inventory.getDonationItem();

	if (MessageSetItemReputationAmount.isNoteForLord(province, donation)) {
		writeReplyNote(inventory, donation);
		return;
	}

	if (MessageSetItemReputationAmount.isStolenItemForProvince(province, donation)) {
		handleReturnStolenItem(player, province, inventory, donation);
		return;
	}

	DonationReward reward = getRepForDonation(donation);
	if (reward != null) {
		PlayerCivilizationCapabilityImpl.get(player).adjustReputation(province.civilization, reward.rep);
		inventory.setDonationItem(ItemStack.EMPTY);
		inventory.setReturnItems(l(new ItemStack(reward.item)));
	}
}
 
Example #10
Source File: EventSoulBound.java    From Levels with GNU General Public License v2.0 6 votes vote down vote up
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event)
{
	EntityPlayer player = event.getEntityPlayer();
	Item item;
	
	for (int i = 0; i < event.getDrops().size(); i++)
	{
		item = event.getDrops().get(i).getEntityItem().getItem();
		
		if (item != null && (item instanceof ItemSword || item instanceof ItemShield || item instanceof ItemArmor || item instanceof ItemBow))
		{
			ItemStack stack = event.getDrops().get(i).getEntityItem();
			NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
			
			if (nbt != null)
			{
				if (WeaponAttribute.SOUL_BOUND.hasAttribute(nbt) || ArmorAttribute.SOUL_BOUND.hasAttribute(nbt) || BowAttribute.SOUL_BOUND.hasAttribute(nbt) || ShieldAttribute.SOUL_BOUND.hasAttribute(nbt))
				{
					event.getDrops().remove(i);
					player.inventory.addItemStackToInventory(stack);
				}
			}
		}
	}
}
 
Example #11
Source File: CalcState.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
protected Calculator<?, ExprType> newCalculator(final SenderHolder holder) {
	final Calculator<TypedValue, ExprType> calculator = TypedValueCalculatorFactory.create();

	final TypedValue nullValue = calculator.environment.nullValue();
	final TypeDomain domain = nullValue.domain;
	calculator.environment.setGlobalSymbol("player", new NullaryFunction.Direct<TypedValue>() {

		@Override
		protected TypedValue call() {
			if (holder.sender instanceof EntityPlayer) {
				final EntityPlayerWrapper wrapper = new EntityPlayerWrapper((EntityPlayer)holder.sender, nullValue);
				return StructWrapper.create(domain, wrapper);
			}

			return nullValue;
		}

	});

	return calculator;
}
 
Example #12
Source File: ContainerPlayerTFC.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onContainerClosed(EntityPlayer player)
{
	if(!player.world.isRemote)
	{
		super.onContainerClosed(player);

		for (int i = 0; i < 9; ++i)
		{
			ItemStack itemstack = this.craftMatrix.removeStackFromSlot(i);
			if (!itemstack.isEmpty())
				player.dropItem(itemstack, false);
		}

		this.craftResult.setInventorySlotContents(0, ItemStack.EMPTY);
	}
}
 
Example #13
Source File: ItemShieldFocus.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onPlayerStoppedUsingFocus(ItemStack itemstack, World world, EntityPlayer player, int count) {
    int x = MathHelper.floor_double(player.posX);
    int y = MathHelper.floor_double(player.posY);
    int z = MathHelper.floor_double(player.posZ);

    // Player Level
    if ((player.worldObj.getBlock(x + 1, y, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x - 1, y, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y, z + 1) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y, z - 1) == IC2BlockRegistry.shield)) {
        player.worldObj.setBlockToAir(x + 1, y, z);
        player.worldObj.setBlockToAir(x - 1, y, z);
        player.worldObj.setBlockToAir(x, y, z + 1);
        player.worldObj.setBlockToAir(x, y, z - 1);
    }

    // Above the player
    if ((player.worldObj.getBlock(x + 1, y + 1, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x - 1, y + 1, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y + 1, z + 1) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y + 1, z - 1) == IC2BlockRegistry.shield)) {
        player.worldObj.setBlockToAir(x + 1, y + 1, z);
        player.worldObj.setBlockToAir(x - 1, y + 1, z);
        player.worldObj.setBlockToAir(x, y + 1, z + 1);
        player.worldObj.setBlockToAir(x, y + 1, z - 1);
    }

    ItemStack milk = (new ItemStack(Items.milk_bucket));
    player.curePotionEffects(milk);
}
 
Example #14
Source File: BlockNoodle.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
  public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
  		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  	if (worldIn.isRemote) {
          return true;
      }
int i = this.getCutting(state);
ItemStack stack = playerIn.getHeldItem(hand);
if(!isReady(state)){
    if(stack.getItem() instanceof ItemKnifeNoodle){
    	if(!playerIn.isCreative()) stack.damageItem(1, playerIn);
    	 if (worldIn.rand.nextInt(8) == 0) {
    		 worldIn.setBlockState(pos, this.withCutting(i + 1), 2);
    		 return true;
    	 }
    }
}else{
	worldIn.setBlockToAir(pos);
	spawnAsEntity(worldIn, pos, getNoodle());
}
return true;
  }
 
Example #15
Source File: ItemLinkCrystal.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean doKeyBindingAction(EntityPlayer player, ItemStack stack, int key)
{
    // Alt + Shift + Toggle mode: Store the player's current location, including rotation
    if (EnumKey.TOGGLE.matches(key, HotKeys.MOD_SHIFT_ALT))
    {
        if (stack.getMetadata() == TYPE_PORTAL)
        {
            return false;
        }
        else
        {
            this.setTarget(stack, player, true);
            return true;
        }
    }

    return super.doKeyBindingAction(player, stack, key);
}
 
Example #16
Source File: Core.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static InventoryPlayer getNewInventory(EntityPlayer player)
{
	InventoryPlayer ip = player.inventory;
	NBTTagList nbt = new NBTTagList();
	nbt = player.inventory.writeToNBT(nbt);
	ip = new InventoryPlayerTFC(player);
	ip.readFromNBT(nbt);
	return ip;
}
 
Example #17
Source File: BlockLightChain.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float vx, float vy, float vz) {
    BlockGarden block = getGardenBlock(world, x, y, z);
    if (block != null) {
        y = getBaseBlockYCoord(world, x, y, z);
        return block.applyItemToGarden(world, x, y, z, player, null);
    }

    return super.onBlockActivated(world, x, y, z, player, side, vx, vy, vz);
}
 
Example #18
Source File: ItemThinLog.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public boolean placeBlockAt (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{
    int blockMeta = (metadata < 16) ? metadata : 0;
    if (!super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, blockMeta))
        return false;

    TileEntityWoodProxy.syncTileEntityWithData(world, x, y, z, metadata);
    return true;
}
 
Example #19
Source File: ContainerCustomSlotClick.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void shiftClickSlot(int slotNum, EntityPlayer player)
{
    SlotItemHandlerGeneric slot = this.getSlotItemHandler(slotNum);
    ItemStack stackSlot = slot != null ? slot.getStack() : ItemStack.EMPTY;

    if (stackSlot.isEmpty() == false && this.transferStackFromSlot(player, slotNum))
    {
        slot.onTake(player, stackSlot);
    }
}
 
Example #20
Source File: MCCraftingGrid.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private MCCraftingGrid(InventoryCrafting inventory) {
	this.inventory = inventory;
	width = height = (int) Math.sqrt(inventory.getSizeInventory());
	items = new nova.core.item.Item[width * height];
	original = new net.minecraft.item.ItemStack[items.length];
	itemCount = 0;
	update();

	Container container = ReflectionUtil.getCraftingContainer(inventory);
	if (container != null) {
		@SuppressWarnings("unchecked")
		List<Slot> slots = container.inventorySlots;

		EntityPlayer playerOrig = null;
		Optional<Player> player = Optional.empty();

		for (Slot slot : slots) {
			if (slot instanceof SlotCrafting) {
				playerOrig = ReflectionUtil.getCraftingSlotPlayer((SlotCrafting) slot);
				player = WrapUtility.getNovaPlayer(playerOrig);

				if (player.isPresent()) {
					break;
				}
			}
		}

		this.playerOrig = playerOrig;
		this.player = player;
	} else {
		playerOrig = null;
		player = Optional.empty();
	}
}
 
Example #21
Source File: TileSpaceElevator.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public boolean onLinkStart(ItemStack item, TileEntity entity,
		EntityPlayer player, World world) {
	ItemLinker.setMasterCoords(item, this.getPos());
	ItemLinker.setDimId(item, world.provider.getDimension());
	if(!world.isRemote)
		player.sendMessage(new TextComponentString(LibVulpes.proxy.getLocalizedString("msg.linker.program")));
	return true;
}
 
Example #22
Source File: GuiWeaponSelection.java    From Levels with GNU General Public License v2.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) 
{
	this.drawDefaultBackground();
	super.drawScreen(mouseX, mouseY, partialTicks);
	
	EntityPlayer player = this.mc.player;
	ItemStack stack = player.inventory.getCurrentItem();
	NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
	
	if (player != null && stack != null &&  nbt != null && stack.getItem() instanceof ItemSword)
	{
		drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes"), width / 2, 20, 0xFFFFFF);
		drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes.tokens") + ": " + Experience.getAttributeTokens(nbt), width / 2 - 112, 40, 0xFFFFFF);
		drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes.current"), width / 2 + 112, 40, 0xFFFFFF);
		
		int k = -1;
		
		for (int i = 0; i < WeaponAttribute.WEAPON_ATTRIBUTES.size(); i++)
		{
			if (WeaponAttribute.WEAPON_ATTRIBUTES.get(i).hasAttribute(nbt))
			{
				k++;
				drawCenteredString(fontRendererObj, WeaponAttribute.WEAPON_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 60 + (10 * k), WeaponAttribute.WEAPON_ATTRIBUTES.get(i).getHex());
			}
		}

		displayButtons(nbt);
		drawTooltips(nbt, mouseX, mouseY);
	}
}
 
Example #23
Source File: ItemMetalBlend.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
   public void onCreated(final ItemStack item, final World world, final EntityPlayer crafter) {
   	super.onCreated(item, world, crafter);
   	// achievement
   	// achievement
   	if(metal == Materials.aquarium || metal == Materials.brass || metal == Materials.bronze
   			|| metal == Materials.electrum || metal == Materials.invar || metal == Materials.steel ){
       	crafter.addStat(Achievements.metallurgy, 1);
   	}
   	
}
 
Example #24
Source File: ComponentObscurity.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world,	EntityPlayer player) {
	UtilsForComponents.sendPotionPacket(14, 600, 0, player);
	player.addPotionEffect(new PotionEffect(14, 600, 0));
	ArtifactClientEventHandler.cloaked = true;
	//System.out.println("Cloaking player.");
	UtilsForComponents.sendItemDamagePacket(player, player.inventory.currentItem, 1); //itemStack.damageItem(1, player);
	itemStack.stackTagCompound.setInteger("onItemRightClickDelay", 200);
	return itemStack;
}
 
Example #25
Source File: HackableTameable.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onHackFinished(Entity entity, EntityPlayer player){
    EntityTameable tameable = (EntityTameable)entity;
    if(entity.worldObj.isRemote) {
        tameable.handleHealthUpdate((byte)7);
    } else {
        tameable.setPathToEntity((PathEntity)null);
        tameable.setAttackTarget((EntityLivingBase)null);
        tameable.setHealth(20.0F);
        tameable.func_152115_b(player.getUniqueID().toString());//setOwner
        entity.worldObj.setEntityState(tameable, (byte)7);
        tameable.setTamed(true);
    }
}
 
Example #26
Source File: FoodStatsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public FoodStatsTFC(EntityPlayer player)
{
	this.player = player;
	//waterTimer = Math.max(TFC_Time.getTotalTicks(),TFC_Time.startTime);
	//foodTimer = Math.max(TFC_Time.getTotalTicks(),TFC_Time.startTime);
	//foodHealTimer = Math.max(TFC_Time.getTotalTicks(),TFC_Time.startTime);
}
 
Example #27
Source File: ItemFruitTainted.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) {
    if(!world.isRemote && player instanceof EntityPlayerMP) {
        Thaumcraft.addStickyWarpToPlayer(player, 1);
        player.addPotionEffect(getEffect(PotionFluxTaint.instance.id, 600, false));
        player.addPotionEffect(getEffect(Potion.hunger.id, 600, false));
        if(world.rand.nextFloat() < 0.4F){
            player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("warp.text.15")));
            player.addPotionEffect(getEffect(PotionThaumarhia.instance.id, 600, true));
        }
    }
    return super.onEaten(stack, world, player);
}
 
Example #28
Source File: FWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
	Block blockInstance = getBlockInstance(world, VectorConverter.instance().toNova(pos));
	Block.RemoveEvent evt = new Block.RemoveEvent(Optional.of(EntityConverter.instance().toNova(player)));
	blockInstance.events.publish(evt);
	if (evt.result) {
		return super.removedByPlayer(world, pos, player, willHarvest);
	}
	return false;
}
 
Example #29
Source File: EntityRequestPacket.java    From NBTEdit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handleServerSide(EntityPlayerMP player) {
	Entity e = player.worldObj.getEntityByID(entityID);
	if (e instanceof EntityPlayer && e != player) {
		sendMessageToPlayer(player, SECTION_SIGN + "cError - You may not use NBTEdit on other Players");
		NBTEdit.log(Level.WARNING, player.getCommandSenderName() +  " tried to use NBTEdit on another player, " + ((EntityPlayer)e).getCommandSenderName());
	}
	else if (e != null) {
		NBTTagCompound tag = new NBTTagCompound();
		e.writeToNBT(tag);
		NBTEdit.DISPATCHER.sendTo(new EntityNBTPacket(entityID, tag), player);
	}
	else
		sendMessageToPlayer(player, SECTION_SIGN + "cError - Unknown EntityID #" + entityID );
}
 
Example #30
Source File: ChorusFruit.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) {
	ItemStack result = super.onEaten(stack, world, player);
	for (int i = 0; i < 16; i++) {
		double xx = player.posX + (player.getRNG().nextDouble() - 0.5D) * 64.0D;
		double yy = player.posY + (player.getRNG().nextInt(64) - 32);
		double zz = player.posZ + (player.getRNG().nextDouble() - 0.5D) * 64.0D;
		if (teleportTo(player, xx, yy, zz))
			break;
	}
	return result;
}