本文整理汇总了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);
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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]);
}
}
示例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;
}
}