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


Java ItemStackHandler.setStackInSlot方法代码示例

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


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

示例1: getChargedDispenserUpgradeDrone

import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
private static EntityDrone getChargedDispenserUpgradeDrone(World world) {
    EntityDrone drone = new EntityDrone(world);

    NBTTagCompound tag = new NBTTagCompound();
    drone.writeEntityToNBT(tag);

    ItemStackHandler upgrades = new ItemStackHandler(9);
    upgrades.setStackInSlot(0, new ItemStack(ItemRegistry.getInstance().getUpgrade(EnumUpgrade.DISPENSER), 64));
    upgrades.setStackInSlot(1, new ItemStack(ItemRegistry.getInstance().getUpgrade(EnumUpgrade.SPEED), 10));
    tag.setTag(ChargeableItemHandler.NBT_UPGRADE_TAG, upgrades.serializeNBT());
    tag.setTag("Inventory", new NBTTagCompound());
    tag.setFloat("currentAir", 100000);

    drone.readEntityFromNBT(tag);
    // FIXME: we really need to get a clientside localization here (on the server side)
    drone.setCustomNameTag(net.minecraft.util.text.translation.I18n.translateToLocal("drone.amadronDeliveryDrone"));

    drone.naturallySpawned = true; // Don't let the drone be dropped when wrenching it.

    return drone;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:22,代码来源:ProgrammedDroneUtils.java

示例2: writeToNBT

import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tag) {

    super.writeToNBT(tag);
    tag.setTag("Items", inventory.serializeNBT());

    NBTTagCompound tankTag = new NBTTagCompound();
    tank.writeToNBT(tankTag);
    tag.setTag("tank", tankTag);

    ItemStackHandler handler = new ItemStackHandler(getFakePlayer().inventory.getSizeInventory());
    for (int i = 0; i < handler.getSlots(); i++) {
        handler.setStackInSlot(i, getFakePlayer().inventory.getStackInSlot(i));
    }
    tag.setTag("droneItems", handler.serializeNBT());

    return tag;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:19,代码来源:TileEntityProgrammableController.java

示例3: retrieveValue

import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
protected ItemStackHandler retrieveValue(Field field, Object te) throws Exception {
    ItemStackHandler handler = (ItemStackHandler) field.get(te);
    ItemStackHandler result = new ItemStackHandler(handler.getSlots());
    for (int i = 0; i < handler.getSlots(); i++) {
        result.setStackInSlot(i, handler.getStackInSlot(i));
    }
    return result;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:10,代码来源:SyncedField.java

示例4: injectValue

import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
protected void injectValue(Field field, Object te, ItemStackHandler value) throws Exception {
    ItemStackHandler handler = (ItemStackHandler) field.get(te);
    for (int i = 0; i < value.getSlots(); i++) {
        handler.setStackInSlot(i, value.getStackInSlot(i));
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:8,代码来源:SyncedField.java

示例5: copyWhenNecessary

import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
protected ItemStackHandler copyWhenNecessary(ItemStackHandler oldValue) {
    ItemStackHandler result = new ItemStackHandler(oldValue.getSlots());
    for (int i = 0; i < oldValue.getSlots(); i++) {
        result.setStackInSlot(i, oldValue.getStackInSlot(i));
    }
    return result;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:9,代码来源:SyncedField.java

示例6: breakBlock

import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{	
	BaseTileEntityHarshenSingleItemInventory te = (BaseTileEntityHarshenSingleItemInventory) worldIn.getTileEntity(pos);
	IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

	if(!worldIn.isRemote)
		if(isBreakNBT(handler.getStackInSlot(0)))
		{
			ItemStackHandler handlerStack = new ItemStackHandler(1);
			handlerStack.setStackInSlot(0, handler.getStackInSlot(0));
			ItemStack stack = new ItemStack(this);
	        String stackName = "";
			NBTTagCompound nbttagcompound = new NBTTagCompound();
			if(handlerStack.getStackInSlot(0).getItem() != Items.AIR)
			{
		        nbttagcompound.setTag("ItemStackHandler", handlerStack.serializeNBT());
		        stackName +=  I18n.translateToLocal(handlerStack.getStackInSlot(0).getItem().getUnlocalizedName() + ".name");
			}
			addNBT(handler.getStackInSlot(0), nbttagcompound, worldIn, pos);
			if(!nbttagcompound.getKeySet().isEmpty() || !handlerStack.getStackInSlot(0).isEmpty())
			{
				stack.setTagCompound(nbttagcompound);
				stackName += extraName(nbttagcompound, handlerStack.getStackInSlot(0).getItem() != Items.AIR);
				stackName = stackName.equals("")? "�r" + getLocalizedName() : "�r" + getLocalizedName() + " (" + stackName + ")";
				stack.setStackDisplayName(stackName);
			}
			if(!creativeBreakMap.containsKey(pos) || !creativeBreakMap.get(pos))
				worldIn.spawnEntity(new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack));
			creativeBreakMap.remove(pos);
		}
		else
			InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), handler.getStackInSlot(0));
	super.breakBlock(worldIn, pos, state);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:36,代码来源:BaseBlockHarshenSingleInventory.java

示例7: test_removeInputsFromInventory_stacks

import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Test
public void test_removeInputsFromInventory_stacks()
{
    ItemStackHandler inv = new ItemStackHandler(2);
    inv.setStackInSlot(0, new ItemStack(Items.APPLE));
    inv.setStackInSlot(1, new ItemStack(Items.STICK, 3));

    RecipeInputImpl input1 = RecipeInputImpl.create(new ItemStack(Items.STICK, 2));
    RecipeInputImpl input2 = RecipeInputImpl.create(new ItemStack(Items.APPLE, 1));
    ItemHelper.removeInputsFromInventory(Lists.newArrayList(input1, input2), inv, 0, 2);

    assertTrue(inv.getStackInSlot(0).isEmpty());
    assertEquals(1, inv.getStackInSlot(1).getCount());
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:15,代码来源:ItemHelperTests.java

示例8: test_removeInputsFromInventory_ore

import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
@Test
public void test_removeInputsFromInventory_ore()
{
    ItemStackHandler inv = new ItemStackHandler(2);
    inv.setStackInSlot(0, new ItemStack(Items.APPLE));
    inv.setStackInSlot(1, new ItemStack(Items.STICK, 3));

    RecipeInputImpl input1 = new RecipeInputImpl("stickWood", 2);
    RecipeInputImpl input2 = RecipeInputImpl.create(new ItemStack(Items.APPLE, 1));
    ItemHelper.removeInputsFromInventory(Lists.newArrayList(input1, input2), inv, 0, 2);

    assertTrue(inv.getStackInSlot(0).isEmpty());
    assertEquals(1, inv.getStackInSlot(1).getCount());
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:15,代码来源:ItemHelperTests.java

示例9: decrStackInInventory

import net.minecraftforge.items.ItemStackHandler; //导入方法依赖的package包/类
public static void decrStackInInventory(ItemStackHandler handler, int slot) {
    if (slot < 0 || slot >= handler.getSlots()) return;
    ItemStack st = handler.getStackInSlot(slot);
    if (st.isEmpty()) return;
    st.setCount(st.getCount() - 1);
    if (st.getCount() <= 0) {
        handler.setStackInSlot(slot, ItemStack.EMPTY);
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:10,代码来源:ItemUtils.java


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