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


Java EntityPlayerMP.dropItem方法代码示例

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


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

示例1: execute

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的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


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