コード例 #1
0
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (getRunning()) run();
    else postRun();

    if (Config.useFuel && !worldObj.isRemote) {
      if (inventory.getStackInSlot(0) != null
          && TileEntityFurnace.isItemFuel(inventory.getStackInSlot(0))
          && (fuel.get() + TileEntityFurnace.getItemBurnTime(inventory.getStackInSlot(0)))
              <= Config.maxFuelLevel)
        if (inventory.getStackInSlot(0).getItem().equals(Items.lava_bucket)) {
          fuel.modify(TileEntityFurnace.getItemBurnTime(inventory.decrStackSize(0, 1)));
          inventory.setInventorySlotContents(0, new ItemStack(Items.bucket));
        } else {
          fuel.modify(TileEntityFurnace.getItemBurnTime(inventory.decrStackSize(0, 1)));
        }

      if (fuel.isDirty()) sync();
    }

    lastTickPosX = posX;
    lastTickPosY = posY;
    lastTickPosZ = posZ;

    posX += motionX;
    posY += motionY;
    posZ += motionZ;

    setPosition(posX, posY, posZ);

    if (getTimeSinceHit() > 0) setTimeSinceHit(getTimeSinceHit() - 1);
    if (getDamageTaken() > 0) setDamageTaken(getDamageTaken() - 1);
  }
コード例 #2
0
 public void func_146101_a(TileEntityFurnace p_146101_1_) {
   this.getNextWindowId();
   this.playerNetServerHandler.sendPacket(
       new S2DPacketOpenWindow(
           this.currentWindowId,
           2,
           p_146101_1_.getInventoryName(),
           p_146101_1_.getSizeInventory(),
           p_146101_1_.isCustomInventoryName()));
   this.openContainer = new ContainerFurnace(this.inventory, p_146101_1_);
   this.openContainer.windowId = this.currentWindowId;
   this.openContainer.onCraftGuiOpened(this);
 }
コード例 #3
0
  public void updateEntity() {
    ItemStack log = getStackInSlot(0);
    ItemStack output = getStackInSlot(1);

    boolean powered = burning > 0;

    if (log != null && powered) {
      if (progress != loggingTime) {
        progress++;
      } else {
        if (output == null) {
          decrStackSize(0, 1);
          setInventorySlotContents(1, new ItemStack(Block.planks, 6, log.getItemDamage()));
          progress = 0;
        } else {
          if (output.isItemEqual(new ItemStack(Block.planks, 6, log.getItemDamage()))
              && output.stackSize < getInventoryStackLimit()) {
            decrStackSize(0, 1);
            output.stackSize = output.stackSize + 6;
            progress = 0;
          } else {
            progress = 0;
          }
        }
      }
    } else {
      progress = 0;
    }

    if (powered) {
      burning--;
    }

    ItemStack fuel = getStackInSlot(2);

    if (fuel != null) {
      if (TileEntityFurnace.getItemBurnTime(fuel) > 0) {
        if (!powered) {
          decrStackSize(2, 1);
          burning = TileEntityFurnace.getItemBurnTime(fuel);
        }
      }
    }

    if (powered != burning > 0) {
      this.onInventoryChanged();
      // BlockLogger.updateState(burning > 0, worldObj, xCoord, yCoord, zCoord);
    }
  }
コード例 #4
0
ファイル: FuelPlugin.java プロジェクト: asiekierka/Railcraft
  private static int findFuelValue(ItemStack stack) {
    try {
      Item item = stack.getItem();

      if (item instanceof ItemBlock) {
        Block block = InvTools.getBlockFromStack(stack);

        String name = block.getUnlocalizedName();
        if (name != null && name.contains("blockScaffold")) return 0;
      }

      //            if (itemID == Item.coal.itemID && stack.getItemDamage() == 0)
      //                return 1600;

      if (item == Items.blaze_rod) return 1000;

      FluidStack liquid = FluidItemHelper.getFluidStackInContainer(stack);
      if (liquid != null && Fluids.LAVA.get() == liquid.getFluid()) return liquid.amount;

      String name = stack.getItem().getUnlocalizedName();
      if (name != null && name.contains("itemScrap")) return 0;

      return TileEntityFurnace.getItemBurnTime(stack);
    } catch (Exception ex) {
      Game.logThrowable(
          "Error in Fuel Handler! Is some mod creating items that are not compliant with standards?",
          ex);
    }
    return 0;
  }
コード例 #5
0
  public int getFuel(ItemStack itemstack) {
    if (itemstack.getItem() == Items.lava_bucket) {
      return 1000;
    }

    return TileEntityFurnace.getItemBurnTime(itemstack) / 2;
  }
コード例 #6
0
  @Override
  public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    facing = ForgeDirection.getOrientation(tagCompound.getInteger("direction"));

    isValidMultiblock = tagCompound.getBoolean("isValidMultiblock");

    NBTTagList itemsTag = (NBTTagList) tagCompound.getTag("Items");
    furnaceItems = new ItemStack[getSizeInventory()];

    for (int i = 0; i < itemsTag.tagCount(); i++) {
      NBTTagCompound slotTag = (NBTTagCompound) itemsTag.getCompoundTagAt(i);
      byte slot = slotTag.getByte("Slot");

      if (slot >= 0 && slot < furnaceItems.length)
        furnaceItems[slot] = ItemStack.loadItemStackFromNBT(slotTag);
    }

    furnaceBurnTime = tagCompound.getShort("BurnTime");
    furnaceCookTime = tagCompound.getShort("CookTime");
    currentItemBurnTime = TileEntityFurnace.getItemBurnTime(furnaceItems[1]);
    cooking = tagCompound.getBoolean("active");
    type = tagCompound.getInteger("type");
    if (type == 1) partBlocks = stonebrick;
    hole = hole.readFromNBT(tagCompound, "hole");
  }
コード例 #7
0
 @Override
 public void loadUsageRecipes(ItemStack ingredient) {
   int redstone = RedstoneExtractorRecipes.discharge().value(ingredient);
   if (redstone > 0) arecipes.add(new StarchPair(ingredient, redstone));
   int fuel = TileEntityFurnace.getItemBurnTime(ingredient);
   if (fuel > 0) afuels.add(new FuelPair(ingredient, fuel));
 }
コード例 #8
0
 private static void findFuels() {
   afuels = new ArrayList<FuelPair>();
   Set<Item> efuels = excludedFuels();
   for (ItemStack item : ItemList.items)
     if (!efuels.contains(item.getItem())) {
       int burnTime = TileEntityFurnace.getItemBurnTime(item);
       if (burnTime > 0) afuels.add(new FuelPair(item.copy(), burnTime));
     }
 }
コード例 #9
0
  /** Called to transfer a stack from one inventory to the other eg. when shift clicking. */
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) {
    ItemStack var2 = null;
    final Slot var3 = (Slot) inventorySlots.get(par1);

    if (var3 != null && var3.getHasStack()) {
      final ItemStack var4 = var3.getStack();
      var2 = var4.copy();

      if (par1 == 1) {
        if (!mergeItemStack(var4, 2, 38, true)) {
          return null;
        }

        var3.onSlotChange(var4, var2);
      } else if (par1 != 1 && par1 != 0) {
        if (FurnaceRecipes.smelting().getSmeltingResult(var4) != null) {
          if (!mergeItemStack(var4, 0, 1, false)) {
            return null;
          }
        } else if (TileEntityFurnace.isItemFuel(var4)) {
          if (!mergeItemStack(var4, 0, 1, false)) {
            return null;
          }
        } else if (par1 >= 2 && par1 < 29) {
          if (!mergeItemStack(var4, 29, 38, false)) {
            return null;
          }
        } else if (par1 >= 29 && par1 < 38 && !mergeItemStack(var4, 2, 29, false)) {
          return null;
        }
      } else if (!mergeItemStack(var4, 2, 38, false)) {
        return null;
      }

      if (var4.stackSize == 0) {
        var3.putStack((ItemStack) null);
      } else {
        var3.onSlotChanged();
      }

      if (var4.stackSize == var2.stackSize) {
        return null;
      }

      var3.onPickupFromSlot(par1EntityPlayer, var4);
    }

    return var2;
  }
コード例 #10
0
ファイル: RMFurnaceTile.java プロジェクト: Roblomal/ProjectE
  @Override
  public boolean isItemValidForSlot(int slot, ItemStack stack) {
    if (stack == null) {
      return false;
    }

    if (slot == 0) {
      return TileEntityFurnace.isItemFuel(stack) || stack.getItem() == ObjHandler.kleinStars;
    } else if (slot >= 1 && slot <= 13) {
      return FurnaceRecipes.smelting().getSmeltingResult(stack) != null;
    }

    return false;
  }
コード例 #11
0
  public void updateEntity() {
    boolean flag = burnTime > 0;
    boolean flag1 = false;

    if (burnTime > 0) {
      burnTime--;
    }

    if (!worldObj.isRemote) {
      if (burnTime != 0 || contents[1] != null && contents[0] != null) {
        if (burnTime == 0 && canSmelt()) {
          currentItemBurnTime = burnTime = TileEntityFurnace.getItemBurnTime(contents[1]);

          if (burnTime > 0) {
            flag1 = true;

            if (contents[1] != null) {
              contents[1].stackSize--;

              if (contents[1].stackSize == 0) {
                contents[1] = contents[1].getItem().getContainerItem(contents[1]);
              }
            }
          }
        }

        if (isBurning() && canSmelt()) {
          progress++;

          if (progress == 200) {
            progress = 0;
            smeltItem();
            flag1 = true;
          }
        } else {
          progress = 0;
        }
      }

      if (flag != burnTime > 0) {
        flag1 = true;
        // BlockFurnace.updateFurnaceBlockState(burnTime > 0, worldObj, xCoord, yCoord, zCoord);
      }
    }

    if (flag1) {
      markDirty();
    }
  }
コード例 #12
0
  private boolean getFuelFromInventory() {
    for (int i = 0; i < owner.getInventory().getSizeInventory(); i++) {
      ItemStack stack = owner.getInventory().getStackInSlot(i);

      if (stack != null) {
        try {
          final boolean isFuel = TileEntityFurnace.isItemFuel(stack);
          int fuelValue =
              TileEntityFurnace.getItemBurnTime(stack) == 0
                  ? GameRegistry.getFuelValue(stack)
                  : TileEntityFurnace.getItemBurnTime(stack);
          fuelValue = fuelValue / Time.SECOND / 10;

          if (fuelValue == 0 && isFuel) {
            fuelValue = 1;
          }

          if (fuelValue > 0) {
            hasFuel = true;
            fuelUsesRemaining = fuelValue;

            owner
                .getInventory()
                .decrStackSize(owner.getInventory().getFirstSlotContainingItem(stack.getItem()), 1);
          }
        } catch (
            ClassCastException
                e) // Known problem with earlier versions of MCA, not sure why this happened.
        {
          continue;
        }
      }
    }

    return hasFuel;
  }
コード例 #13
0
  public ItemStack func_82846_b(EntityPlayer p_82846_1_, int p_82846_2_) {
    ItemStack var3 = null;
    Slot var4 = (Slot) this.field_75151_b.get(p_82846_2_);
    if (var4 != null && var4.func_75216_d()) {
      ItemStack var5 = var4.func_75211_c();
      var3 = var5.func_77946_l();
      if (p_82846_2_ == 2) {
        if (!this.func_75135_a(var5, 3, 39, true)) {
          return null;
        }

        var4.func_75220_a(var5, var3);
      } else if (p_82846_2_ != 1 && p_82846_2_ != 0) {
        if (FurnaceRecipes.func_77602_a().func_77603_b(var5.func_77973_b().field_77779_bT)
            != null) {
          if (!this.func_75135_a(var5, 0, 1, false)) {
            return null;
          }
        } else if (TileEntityFurnace.func_70401_b(var5)) {
          if (!this.func_75135_a(var5, 1, 2, false)) {
            return null;
          }
        } else if (p_82846_2_ >= 3 && p_82846_2_ < 30) {
          if (!this.func_75135_a(var5, 30, 39, false)) {
            return null;
          }
        } else if (p_82846_2_ >= 30 && p_82846_2_ < 39 && !this.func_75135_a(var5, 3, 30, false)) {
          return null;
        }
      } else if (!this.func_75135_a(var5, 3, 39, false)) {
        return null;
      }

      if (var5.field_77994_a == 0) {
        var4.func_75215_d((ItemStack) null);
      } else {
        var4.func_75218_e();
      }

      if (var5.field_77994_a == var3.field_77994_a) {
        return null;
      }

      var4.func_82870_a(p_82846_1_, var5);
    }

    return var3;
  }
コード例 #14
0
  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    ItemStack stack = null;
    Slot currentSlot = (Slot) inventorySlots.get(slotID);

    if (currentSlot != null && currentSlot.getHasStack()) {
      ItemStack slotStack = currentSlot.getStack();
      stack = slotStack.copy();

      if (slotID == 2) {
        if (!mergeItemStack(slotStack, 3, 39, true)) {
          return null;
        }
      } else if (slotID != 1 && slotID != 0) {
        if (FurnaceRecipes.smelting().getSmeltingResult(slotStack) != null) {
          if (!mergeItemStack(slotStack, 0, 1, false)) {
            return null;
          }
        } else if (TileEntityFurnace.isItemFuel(slotStack)) {
          if (!mergeItemStack(slotStack, 1, 2, false)) {
            return null;
          }
        } else if (slotID >= 3 && slotID < 30) {
          if (!mergeItemStack(slotStack, 30, 39, false)) {
            return null;
          }
        } else if (slotID >= 30 && slotID < 39 && !mergeItemStack(slotStack, 3, 30, false)) {
          return null;
        }
      } else if (!mergeItemStack(slotStack, 3, 39, false)) {
        return null;
      }

      if (slotStack.stackSize == 0) {
        currentSlot.putStack((ItemStack) null);
      } else {
        currentSlot.onSlotChanged();
      }

      if (slotStack.stackSize == stack.stackSize) {
        return null;
      }

      currentSlot.onPickupFromSlot(player, slotStack);
    }

    return stack;
  }
コード例 #15
0
  /**
   * Called when a player shift-clicks on a slot. You must override this or you will crash when
   * someone does that.
   */
  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.inventorySlots.get(par2);

    if (slot != null && slot.getHasStack()) {
      ItemStack itemstack1 = slot.getStack();
      itemstack = itemstack1.copy();

      if (par2 == 1) {
        if (!this.mergeItemStack(itemstack1, 29, 65, true)) {
          return null;
        }

        slot.onSlotChange(itemstack1, itemstack);
      } else if (par2 >= 11 && par2 <= 64) {
        if (TileEntityFurnace.isItemFuel(itemstack1)) {

          if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
            return null;
          }
          // else if (!this.mergeItemStack(itemstack1, 11, 20, false)) {

          //	return null;

          // }

          //					if (par2 <= 19) {
          //						if (!this.mergeItemStack(itemstack1, 0, 1, false))
          //						{
          //							return null;
          //						}
          //					}
          //					else if (!this.mergeItemStack(itemstack1, 11, 65, false)) {
          //						return null;
          //					}
          //					else if (!this.mergeItemStack(itemstack1, 11, 20, false))
          //					{
          //						if (!this.mergeItemStack(itemstack1, 20, 65, false))
          //						{
          //							return null;
          //						}
          //					}

        } else if (par2 >= 11 && par2 <= 28) {
          if (!this.mergeItemStack(itemstack1, 29, 65, false)) {
            return null;
          }
        } else if (par2 >= 29 && par2 <= 55) {
          if (!this.mergeItemStack(itemstack1, 11, 20, false)) {

            if (!this.mergeItemStack(itemstack1, 56, 65, false)) {
              return null;
            }
          }
        } else if (par2 >= 56 && par2 <= 64) {
          if (!this.mergeItemStack(itemstack1, 11, 20, false)) {

            if (!this.mergeItemStack(itemstack1, 29, 56, false)) {
              return null;
            }
          }
        }
      } else if (!this.mergeItemStack(itemstack1, 29, 65, false)) {
        return null;
      }

      if (itemstack1.stackSize == 0) {
        slot.putStack((ItemStack) null);
      } else {
        slot.onSlotChanged();
      }

      if (itemstack1.stackSize == itemstack.stackSize) {
        return null;
      }

      slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
    }

    return itemstack;
  }
コード例 #16
0
 @Override
 public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
   return slot > 8 && !TileEntityFurnace.isItemFuel(itemstack)
       ? false
       : (slot == 8 ? TileEntityFurnace.isItemFuel(itemstack) : true);
 }
コード例 #17
0
ファイル: RMFurnaceTile.java プロジェクト: Roblomal/ProjectE
  private void pullFromInventories() {
    TileEntity tile = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);

    if (tile instanceof ISidedInventory) {
      final int side = 0;
      ISidedInventory inv = (ISidedInventory) tile;

      int[] slots = inv.getAccessibleSlotsFromSide(side);

      if (slots.length > 0) {
        for (int i : slots) {
          ItemStack stack = inv.getStackInSlot(i);

          if (stack == null) {
            continue;
          }

          if (inv.canExtractItem(i, stack, side)) {
            if (TileEntityFurnace.isItemFuel(stack) || stack.getItem() == ObjHandler.kleinStars) {
              if (inventory[0] == null) {
                inventory[0] = stack;
                inv.setInventorySlotContents(i, null);
              } else if (Utils.areItemStacksEqual(stack, inventory[0])) {
                int remain = inventory[0].getMaxStackSize() - inventory[0].stackSize;

                if (stack.stackSize <= remain) {
                  inventory[0].stackSize += stack.stackSize;
                  inv.setInventorySlotContents(i, null);
                } else {
                  inventory[0].stackSize += remain;
                  stack.stackSize -= remain;
                }
              }

              continue;
            }

            for (int j = inputStorage[0]; j < inputStorage[1]; j++) {
              ItemStack otherStack = inventory[j];

              if (otherStack == null) {
                inventory[j] = stack;
                inv.setInventorySlotContents(i, null);
                break;
              } else if (Utils.areItemStacksEqual(stack, otherStack)) {
                int remain = otherStack.getMaxStackSize() - otherStack.stackSize;

                if (stack.stackSize <= remain) {
                  inventory[j].stackSize += stack.stackSize;
                  inv.setInventorySlotContents(i, null);
                  break;
                } else {
                  inventory[j].stackSize += remain;
                  stack.stackSize -= remain;
                }
              }
            }
          }
        }
      }
    } else if (tile instanceof IInventory) {
      IInventory inv = (IInventory) tile;

      for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);

        if (stack == null) {
          continue;
        }

        if (TileEntityFurnace.isItemFuel(stack) || stack.getItem() == ObjHandler.kleinStars) {
          ItemStack fuel = inventory[0];

          if (fuel == null) {
            inventory[0] = stack;
            inv.setInventorySlotContents(i, null);
          } else {
            int remain = fuel.getMaxStackSize() - fuel.stackSize;

            if (stack.stackSize <= remain) {
              inventory[0].stackSize += stack.stackSize;
              inv.setInventorySlotContents(i, null);
            } else {
              inventory[0].stackSize += remain;
              stack.stackSize -= remain;
            }
          }

          continue;
        } else if (FurnaceRecipes.smelting().getSmeltingResult(stack) == null) {
          continue;
        }

        for (int j = inputStorage[0]; j < inputStorage[1]; j++) {
          ItemStack otherStack = inventory[j];

          if (otherStack == null) {
            inventory[j] = stack;
            inv.setInventorySlotContents(i, null);
            break;
          } else if (Utils.areItemStacksEqual(stack, otherStack)) {
            int remain = otherStack.getMaxStackSize() - otherStack.stackSize;

            if (stack.stackSize <= remain) {
              inventory[j].stackSize += stack.stackSize;
              inv.setInventorySlotContents(i, null);
              break;
            } else {
              inventory[j].stackSize += remain;
              stack.stackSize -= remain;
            }
          }
        }
      }
    }
  }
コード例 #18
0
  @Override
  public boolean executeBlock(int pMode, int px, int py, int pz) {
    if (!owner.isEqualTile()) {
      return false;
    }

    TileEntityFurnace ltile = (TileEntityFurnace) owner.maidTileEntity;
    ItemStack litemstack;
    boolean lflag = false;
    int li;

    if (owner.getSwingStatusDominant().canAttack()) {
      // 完成品回収
      litemstack = ltile.getStackInSlot(2);
      if (litemstack != null) {
        if (litemstack.stackSize > 0) {
          li = litemstack.stackSize;
          if (owner.maidInventory.addItemStackToInventory(litemstack)) {
            dropExpOrb(litemstack, li - litemstack.stackSize);
            owner.playSound("random.pop");
            owner.setSwing(5, LMM_EnumSound.cookingOver, false);
            //                    	if
            // (!pEntityLittleMaid.maidInventory.isItemBurned(pEntityLittleMaid.maidInventory.currentItem)) {
            owner.getNextEquipItem();
            //                    	}
            lflag = true;
          }
        }
        ltile.setInventorySlotContents(2, null);
      }

      // 調理可能品を竈にぽーい
      if (!lflag && ltile.getStackInSlot(0) == null) {
        litemstack = ltile.getStackInSlot(2);
        li = owner.maidInventory.getSmeltingItem();
        owner.setEquipItem(li);
        if (li > -1) {
          litemstack = owner.maidInventory.getStackInSlot(li);
          // レシピ対応品
          if (litemstack.stackSize >= ltile.getInventoryStackLimit()) {
            ltile.setInventorySlotContents(
                0, litemstack.splitStack(ltile.getInventoryStackLimit()));
          } else {
            ltile.setInventorySlotContents(0, litemstack.splitStack(litemstack.stackSize));
          }
          if (litemstack.stackSize <= 0) {
            owner.maidInventory.setInventorySlotContents(li, null);
          }
          owner.playSound("random.pop");
          owner.setSwing(5, LMM_EnumSound.cookingStart, false);
          lflag = true;
        }
      }

      // 手持ちの燃料をぽーい
      if (!lflag && ltile.getStackInSlot(1) == null && ltile.getStackInSlot(0) != null) {
        owner.getNextEquipItem();
        litemstack = owner.getCurrentEquippedItem();
        if (LMM_InventoryLittleMaid.isItemBurned(litemstack)) {
          if (litemstack.stackSize >= ltile.getInventoryStackLimit()) {
            ltile.setInventorySlotContents(
                1, litemstack.splitStack(ltile.getInventoryStackLimit()));
          } else {
            ltile.setInventorySlotContents(1, litemstack.splitStack(litemstack.stackSize));
          }
          if (litemstack.stackSize <= 0) {
            owner.maidInventory.setInventoryCurrentSlotContents(null);
          }
          owner.getNextEquipItem();
          owner.playSound("random.pop");
          owner.setSwing(5, LMM_EnumSound.addFuel, false);
          lflag = true;
        } else {
          if (ltile.isBurning()) {
            lflag = true;
          } else {
            // 燃やせるアイテムを持ってないので調理可能品を回収
            ItemStack litemstack2 = ltile.getStackInSlotOnClosing(0);
            if (owner.maidInventory.addItemStackToInventory(litemstack2)) {
              owner.playSound("random.pop");
              owner.setSwing(5, LMM_EnumSound.Null, false);
              owner.getNextEquipItem();
              lflag = false;
            } else {
              ltile.setInventorySlotContents(0, litemstack2);
            }
          }
        }
      }

      // 燃え終わってるのに燃料口に何かあるなら回収する
      if (!lflag && !ltile.isBurning() && ltile.getStackInSlot(1) != null) {
        ItemStack litemstack2 = ltile.getStackInSlotOnClosing(1);
        if (owner.maidInventory.addItemStackToInventory(litemstack2)) {
          owner.playSound("random.pop");
          owner.setSwing(5, LMM_EnumSound.Null, false);
          owner.getNextEquipItem();
          lflag = LMM_InventoryLittleMaid.isItemBurned(owner.getCurrentEquippedItem());
        } else {
          ltile.setInventorySlotContents(1, litemstack2);
        }
      }
    } else {
      lflag = true;
    }
    if (ltile.isBurning()) {
      owner.setWorking(true);
      owner.setSneaking(py - (int) owner.posY <= 0);
      lflag = true;
    }
    // mod_LMM_littleMaidMob.Debug("work" + lflag);
    return lflag;
  }
コード例 #19
0
  @Override
  public void updateEntity() {
    if (first && isValidMultiblock) {
      first = false;
      convertDummies();
    }
    if (!isValidMultiblock) return;
    boolean flag = furnaceBurnTime > 0;
    boolean flag1 = false;

    int metadata = getBlockMetadata();
    int isActive = (metadata >> 3);

    if (furnaceBurnTime > 0) furnaceBurnTime--;
    if (furnaceBurnTime == 0 && metadata != 0) {
      worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3);
    }

    if (!this.worldObj.isRemote) {
      boolean canSmelt = false;

      for (int i = 0; i < 8; i++) {
        canSmelt = canSmelt || canSmelt(i);
      }
      if (furnaceBurnTime == 0 && canSmelt) {
        currentItemBurnTime = furnaceBurnTime = TileEntityFurnace.getItemBurnTime(furnaceItems[8]);

        if (furnaceBurnTime > 0) {
          flag1 = true;

          if (furnaceItems[8] != null) {
            furnaceItems[8].stackSize--;

            if (furnaceItems[8].stackSize == 0)
              furnaceItems[8] = furnaceItems[8].getItem().getContainerItem(furnaceItems[8]);
          }
        }
      }
      canSmelt = false;
      for (int i = 0; i < 8; i++) {
        canSmelt = canSmelt || canSmelt(i);
      }
      if (isBurning() && canSmelt) {
        furnaceCookTime++;

        if (furnaceCookTime == getCookTime()) {
          furnaceCookTime = 0;
          for (int i = 0; i < 8; i++) smeltItem(i);
          flag1 = true;
        }
      } else {
        furnaceCookTime = 0;
      }

      if (isActive == 0 && furnaceBurnTime > 0) {
        flag1 = true;
        isActive = 1;
        metadata = 1;
        setInside();
        if (metadata != 1) worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 3);
      }
    }

    if (flag1) closeInventory();
  }
コード例 #20
0
ファイル: RMFurnaceTile.java プロジェクト: Roblomal/ProjectE
 private int getItemBurnTime(ItemStack stack) {
   int val = TileEntityFurnace.getItemBurnTime(stack);
   return (val * ticksBeforeSmelt) / 200 * efficiencyBonus;
 }
コード例 #21
0
 // returns the number of ticks the given item will burn. Returns 0 if the given item is not a
 // valid fuel
 public static short getItemBurnTime(ItemStack stack) {
   int burntime = TileEntityFurnace.getItemBurnTime(stack); // just use the vanilla values
   return (short) MathHelper.clamp_int(burntime, 0, Short.MAX_VALUE);
 }
コード例 #22
0
 public static boolean canItemBurn(ItemStack stack) {
   if (TileEntityFurnace.isItemFuel(stack)) return true;
   return contains(burnItem, stack);
 }
コード例 #23
0
public class VanillaSmeltingRecipe implements IMachineRecipe {

  // We will use the same energy as per a standard furnace.
  // To do the conversion between fuel burning and RF, use the Stirling Gen
  // which produces ten RF per tick of burn time
  private static int RF_PER_ITEM =
      TileEntityFurnace.getItemBurnTime(new ItemStack(Items.coal, 1, 0)) * 10 / 8;

  private boolean enabled = true;

  private List<RecipeInput> excludes = new ArrayList<RecipeInput>();

  @Override
  public String getUid() {
    return "VanillaSmeltingRecipe";
  }

  public void setEnabled(boolean enabled) {
    this.enabled = enabled;
  }

  public void addExclude(RecipeInput ri) {
    excludes.add(ri);
  }

  @Override
  public int getEnergyRequired(MachineRecipeInput... inputs) {
    int numInputs = getNumInputs(inputs);
    return numInputs * RF_PER_ITEM;
  }

  @Override
  public RecipeBonusType getBonusType(MachineRecipeInput... inputs) {
    return RecipeBonusType.NONE;
  }

  private int getNumInputs(MachineRecipeInput[] inputs) {
    int numInputs = 0;
    for (MachineRecipeInput input : inputs) {
      if (input != null && isValidInput(input)) {
        numInputs += input.item.stackSize;
      }
    }
    return Math.min(numInputs, 3);
  }

  @Override
  public boolean isRecipe(MachineRecipeInput... inputs) {
    if (!enabled) {
      return false;
    }
    ItemStack output = null;
    for (MachineRecipeInput ri : inputs) {
      if (ri != null && ri.item != null && !isExcluded(ri.item)) {
        if (output == null) {
          output = FurnaceRecipes.smelting().getSmeltingResult(ri.item);
          if (output == null) {
            return false;
          }
        } else {
          ItemStack newOutput = FurnaceRecipes.smelting().getSmeltingResult(ri.item);
          if (newOutput == null || !newOutput.isItemEqual(output)) {
            return false;
          }
        }
      }
    }
    return output != null;
  }

  private boolean isExcluded(ItemStack item) {
    for (RecipeInput ri : excludes) {
      if (ri != null && ri.isInput(item)) {
        return true;
      }
    }
    return false;
  }

  @Override
  public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) {
    ItemStack output = null;
    int inputCount = 0;
    for (MachineRecipeInput ri : inputs) {
      if (ri != null && ri.item != null && output == null) {
        output = FurnaceRecipes.smelting().getSmeltingResult(ri.item);
      }
    }
    if (output == null) {
      return new ResultStack[0];
    }
    int stackSize = output.stackSize;
    output = OreDictionaryPreferences.instance.getPreferred(output);
    ItemStack result = output.copy();
    result.stackSize = stackSize;
    result.stackSize = result.stackSize * getNumInputs(inputs);
    return new ResultStack[] {new ResultStack(result)};
  }

  @Override
  public float getExperienceForOutput(ItemStack output) {
    if (output == null) {
      return 0;
    }
    float result = FurnaceRecipes.smelting().func_151398_b(output);
    return result * output.stackSize;
  }

  @Override
  public boolean isValidInput(MachineRecipeInput input) {
    if (!enabled) {
      return false;
    }
    if (input == null || input.item == null) {
      return false;
    }
    if (isExcluded(input.item)) {
      return false;
    }
    ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(input.item);
    return itemstack != null;
  }

  @Override
  public String getMachineName() {
    return ModObject.blockAlloySmelter.unlocalisedName;
  }

  @Override
  public List<MachineRecipeInput> getQuantitiesConsumed(MachineRecipeInput[] inputs) {
    int consumed = 0;
    List<MachineRecipeInput> result = new ArrayList<MachineRecipeInput>();
    for (MachineRecipeInput ri : inputs) {
      if (isValidInput(new MachineRecipeInput(ri.slotNumber, ri.item))
          && consumed < 3
          && ri != null
          && ri.item != null) {
        int available = ri.item.stackSize;
        int canUse = 3 - consumed;
        int use = Math.min(canUse, available);
        if (use > 0) {
          ItemStack st = ri.item.copy();
          st.stackSize = use;
          result.add(new MachineRecipeInput(ri.slotNumber, st));
          consumed += use;
        }
      }
    }
    return result;
  }

  public List<IRecipe> getAllRecipes() {
    if (!enabled) {
      return Collections.emptyList();
    }
    List<IRecipe> result = new ArrayList<IRecipe>();
    Map<ItemStack, ItemStack> metaList = FurnaceRecipes.smelting().getSmeltingList();
    for (Entry<ItemStack, ItemStack> entry : metaList.entrySet()) {
      ItemStack output = entry.getValue();
      output = OreDictionaryPreferences.instance.getPreferred(output).copy();
      result.add(
          new Recipe(
              new RecipeInput(entry.getKey()),
              RF_PER_ITEM,
              RecipeBonusType.NONE,
              new RecipeOutput(output)));
    }
    return result;
  }
}