@Override
  protected void onCrafting(ItemStack par1ItemStack) {
    par1ItemStack.onCrafting(thePlayer.worldObj, thePlayer, stackSize);

    if (!thePlayer.worldObj.isRemote) {
      int i = stackSize;
      float f = MaterializerRecipes.instance().getExperience(par1ItemStack);
      int j;

      if (f == 0.0F) i = 0;
      else if (f < 1.0F) {
        j = MathHelper.floor_float(i * f);

        if (j < MathHelper.ceiling_float_int(i * f) && (float) Math.random() < i * f - j) ++j;

        i = j;
      }

      while (i > 0) {
        j = EntityXPOrb.getXPSplit(i);
        i -= j;
        thePlayer.worldObj.spawnEntityInWorld(
            new EntityXPOrb(
                thePlayer.worldObj,
                thePlayer.posX,
                thePlayer.posY + 0.5D,
                thePlayer.posZ + 0.5D,
                j));
      }
    }

    stackSize = 0;

    MinecraftForge.EVENT_BUS.post(new ACEvents.ItemMaterializedEvent(thePlayer, par1ItemStack));
  }
 /** the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */
 protected void onCrafting(ItemStack par1ItemStack) {
   par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b);
   if (!this.thePlayer.worldObj.isRemote) {
     int var2 = this.field_75228_b;
     float var3 = RecipesCoffeeGrinder.smelting().getExperience(par1ItemStack.itemID);
     int var4;
     if (var3 == 0.0F) {
       var2 = 0;
     } else if (var3 < 1.0F) {
       var4 = MathHelper.floor_float((float) var2 * var3);
       if (var4 < MathHelper.ceiling_float_int((float) var2 * var3)
           && (float) Math.random() < (float) var2 * var3 - (float) var4) {
         ++var4;
       }
       var2 = var4;
     }
     while (var2 > 0) {
       var4 = EntityXPOrb.getXPSplit(var2);
       var2 -= var4;
       this.thePlayer.worldObj.spawnEntityInWorld(
           new EntityXPOrb(
               this.thePlayer.worldObj,
               this.thePlayer.posX,
               this.thePlayer.posY + 0.5D,
               this.thePlayer.posZ + 0.5D,
               var4));
     }
   }
   this.field_75228_b = 0;
 }
Exemple #3
0
 /*     */ protected void onCrafting(ItemStack p_75208_1_) /*     */ {
   /*  69 */ p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b);
   /*     */
   /*  71 */ if (!this.thePlayer.worldObj.isRemote)
   /*     */ {
     /*  73 */ int i = this.field_75228_b;
     /*  74 */ float f = OvenRecipes.smelting().func_151398_b(p_75208_1_);
     /*     */
     /*     */
     /*  77 */ if (f == 0.0F)
     /*     */ {
       /*  79 */ i = 0;
       /*     */ }
     /*  81 */ else if (f < 1.0F)
     /*     */ {
       /*  83 */ int j = net.minecraft.util.MathHelper.floor_float(i * f);
       /*     */
       /*  85 */ if ((j < net.minecraft.util.MathHelper.ceiling_float_int(i * f))
           && ((float) Math.random() < i * f - j))
       /*     */ {
         /*  87 */ j++;
         /*     */ }
       /*     */
       /*  90 */ i = j;
       /*     */ }
     /*     */
     /*  93 */ while (i > 0)
     /*     */ {
       /*  95 */ int j = EntityXPOrb.getXPSplit(i);
       /*  96 */ i -= j;
       /*  97 */ this.thePlayer.worldObj.spawnEntityInWorld(
           new EntityXPOrb(
               this.thePlayer.worldObj,
               this.thePlayer.posX,
               this.thePlayer.posY + 0.5D,
               this.thePlayer.posZ + 0.5D,
               j));
       /*     */ }
     /*     */ }
   /*     */
   /* 101 */ this.field_75228_b = 0;
   /*     */
   /* 103 */ FMLCommonHandler.instance().firePlayerSmeltedEvent(this.thePlayer, p_75208_1_);
   /*     */
   /* 105 */ if (p_75208_1_.getItem() == Items.iron_ingot)
   /*     */ {
     /* 107 */ this.thePlayer.addStat(AchievementList.acquireIron, 1);
     /*     */ }
   /*     */
   /* 110 */ if (p_75208_1_.getItem() == Items.cooked_fished)
   /*     */ {
     /* 112 */ this.thePlayer.addStat(AchievementList.cookFish, 1);
     /*     */ }
   /*     */ }
  public void onCrafting(EntityPlayer player, ItemStack stack) {
    stack.onCrafting(player.worldObj, player, stack.stackSize);

    if (stack.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) {
      player.addStat(AchievementList.buildWorkBench, 1);
    }

    if (stack.getItem() instanceof ItemPickaxe) {
      player.addStat(AchievementList.buildPickaxe, 1);
    }

    if (stack.getItem() == Item.getItemFromBlock(Blocks.furnace)) {
      player.addStat(AchievementList.buildFurnace, 1);
    }

    if (stack.getItem() instanceof ItemHoe) {
      player.addStat(AchievementList.buildHoe, 1);
    }

    if (stack.getItem() == Items.bread) {
      player.addStat(AchievementList.makeBread, 1);
    }

    if (stack.getItem() == Items.cake) {
      player.addStat(AchievementList.bakeCake, 1);
    }

    if (stack.getItem() instanceof ItemPickaxe
        && ((ItemPickaxe) stack.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) {
      player.addStat(AchievementList.buildBetterPickaxe, 1);
    }

    if (stack.getItem() instanceof ItemSword) {
      player.addStat(AchievementList.buildSword, 1);
    }

    if (stack.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) {
      player.addStat(AchievementList.enchantments, 1);
    }

    if (stack.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) {
      player.addStat(AchievementList.bookcase, 1);
    }

    if (stack.getItem() == Item.getItemFromBlock(CraftingPillars.blockCraftingPillar)) {
      player.addStat(CraftingPillars.achievementRecursion, 1);
      System.out.println("achivement recursion");
    }
  }
Exemple #5
0
  @Override
  protected void onCrafting(ItemStack par1ItemStack) {
    par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b);

    if (!this.thePlayer.worldObj.isRemote) {
      int i = this.field_75228_b;
      // 経験値なぁ…うーん
      float f = FurnaceRecipes.smelting().func_151398_b(par1ItemStack);
      int j;

      if (f == 0.0F) {
        i = 0;
      } else if (f < 1.0F) {
        j = MathHelper.floor_float((float) i * f);

        if (j < MathHelper.ceiling_float_int((float) i * f)
            && (float) Math.random() < (float) i * f - (float) j) {
          ++j;
        }

        i = j;
      }

      while (i > 0) {
        j = EntityXPOrb.getXPSplit(i);
        i -= j;
        this.thePlayer.worldObj.spawnEntityInWorld(
            new EntityXPOrb(
                this.thePlayer.worldObj,
                this.thePlayer.posX,
                this.thePlayer.posY + 0.5D,
                this.thePlayer.posZ + 0.5D,
                j));
      }
    }

    this.field_75228_b = 0;

    FMLCommonHandler.instance().firePlayerSmeltedEvent(thePlayer, par1ItemStack);

    if (par1ItemStack.getItem() == Items.iron_ingot) {
      this.thePlayer.addStat(AchievementList.acquireIron, 1);
    }

    if (par1ItemStack.getItem() == Items.cooked_fished) {
      this.thePlayer.addStat(AchievementList.cookFish, 1);
    }
  }
  /** the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */
  protected void onCrafting(ItemStack par1ItemStack) {
    par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b);

    if (!this.thePlayer.worldObj.isRemote) {
      int i = this.field_75228_b;
      float f = FurnaceRecipes.smelting().getExperience(par1ItemStack);
      int j;

      if (f == 0.0F) {
        i = 0;
      } else if (f < 1.0F) {
        j = MathHelper.floor_float((float) i * f);

        if (j < MathHelper.ceiling_float_int((float) i * f)
            && (float) Math.random() < (float) i * f - (float) j) {
          ++j;
        }

        i = j;
      }

      while (i > 0) {
        j = EntityXPOrb.getXPSplit(i);
        i -= j;
        this.thePlayer.worldObj.spawnEntityInWorld(
            new EntityXPOrb(
                this.thePlayer.worldObj,
                this.thePlayer.posX,
                this.thePlayer.posY + 0.5D,
                this.thePlayer.posZ + 0.5D,
                j));
      }
    }

    this.field_75228_b = 0;

    GameRegistry.onItemSmelted(thePlayer, par1ItemStack);

    if (par1ItemStack.itemID == Item.ingotIron.itemID) {
      this.thePlayer.addStat(AchievementList.acquireIron, 1);
    }

    if (par1ItemStack.itemID == Item.fishCooked.itemID) {
      this.thePlayer.addStat(AchievementList.cookFish, 1);
    }
  }
  @Override
  protected void onCrafting(ItemStack stack) {
    stack.onCrafting(this.player.worldObj, this.player, this.amount);

    if (!this.player.worldObj.isRemote) {
      int amount = this.amount;
      float experience = FurnaceRecipes.smelting().getExperience(stack);

      if (experience == 0.0F) {
        amount = 0;
      } else if (experience < 1.0F) {
        int orbs = MathHelper.floor_float((float) amount * experience);

        if (orbs < MathHelper.ceiling_float_int((float) amount * experience)
            && (float) Math.random() < (float) amount * experience - (float) orbs) {
          ++orbs;
        }

        amount = orbs;
      }

      while (amount > 0) {
        int orbSize = EntityXPOrb.getXPSplit(amount);
        amount -= orbSize;
        this.player.worldObj.spawnEntityInWorld(
            new EntityXPOrb(
                this.player.worldObj,
                this.player.posX,
                this.player.posY + 0.5D,
                this.player.posZ + 0.5D,
                orbSize));
      }
    }

    this.amount = 0;

    GameRegistry.onItemSmelted(this.player, stack);

    if (stack.itemID == Item.ingotIron.itemID) {
      this.player.addStat(AchievementList.acquireIron, 1);
    }

    if (stack.itemID == Item.fishCooked.itemID) {
      this.player.addStat(AchievementList.cookFish, 1);
    }
  }
  @Override
  public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack) {
    itemstack.onCrafting(thePlayer.worldObj, thePlayer, slotNumber);
    TerraFirmaCraft.proxy.takenFromCrafting(thePlayer, itemstack, craftMatrix);

    for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
      ItemStack itemstack1 = craftMatrix.getStackInSlot(i);
      if (itemstack1 != null) {
        craftMatrix.decrStackSize(i, 1);
        if (player.worldObj.isRemote && player.openContainer instanceof ContainerSpecialCrafting)
          ((GuiKnapping) Minecraft.getMinecraft().currentScreen).resetButton(i);

        if (itemstack1.getItem().getContainerItem() != null) {
          ItemStack itemstack2 = new ItemStack(itemstack1.getItem().getContainerItem());
          if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1)
              || !thePlayer.inventory.addItemStackToInventory(itemstack2)) {
            if (craftMatrix.getStackInSlot(i) == null)
              craftMatrix.setInventorySlotContents(i, itemstack2);
            else thePlayer.entityDropItem(itemstack2, 0);
          }
        }
      }
    }
  }
  @Override
  protected void onCrafting(ItemStack outputStack) {
    if (outputStack == null) return;

    outputStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
  }
 public void onCraftingPickup(World world, EntityPlayer player, ItemStack stack) {
   stack.onCrafting(world, player, stack.stackSize);
 }
 /** the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */
 protected void onCrafting(ItemStack stack) {
   if (this.amountCrafted > 0) {
     stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
   }
 }