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


Java EntityPlayer.dropPlayerItemWithRandomChoice方法代码示例

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


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

示例1: fillBucket

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private ItemStack fillBucket(ItemStack emptyBuckets, EntityPlayer player, Item fullBucket)
{
    if (player.capabilities.isCreativeMode)
    {
        return emptyBuckets;
    }
    else if (--emptyBuckets.stackSize <= 0)
    {
        return new ItemStack(fullBucket);
    }
    else
    {
        if (!player.inventory.addItemStackToInventory(new ItemStack(fullBucket)))
        {
            player.dropPlayerItemWithRandomChoice(new ItemStack(fullBucket, 1, 0), false);
        }

        return emptyBuckets;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:ItemBucket.java

示例2: onContainerClosed

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called when the container is closed.
 */
public void onContainerClosed(EntityPlayer playerIn)
{
    super.onContainerClosed(playerIn);

    if (!this.worldPointer.isRemote)
    {
        for (int i = 0; i < this.tableInventory.getSizeInventory(); ++i)
        {
            ItemStack itemstack = this.tableInventory.removeStackFromSlot(i);

            if (itemstack != null)
            {
                playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:ContainerEnchantment.java

示例3: onContainerClosed

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called when the container is closed.
 */
public void onContainerClosed(EntityPlayer playerIn)
{
    super.onContainerClosed(playerIn);

    if (!this.theWorld.isRemote)
    {
        for (int i = 0; i < this.inputSlots.getSizeInventory(); ++i)
        {
            ItemStack itemstack = this.inputSlots.removeStackFromSlot(i);

            if (itemstack != null)
            {
                playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:21,代码来源:ContainerRepair.java

示例4: interact

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.bucket && !player.capabilities.isCreativeMode && !this.isChild())
    {
        if (itemstack.stackSize-- == 1)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.milk_bucket));
        }
        else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket)))
        {
            player.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false);
        }

        return true;
    }
    else
    {
        return super.interact(player);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:26,代码来源:EntityCow.java

示例5: onContainerClosed

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called when the container is closed.
 */
public void onContainerClosed(EntityPlayer playerIn)
{
    super.onContainerClosed(playerIn);

    for (int i = 0; i < 4; ++i)
    {
        ItemStack itemstack = this.craftMatrix.removeStackFromSlot(i);

        if (itemstack != null)
        {
            playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
        }
    }

    this.craftResult.setInventorySlotContents(0, (ItemStack)null);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:ContainerPlayer.java

示例6: onContainerClosed

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called when the container is closed.
 */
public void onContainerClosed(EntityPlayer playerIn)
{
    InventoryPlayer inventoryplayer = playerIn.inventory;

    if (inventoryplayer.getItemStack() != null)
    {
        playerIn.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), false);
        inventoryplayer.setItemStack((ItemStack)null);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:14,代码来源:Container.java

示例7: onContainerClosed

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called when the container is closed.
 */
@Override
public void onContainerClosed(EntityPlayer player) {
	super.onContainerClosed(player);

	if (!world.isRemote)
		for (int i = 0; i < tableInventory.getSizeInventory(); i++) {
			ItemStack stack = tableInventory.getStackInSlotOnClosing(i);
			if (stack != null)
				player.dropPlayerItemWithRandomChoice(stack, false);
		}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:15,代码来源:ContainerEnchantment.java

示例8: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    ItemStack itemstack = new ItemStack(Items.filled_map, 1, worldIn.getUniqueDataId("map"));
    String s = "map_" + itemstack.getMetadata();
    MapData mapdata = new MapData(s);
    worldIn.setItemData(s, mapdata);
    mapdata.scale = 0;
    mapdata.calculateMapCenter(playerIn.posX, playerIn.posZ, mapdata.scale);
    mapdata.dimension = (byte)worldIn.provider.getDimensionId();
    mapdata.markDirty();
    --itemStackIn.stackSize;

    if (itemStackIn.stackSize <= 0)
    {
        return itemstack;
    }
    else
    {
        if (!playerIn.inventory.addItemStackToInventory(itemstack.copy()))
        {
            playerIn.dropPlayerItemWithRandomChoice(itemstack, false);
        }

        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
        return itemStackIn;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:31,代码来源:ItemEmptyMap.java

示例9: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);

    if (movingobjectposition == null)
    {
        return itemStackIn;
    }
    else
    {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
        {
            BlockPos blockpos = movingobjectposition.getBlockPos();

            if (!worldIn.isBlockModifiable(playerIn, blockpos))
            {
                return itemStackIn;
            }

            if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
            {
                return itemStackIn;
            }

            if (worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.water)
            {
                --itemStackIn.stackSize;
                playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);

                if (itemStackIn.stackSize <= 0)
                {
                    return new ItemStack(Items.potionitem);
                }

                if (!playerIn.inventory.addItemStackToInventory(new ItemStack(Items.potionitem)))
                {
                    playerIn.dropPlayerItemWithRandomChoice(new ItemStack(Items.potionitem, 1, 0), false);
                }
            }
        }

        return itemStackIn;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:48,代码来源:ItemGlassBottle.java

示例10: processCommand

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 2)
    {
        throw new WrongUsageException("commands.give.usage", new Object[0]);
    }
    else
    {
        EntityPlayer entityplayer = getPlayer(sender, args[0]);
        Item item = getItemByText(sender, args[1]);
        int i = args.length >= 3 ? parseInt(args[2], 1, 64) : 1;
        int j = args.length >= 4 ? parseInt(args[3]) : 0;
        ItemStack itemstack = new ItemStack(item, i, j);

        if (args.length >= 5)
        {
            String s = getChatComponentFromNthArg(sender, args, 4).getUnformattedText();

            try
            {
                itemstack.setTagCompound(JsonToNBT.getTagFromJson(s));
            }
            catch (NBTException nbtexception)
            {
                throw new CommandException("commands.give.tagError", new Object[] {nbtexception.getMessage()});
            }
        }

        boolean flag = entityplayer.inventory.addItemStackToInventory(itemstack);

        if (flag)
        {
            entityplayer.worldObj.playSoundAtEntity(entityplayer, "random.pop", 0.2F, ((entityplayer.getRNG().nextFloat() - entityplayer.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F);
            entityplayer.inventoryContainer.detectAndSendChanges();
        }

        if (flag && itemstack.stackSize <= 0)
        {
            itemstack.stackSize = 1;
            sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i);
            EntityItem entityitem1 = entityplayer.dropPlayerItemWithRandomChoice(itemstack, false);

            if (entityitem1 != null)
            {
                entityitem1.func_174870_v();
            }
        }
        else
        {
            sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, i - itemstack.stackSize);
            EntityItem entityitem = entityplayer.dropPlayerItemWithRandomChoice(itemstack, false);

            if (entityitem != null)
            {
                entityitem.setNoPickupDelay();
                entityitem.setOwner(entityplayer.getName());
            }
        }

        notifyOperators(sender, this, "commands.give.success", new Object[] {itemstack.getChatComponent(), Integer.valueOf(i), entityplayer.getName()});
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:66,代码来源:CommandGive.java


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