コード例 #1
0
ファイル: BuildCraftCore.java プロジェクト: GWLAN/BuildCraft
  public void loadRecipes() {
    CoreProxy.proxy.addCraftingRecipe(
        new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', "ingotIron", 'G', "gearStone");
    CoreProxy.proxy.addCraftingRecipe(
        new ItemStack(woodenGearItem), " S ", "S S", " S ", 'S', "stickWood");
    CoreProxy.proxy.addCraftingRecipe(
        new ItemStack(stoneGearItem), " I ", "IGI", " I ", 'I', "cobblestone", 'G', "gearWood");
    CoreProxy.proxy.addCraftingRecipe(
        new ItemStack(ironGearItem), " I ", "IGI", " I ", 'I', "ingotIron", 'G', "gearStone");
    CoreProxy.proxy.addCraftingRecipe(
        new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I', "ingotGold", 'G', "gearIron");
    CoreProxy.proxy.addCraftingRecipe(
        new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', "gemDiamond", 'G', "gearGold");
    CoreProxy.proxy.addCraftingRecipe(
        new ItemStack(mapLocationItem), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y', "dyeYellow");

    CoreProxy.proxy.addCraftingRecipe(
        new ItemStack(engineBlock, 1, 0),
        "www",
        " g ",
        "GpG",
        'w',
        "plankWood",
        'g',
        "blockGlass",
        'G',
        "gearWood",
        'p',
        Blocks.piston);

    CoreProxy.proxy.addCraftingRecipe(
        new ItemStack(paintbrushItem),
        " iw",
        " gi",
        "s  ",
        's',
        "stickWood",
        'g',
        "gearWood",
        'w',
        new ItemStack(Blocks.wool, 1, 0),
        'i',
        Items.string);

    ItemStack anyPaintbrush = new ItemStack(paintbrushItem, 1, OreDictionary.WILDCARD_VALUE);

    for (int i = 0; i < 16; i++) {
      ItemStack outputStack = new ItemStack(paintbrushItem);
      NBTUtils.getItemData(outputStack).setByte("color", (byte) i);
      CoreProxy.proxy.addShapelessRecipe(outputStack, anyPaintbrush, EnumColor.fromId(i).getDye());
    }

    if (Loader.isModLoaded("BuildCraft|Silicon")) {
      CoreSiliconRecipes.loadSiliconRecipes();
    } else {
      CoreProxy.proxy.addCraftingRecipe(
          new ItemStack(listItem), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y', "dyeGreen");
    }
  }
コード例 #2
0
ファイル: ItemList.java プロジェクト: Jamefrus/BuildCraft
  @Override
  public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
    NBTTagCompound nbt = NBTUtils.getItemData(stack);

    if (nbt.hasKey("label")) {
      list.add(nbt.getString("label"));
    }
  }
コード例 #3
0
 public PackageFontRenderer(ItemStack packageStack) {
   super(
       mc.gameSettings,
       new ResourceLocation("textures/font/ascii.png"),
       mc.getTextureManager(),
       mc.fontRenderer.getUnicodeFlag());
   this.packageStack = packageStack;
   this.pkgTag = NBTUtils.getItemData(packageStack);
 }
コード例 #4
0
ファイル: ItemList.java プロジェクト: Jamefrus/BuildCraft
  public static void saveLine(ItemStack stack, StackLine line, int index) {
    NBTTagCompound nbt = NBTUtils.getItemData(stack);

    nbt.setBoolean("written", true);

    NBTTagCompound lineNBT = new NBTTagCompound();
    line.writeToNBT(lineNBT);
    nbt.setTag("line[" + index + "]", lineNBT);
  }
コード例 #5
0
  @Override
  public int getRequiredEnergy() {
    ItemStack stack = this.getStackInSlot(0);
    ItemStack output = this.getStackInSlot(1);
    if (output != null && output.stackSize == output.getMaxStackSize()) {
      return 0;
    }
    if (stack != null && stack.getItem() != null) {
      if (stack.getItem() instanceof ItemPackage) {
        // tagMap size
        return 400 * NBTUtils.getItemData(stack).func_150296_c().size();
      } else {
        return 400;
      }
    }

    return 0;
  }
コード例 #6
0
ファイル: ItemList.java プロジェクト: Jamefrus/BuildCraft
  public static StackLine[] getLines(ItemStack stack) {
    if (LINE_CACHE.containsKey(stack)) {
      return LINE_CACHE.get(stack);
    }

    StackLine[] result = new StackLine[6];

    for (int i = 0; i < 6; ++i) {
      result[i] = new StackLine();
    }

    NBTTagCompound nbt = NBTUtils.getItemData(stack);

    if (nbt.hasKey("written")) {
      for (int i = 0; i < 6; ++i) {
        result[i].readFromNBT(nbt.getCompoundTag("line[" + i + "]"));
      }
    }

    LINE_CACHE.put(stack, result);

    return result;
  }
コード例 #7
0
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (getEnergy() >= getRequiredEnergy() && getEnergy() > 0) {
      ItemStack input = this.getStackInSlot(0);

      if (input == null) {
        return;
      }

      EntityPlayer internalPlayer = getInternalPlayer().get();

      if (craftSlot == null) {
        craftSlot = new SlotCrafting(internalPlayer, crafting, this, 1, 0, 0);
      }

      if (input.getItem() instanceof ItemPackage) {
        // Try a recipe made out of the package's contents
        NBTTagCompound tag = NBTUtils.getItemData(input);
        for (int i = 0; i < 9; i++) {
          if (tag.hasKey("item" + i)) {
            ItemStack is = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("item" + i));
            if (is != null) {
              crafting.setInventorySlotContents(i, is);
            } else {
              return;
            }
          } else {
            crafting.setInventorySlotContents(i, null);
          }
        }
      } else {
        // Try a shapeless recipe made from just that item
        ItemStack input2 = input.copy();
        input2.stackSize = 1;
        crafting.setInventorySlotContents(0, input2);
        for (int i = 1; i < 9; i++) {
          crafting.setInventorySlotContents(i, null);
        }
      }

      IRecipe recipe = crafting.findRecipe();
      ItemStack result = recipe != null ? recipe.getCraftingResult(crafting).copy() : null;

      addEnergy(-getRequiredEnergy());

      if (result != null) {
        craftSlot.onPickupFromSlot(internalPlayer, result);
        handleLeftoverItems(crafting);
        handleLeftoverItems(internalPlayer.inventory);

        for (int i = 1; i <= 4; i++) {
          ItemStack inside = inv.getStackInSlot(i);

          if (inside == null || inside.stackSize <= 0) {
            inv.setInventorySlotContents(i, result.copy());
            result.stackSize = 0;
            break;
          } else if (StackHelper.canStacksMerge(inside, result)) {
            result.stackSize -= StackHelper.mergeStacks(result, inside, true);

            if (result.stackSize == 0) {
              break;
            }
          }
        }

        if (result.stackSize > 0) {
          EntityItem entityitem =
              new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, result.copy());

          worldObj.spawnEntityInWorld(entityitem);
          result.stackSize = 0;
        }
        decrStackSize(0, 1);
      } else {
        ItemStack outputSlot = getStackInSlot(1);
        if (outputSlot == null) {
          setInventorySlotContents(1, getStackInSlot(0));
          setInventorySlotContents(0, null);
        }
      }
    }
  }
コード例 #8
0
ファイル: ItemList.java プロジェクト: Jamefrus/BuildCraft
 @Override
 public String getLabel(ItemStack stack) {
   return NBTUtils.getItemData(stack).getString("label");
 }
コード例 #9
0
ファイル: ItemList.java プロジェクト: Jamefrus/BuildCraft
  public static void saveLabel(ItemStack stack, String text) {
    NBTTagCompound nbt = NBTUtils.getItemData(stack);

    nbt.setString("label", text);
  }
コード例 #10
0
ファイル: ItemList.java プロジェクト: Jamefrus/BuildCraft
 @Override
 public IIcon getIconIndex(ItemStack stack) {
   return icons[NBTUtils.getItemData(stack).hasKey("written") ? 1 : 0];
 }