当前位置: 首页>>代码示例>>Java>>正文


Java EntityItem.setPickupDelay方法代码示例

本文整理汇总了Java中net.minecraft.entity.item.EntityItem.setPickupDelay方法的典型用法代码示例。如果您正苦于以下问题:Java EntityItem.setPickupDelay方法的具体用法?Java EntityItem.setPickupDelay怎么用?Java EntityItem.setPickupDelay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.item.EntityItem的用法示例。


在下文中一共展示了EntityItem.setPickupDelay方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performEffect

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
	if (rtrace.typeOfHit == Type.ENTITY && rtrace.entityHit instanceof EntityLivingBase) {
		EntityLivingBase entity = (EntityLivingBase) rtrace.entityHit;
		EnumHand hand = null;
		if (!entity.getHeldItemMainhand().isEmpty()) hand = EnumHand.MAIN_HAND;
		else if (!entity.getHeldItemOffhand().isEmpty()) hand = EnumHand.OFF_HAND;
		if (hand != null) {
			ItemStack stack = entity.getHeldItem(hand).copy();
			entity.setHeldItem(hand, ItemStack.EMPTY);
			if (!(entity instanceof EntityPlayer) && stack.isItemStackDamageable() && stack.getItemDamage() == 0) {
				stack.setItemDamage((int) (stack.getMaxDamage() * (0.5D + 0.5D * Math.random())));
			}
			EntityItem ei = new EntityItem(world, entity.posX, entity.posY, entity.posZ, stack);
			ei.setPickupDelay(200);
			ei.setNoDespawn();
			if (!world.isRemote) world.spawnEntity(ei);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:21,代码来源:SpellDisarming.java

示例2: performEffect

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public void performEffect(EntityLivingBase entityLivingBaseIn, int p_76394_2_){
    if (!entityLivingBaseIn.world.isRemote){
        EntityItem item = new EntityItem(entityLivingBaseIn.world, entityLivingBaseIn.posX + (entityLivingBaseIn.getLookVec().xCoord * 0.2F), entityLivingBaseIn.posY + entityLivingBaseIn.getEyeHeight() - 0.7F, entityLivingBaseIn.posZ + (entityLivingBaseIn.getLookVec().zCoord), new ItemStack(loot_table[(int) (Math.random() * loot_table.length)], 1));
        item.setPickupDelay(15);
        entityLivingBaseIn.world.spawnEntity(item);
    }
}
 
开发者ID:DeflatedPickles-Old-Repositories,项目名称:JustJunk,代码行数:9,代码来源:PotionSick.java

示例3: ejectStack

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
public static void ejectStack(World world, double x, double y, double z, ItemStack stack, int pickupDelay) {
    EntityItem item = new EntityItem(world, x, y, z, stack);
    float velocity = 0.05F;
    item.motionX = (double) ((float) world.rand.nextGaussian() * velocity);
    item.motionY = (double) ((float) world.rand.nextGaussian() * velocity + 0.2F);
    item.motionZ = (double) ((float) world.rand.nextGaussian() * velocity);
    item.setPickupDelay(pickupDelay);
    world.spawnEntity(item);
}
 
开发者ID:primetoxinz,项目名称:Meltery,代码行数:10,代码来源:Utils.java

示例4: giveItemToPlayer

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
/**
 * Inserts the given itemstack into the players inventory.
 * If the inventory can't hold it, the item will be dropped in the world at the players position.
 *
 * @param player The player to give the item to
 * @param stack  The itemstack to insert
 */
public static void giveItemToPlayer(EntityPlayer player, ItemStack stack, int preferredSlot)
{
    IItemHandler inventory = new PlayerMainInvWrapper(player.inventory);
    World world = player.worldObj;

    // try adding it into the inventory
    ItemStack remainder = stack;
    // insert into preferred slot first
    if(preferredSlot >= 0)
    {
        remainder = inventory.insertItem(preferredSlot, stack, false);
    }
    // then into the inventory in general
    if(remainder != null)
    {
        remainder = insertItemStacked(inventory, remainder, false);
    }

    // play sound if something got picked up
    if (remainder == null || remainder.stackSize != stack.stackSize)
    {
        world.playSound(player, player.posX, player.posY, player.posZ,
                SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
    }

    // drop remaining itemstack into the world
    if (remainder != null && !world.isRemote)
    {
        EntityItem entityitem = new EntityItem(world, player.posX, player.posY + 0.5, player.posZ, stack);
        entityitem.setPickupDelay(40);
        entityitem.motionX = 0;
        entityitem.motionZ = 0;

        world.spawnEntityInWorld(entityitem);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:44,代码来源:ItemHandlerHelper.java

示例5: processingLogic

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
public boolean processingLogic(ItemStack stack) {
	if (!isBoiling() || hasIngredients() || stack.getCount() > 8192) return false;
	Map<Item, ItemValidator<ItemStack>> processing = CauldronRegistry.getItemProcessing(inv.getInnerFluid());
	if (processing != null && processing.containsKey(stack.getItem())) {
		ItemValidator<ItemStack> validator = processing.get(stack.getItem());
		Optional<ItemStack> optional = validator.getMatchFor(stack);
		if (optional.isPresent()) {
			ItemStack out = optional.get().copy();
			if (stack.isItemDamaged() && out.isItemStackDamageable())
				out.setItemDamage(stack.getItemDamage());
			int fluidAmount = inv.getFluidAmount();
			int fluidTaken = 250;
			out.setCount(0);

			if (stack.getCount() <= 16) {
				out.setCount(stack.getCount());
				stack.setCount(0);
			} else {
				while (stack.getCount() > 0 && fluidTaken <= fluidAmount) {
					stack.shrink(1);
					out.grow(1);
					if (out.getCount() % 16 == 0) {
						if (fluidTaken >= fluidAmount) {
							fluidTaken = fluidAmount;
							break;
						}
						fluidTaken += 250;
					}
				}
			}

			if (out.getCount() > 0) {
				final double x = getPos().getX();
				final double y = getPos().getY() + 1D;
				final double z = getPos().getZ();
				final EntityItem item = new EntityItem(world, x + 0.5D, y, z + 0.5D, out);
				item.motionX = world.rand.nextDouble() * 2 - 1;
				item.motionZ = world.rand.nextDouble() * 2 - 1;
				item.motionY = 0.1D;
				item.setPickupDelay(0);
				world.spawnEntity(item);

				play(SoundEvents.BLOCK_FIRE_EXTINGUISH, 1F, 1F);
				for (int i = 0; i < 4; i++) {
					PacketHandler.spawnParticle(ParticleF.STEAM, world, x + world.rand.nextFloat(), getParticleLevel(), z + world.rand.nextFloat(), 5, 0, 0, 0);
				}

				inv.drain(fluidTaken, true);
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:56,代码来源:TileCauldron.java

示例6: addDrop

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private void addDrop(LivingDropsEvent event, ItemStack drop) {
	EntityItem entityitem = new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, drop);
	entityitem.setPickupDelay(10);
	event.getDrops().add(entityitem);
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:6,代码来源:ItemAthame.java

示例7: spawnItem

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private static void spawnItem(EntityLivingBase entity, ItemStack is) {
	EntityItem ei = new EntityItem(entity.world, entity.posX, entity.posY, entity.posZ, is);
	ei.setPickupDelay(100);
	entity.world.spawnEntity(ei);
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:6,代码来源:DisrobingBrew.java

示例8: dropItem

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
public EntityItem dropItem(ItemStack droppedItem, boolean dropAround, boolean traceItem)
{
    if (droppedItem == null)
    {
        return null;
    }
    else if (droppedItem.stackSize == 0)
    {
        return null;
    }
    else
    {
        double d0 = this.posY - 0.30000001192092896D + (double)this.getEyeHeight();
        EntityItem entityitem = new EntityItem(this.worldObj, this.posX, d0, this.posZ, droppedItem);
        entityitem.setPickupDelay(40);

        if (traceItem)
        {
            entityitem.setThrower(this.getName());
        }

        if (dropAround)
        {
            float f = this.rand.nextFloat() * 0.5F;
            float f1 = this.rand.nextFloat() * (float)Math.PI * 2.0F;
            entityitem.motionX = (double)(-MathHelper.sin(f1) * f);
            entityitem.motionZ = (double)(MathHelper.cos(f1) * f);
            entityitem.motionY = 0.20000000298023224D;
        }
        else
        {
            float f2 = 0.3F;
            entityitem.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f2);
            entityitem.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f2);
            entityitem.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * f2 + 0.1F);
            float f3 = this.rand.nextFloat() * (float)Math.PI * 2.0F;
            f2 = 0.02F * this.rand.nextFloat();
            entityitem.motionX += Math.cos((double)f3) * (double)f2;
            entityitem.motionY += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            entityitem.motionZ += Math.sin((double)f3) * (double)f2;
        }

        this.joinEntityItemWithWorld(entityitem);

        if (traceItem)
        {
            this.triggerAchievement(StatList.dropStat);
        }

        return entityitem;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:53,代码来源:EntityPlayer.java

示例9: dropItem

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Nullable
public EntityItem dropItem(ItemStack droppedItem, boolean dropAround, boolean traceItem)
{
    if (droppedItem.func_190926_b())
    {
        return null;
    }
    else
    {
        double d0 = this.posY - 0.30000001192092896D + (double)this.getEyeHeight();
        EntityItem entityitem = new EntityItem(this.world, this.posX, d0, this.posZ, droppedItem);
        entityitem.setPickupDelay(40);

        if (traceItem)
        {
            entityitem.setThrower(this.getName());
        }

        if (dropAround)
        {
            float f = this.rand.nextFloat() * 0.5F;
            float f1 = this.rand.nextFloat() * ((float)Math.PI * 2F);
            entityitem.motionX = (double)(-MathHelper.sin(f1) * f);
            entityitem.motionZ = (double)(MathHelper.cos(f1) * f);
            entityitem.motionY = 0.20000000298023224D;
        }
        else
        {
            float f2 = 0.3F;
            entityitem.motionX = (double)(-MathHelper.sin(this.rotationYaw * 0.017453292F) * MathHelper.cos(this.rotationPitch * 0.017453292F) * f2);
            entityitem.motionZ = (double)(MathHelper.cos(this.rotationYaw * 0.017453292F) * MathHelper.cos(this.rotationPitch * 0.017453292F) * f2);
            entityitem.motionY = (double)(-MathHelper.sin(this.rotationPitch * 0.017453292F) * f2 + 0.1F);
            float f3 = this.rand.nextFloat() * ((float)Math.PI * 2F);
            f2 = 0.02F * this.rand.nextFloat();
            entityitem.motionX += Math.cos((double)f3) * (double)f2;
            entityitem.motionY += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            entityitem.motionZ += Math.sin((double)f3) * (double)f2;
        }

        ItemStack itemstack = this.dropItemAndGetStack(entityitem);

        if (traceItem)
        {
            if (!itemstack.func_190926_b())
            {
                this.addStat(StatList.getDroppedObjectStats(itemstack.getItem()), droppedItem.func_190916_E());
            }

            this.addStat(StatList.DROP);
        }

        return entityitem;
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:55,代码来源:EntityPlayer.java

示例10: addDrop

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
private void addDrop(LivingDropsEvent event, ItemStack drop) {
	
	EntityItem ei = new EntityItem(event.getEntityLiving().worldObj, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, drop);
	ei.setPickupDelay(10);
	event.getDrops().add(ei);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:7,代码来源:UCEventHandlerServer.java

示例11: execute

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	if (args.length < 1)
		throw new WrongUsageException(getUsage(sender), new Object[0]);
	try {
		ItemStack item = ItemFromData.getNewStack(args[0]);
		NBTTagCompound attributes = item.getTagCompound().getCompoundTag("Attributes");
		EntityPlayerMP entityplayermp = args.length > 1 ? getPlayer(server, sender, args[1])
				: getCommandSenderAsPlayer(sender);
		for (int i = 2; i < args.length; i++) {
			String[] attr = args[i].split(":");
			if(attr.length==2){
				if(attr[0].equals("u"))
					item.getTagCompound().setByte("UEffect", Byte.parseByte(attr[1]));
				else if(MapList.nameToAttribute.containsKey(attr[0]))
					attributes.setFloat(Integer.toString(MapList.nameToAttribute.get(attr[0]).id), Float.parseFloat(attr[1]));
				else if(TF2Attribute.attributes[Integer.parseInt(attr[0])]!=null)
					attributes.setFloat(attr[0], Float.parseFloat(attr[1]));
				
			}
			else if(attr[0].equals("a"))
				item.getTagCompound().setBoolean("Australium", true);
			else if(attr[0].equals("s"))
				item.getTagCompound().setBoolean("Strange", true);
			else if(attr[0].equals("v"))
				item.getTagCompound().setBoolean("Valve", true);
				
		}
		
		EntityItem entityitem = entityplayermp.dropItem(item, false);
		entityitem.setPickupDelay(0);
		/*Chunk chunk=entityplayermp.world.getChunkFromBlockCoords(entityplayermp.getPosition());
		int ausCount=0;
		int leadCount=0;
		int coppCount=0;
		int diaCount=0;
		for(int x=0;x<16;x++){
			for(int y=0; y<256;y++){
				for(int z=0; z<16;z++){
					IBlockState state=chunk.getBlockState(x, y, z);
					if(state.getBlock()==TF2weapons.blockAustraliumOre)
						ausCount++;
					else if(state.getBlock()==TF2weapons.blockLeadOre)
						leadCount++;
					else if(state.getBlock()==TF2weapons.blockCopperOre)
						coppCount++;
					else if(state.getBlock()==Blocks.DIAMOND_ORE)
						diaCount++;
				}
			}
		}*/
		
		// notifyCommandListener(sender, this, "Found ores:"+ausCount+" "+leadCount+" "+coppCount+" "+diaCount, new Object[0]);
		// entityitem.func_145797_a(entityplayermp.getCommandSenderName());
		// func_152373_a(p_71515_1_, this, "commands.giveweapon.success",
		// new Object[] {item.func_151000_E(),
		// entityplayermp.getCommandSenderName()});
	} catch (Exception e) {
		throw new WrongUsageException(getUsage(sender), new Object[0]);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:62,代码来源:CommandGiveWeapon.java

示例12: dropItem

import net.minecraft.entity.item.EntityItem; //导入方法依赖的package包/类
@Nullable
public EntityItem dropItem(@Nullable ItemStack droppedItem, boolean dropAround, boolean traceItem)
{
    if (droppedItem == null)
    {
        return null;
    }
    else if (droppedItem.stackSize == 0)
    {
        return null;
    }
    else
    {
        double d0 = this.posY - 0.30000001192092896D + (double)this.getEyeHeight();
        EntityItem entityitem = new EntityItem(this.worldObj, this.posX, d0, this.posZ, droppedItem);
        entityitem.setPickupDelay(40);

        if (traceItem)
        {
            entityitem.setThrower(this.getName());
        }

        if (dropAround)
        {
            float f = this.rand.nextFloat() * 0.5F;
            float f1 = this.rand.nextFloat() * ((float)Math.PI * 2F);
            entityitem.motionX = (double)(-MathHelper.sin(f1) * f);
            entityitem.motionZ = (double)(MathHelper.cos(f1) * f);
            entityitem.motionY = 0.20000000298023224D;
        }
        else
        {
            float f2 = 0.3F;
            entityitem.motionX = (double)(-MathHelper.sin(this.rotationYaw * 0.017453292F) * MathHelper.cos(this.rotationPitch * 0.017453292F) * f2);
            entityitem.motionZ = (double)(MathHelper.cos(this.rotationYaw * 0.017453292F) * MathHelper.cos(this.rotationPitch * 0.017453292F) * f2);
            entityitem.motionY = (double)(-MathHelper.sin(this.rotationPitch * 0.017453292F) * f2 + 0.1F);
            float f3 = this.rand.nextFloat() * ((float)Math.PI * 2F);
            f2 = 0.02F * this.rand.nextFloat();
            entityitem.motionX += Math.cos((double)f3) * (double)f2;
            entityitem.motionY += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            entityitem.motionZ += Math.sin((double)f3) * (double)f2;
        }

        ItemStack itemstack = this.dropItemAndGetStack(entityitem);

        if (traceItem)
        {
            if (itemstack != null)
            {
                this.addStat(StatList.getDroppedObjectStats(itemstack.getItem()), droppedItem.stackSize);
            }

            this.addStat(StatList.DROP);
        }

        return entityitem;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:59,代码来源:EntityPlayer.java


注:本文中的net.minecraft.entity.item.EntityItem.setPickupDelay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。