• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ItemInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中li.cil.oc.api.detail.ItemInfo的典型用法代码示例。如果您正苦于以下问题:Java ItemInfo类的具体用法?Java ItemInfo怎么用?Java ItemInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ItemInfo类属于li.cil.oc.api.detail包,在下文中一共展示了ItemInfo类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getItem

import li.cil.oc.api.detail.ItemInfo; //导入依赖的package包/类
public static ItemStack getItem(String name) {
    ItemInfo ii = li.cil.oc.api.Items.get(name);
    if (ii == null) {
        CivLog.warn("Attempt to get the open computers item \"" + name + "\" failed!");
        CivLog.warn("Called by: " + Thread.currentThread().getStackTrace()[1]);
        return null;
    }
    return ii.createItemStack(1);
}
 
开发者ID:AlexIIL,项目名称:CivCraft,代码行数:10,代码来源:OpenComputersCompat.java


示例2: onItemUse

import li.cil.oc.api.detail.ItemInfo; //导入依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
	if(stack != null && stack.getItem() instanceof ItemPackage && player.isSneaking() && !world.isRemote) {
		NBTTagCompound tag = stack.getTagCompound();
		if(tag == null || !tag.hasKey("t")) {
			player.addChatMessage(new ChatComponentTranslation("chat.cheatycomputers.invalid"));
			return true;
		}

		int tier = tag.getInteger("t");

		final int caseX, caseY, caseZ;

		if(world.getBlock(x, y, z).isReplaceable(world, x, y, z)) {
			caseX = x;
			caseY = y;
			caseZ = z;
		} else {
			ForgeDirection dir = ForgeDirection.getOrientation(side);
			caseX = x + dir.offsetX;
			caseY = y + dir.offsetY;
			caseZ = z + dir.offsetZ;
		}

		if(!world.getBlock(caseX, caseY, caseZ).isReplaceable(world, caseX, caseY, caseZ)) {
			player.addChatMessage(new ChatComponentTranslation("chat.cheatycomputers.obstructed"));
			return true;
		}
		Block block = ScalaProxy.getCase(tier).block();
		world.setBlock(caseX, caseY, caseZ, block);
		world.playSoundEffect((double) ((float) caseX + 0.5F), (double) ((float) caseY + 0.5F), (double) ((float) caseZ + 0.5F), block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);

		TileEntity tile = world.getTileEntity(caseX, caseY, caseZ);
		if(tile instanceof Rotatable) {
			ScalaProxy.setFacing(((Rotatable) tile), player);
		}

		Network.joinOrCreateNetwork(world.getTileEntity(caseX, caseY, caseZ));

		InventorySlots.InventorySlot[] slots = InventorySlots.computer()[tier];
		for(InventorySlots.InventorySlot slot : slots) {
			//NBTTagList list = tag.getTagList(slot.slot(), NBT.TAG_COMPOUND);
			NBTTagList list = tag.getTagList(slot.slot(), NBT.TAG_STRING);
			int count = ScalaProxy.countSlots(slots, slot.slot());
			for(int i = 0; i < count; i++) {
				//NBTTagCompound data = list.getCompoundTagAt(i);
				//ItemStack toAdd = ItemStack.loadItemStackFromNBT(data);
				ItemInfo info = Items.get(list.getStringTagAt(i));
				if(info != null) {
					ItemStack toAdd = info.createItemStack(1);
					if(toAdd != null) {
						ScalaProxy.insertIntoInventoryAt(toAdd.copy(), new BlockPosition(caseX, caseY, caseZ, Option.apply(world)));
						//InventoryUtils.insertIntoInventoryAt(toAdd.copy(),
						//	new BlockPosition(x, y, z, Option.apply(world)), Option.<ForgeDirection>empty(), 64, false);
					}
				}
			}
		}
		if(!player.capabilities.isCreativeMode) {
			player.inventory.decrStackSize(player.inventory.currentItem, 1);
		}
		return true;
	}

	return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
 
开发者ID:Vexatos,项目名称:CheatyComputers,代码行数:67,代码来源:ItemPackage.java


示例3: get

import li.cil.oc.api.detail.ItemInfo; //导入依赖的package包/类
/**
 * Get a descriptor object for the block or item with the specified name.
 * <p/>
 * The names are the same as the ones used in the recipe files. An info
 * object can be used to retrieve both the block and item instance of the
 * item, if available. It can also be used to create a new item stack of
 * the item.
 * <p/>
 * Note that these methods should <em>not</em> be called in the pre-init phase,
 * since the {@link li.cil.oc.api.API#items} may not have been initialized
 * at that time. Only start calling these methods in the init phase or later.
 *
 * @param name the name of the item to get the descriptor for.
 * @return the descriptor for the item with the specified name, or
 * <tt>null</tt> if there is no such item.
 */
public static ItemInfo get(String name) {
    if (API.items != null)
        return API.items.get(name);
    return null;
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:22,代码来源:Items.java



注:本文中的li.cil.oc.api.detail.ItemInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TerminalPosition类代码示例发布时间:2022-05-22
下一篇:
Java UIService类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap