コード例 #1
0
ファイル: GuiDynamicTank.java プロジェクト: shartte/Mekanism
  @Override
  protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    int xAxis = (mouseX - (width - xSize) / 2);
    int yAxis = (mouseY - (height - ySize) / 2);

    fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
    fontRenderer.drawString("Inventory", 8, (ySize - 94) + 2, 0x404040);
    fontRenderer.drawString("Volume: " + tileEntity.clientCapacity / 16000, 53, 26, 0x00CD00);
    fontRenderer.drawString(
        tileEntity.structure.liquidStored != null
            ? LiquidDictionary.findLiquidName(tileEntity.structure.liquidStored)
                + ": "
                + tileEntity.structure.liquidStored.amount
            : "No liquid.",
        53,
        35,
        0x00CD00);

    if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) {
      drawCreativeTabHoveringText(
          tileEntity.structure.liquidStored != null
              ? LiquidDictionary.findLiquidName(tileEntity.structure.liquidStored)
                  + ": "
                  + tileEntity.structure.liquidStored.amount
                  + "mB"
              : "Empty",
          xAxis,
          yAxis);
    }
  }
コード例 #2
0
 @Override
 public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) {
   if (type != null && type.itemID == LiquidDictionary.getCanonicalLiquid("sewage").itemID) {
     return _tank;
   }
   return null;
 }
コード例 #3
0
 @Override
 public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) {
   if (resource == null
       || (resource.itemID != LiquidDictionary.getCanonicalLiquid("sewage").itemID)) {
     return 0;
   } else {
     return _tank.fill(resource, doFill);
   }
 }
コード例 #4
0
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (!worldObj.isRemote) {
      for (int i = 0; i < 9; i++) {
        if (_inventory[i] != null
            && MFRRegistry.getPlantables().containsKey(_inventory[i].itemID)) {
          int targetSlot = findMatchingSlot(_inventory[i]);
          if (targetSlot < 0) {
            continue;
          }

          if (_inventory[targetSlot] == null) {
            _inventory[targetSlot] = _inventory[i];
            _inventory[i] = null;
          } else {
            UtilInventory.mergeStacks(_inventory[targetSlot], _inventory[i]);
            if (_inventory[i].stackSize <= 0) {
              _inventory[i] = null;
            }
          }
        }
      }

      if (Util.isRedstonePowered(this)) {
        return;
      }

      int newBurn = getOutputValue();
      if (_burnTimeMax - _burnTime >= newBurn) {
        _burnTime += newBurn;
        for (int i = 9; i < 18; i++) {
          if (_inventory[i] != null) {
            decrStackSize(i, 1);
          }
        }
      }

      if (_burnTime > 0
          && (_tank.getLiquid() == null
              || _tank.getLiquid().amount <= _tank.getCapacity() - _bioFuelPerTick)) {
        _burnTime -= _burnTimeDecreasePerTick;
        _tank.fill(LiquidDictionary.getLiquid("biofuel", _bioFuelPerTick), true);
      }
    }
  }
コード例 #5
0
  @Override
  public List<ItemStack> ranch(World world, EntityLiving entity, IInventory rancher) {
    List<ItemStack> drops = new LinkedList<ItemStack>();

    IInventoryManager manager = InventoryManager.create(rancher, ForgeDirection.UP);
    int bowlIndex = manager.findItem(new ItemStack(Item.bowlEmpty));
    if (bowlIndex >= 0) {
      drops.add(new ItemStack(Item.bowlSoup));
      rancher.decrStackSize(bowlIndex, 1);
    }

    int bucketIndex = manager.findItem(new ItemStack(Item.bucketEmpty));
    if (bucketIndex >= 0) {
      drops.add(new ItemStack(Item.bucketMilk));
      rancher.setInventorySlotContents(bucketIndex, null);
    } else {
      LiquidStack soup = LiquidDictionary.getLiquid("mushroomsoup", 1000);
      drops.add(new ItemStack(soup.itemID, 1, soup.itemMeta));
    }

    return drops;
  }
コード例 #6
0
  @Override
  public boolean activateMachine() {
    _grindingWorld.cleanReferences();
    List<?> entities =
        worldObj.getEntitiesWithinAABB(
            EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());

    entityList:
    for (Object o : entities) {
      EntityLiving e = (EntityLiving) o;
      if (e instanceof EntityAgeable && ((EntityAgeable) e).getGrowingAge() < 0
          || e.isEntityInvulnerable()
          || e.getHealth() <= 0) {
        continue;
      }
      boolean processMob = false;
      processEntity:
      {
        if (MFRRegistry.getGrindables27().containsKey(e.getClass())) {
          IFactoryGrindable2 r = MFRRegistry.getGrindables27().get(e.getClass());
          List<MobDrop> drops = r.grind(e.worldObj, e, getRandom());
          if (drops != null && drops.size() > 0 && WeightedRandom.getTotalWeight(drops) > 0) {
            ItemStack drop = ((MobDrop) WeightedRandom.getRandomItem(_rand, drops)).getStack();
            doDrop(drop);
          }
          if (r instanceof IFactoryGrindable2) {
            if (((IFactoryGrindable2) r).processEntity(e)) {
              processMob = true;
              if (e.getHealth() <= 0) {
                continue entityList;
              }
              break processEntity;
            }
          } else {
            processMob = true;
            break processEntity;
          }
        }
        for (Class<?> t : MFRRegistry.getGrinderBlacklist()) {
          if (t.isInstance(e)) {
            continue entityList;
          }
        }
        if (!_grindingWorld.addEntityForGrinding(e)) {
          continue entityList;
        }
      }
      if (processMob && e.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) {
        try {
          e.worldObj.getGameRules().setOrCreateGameRule("doMobLoot", "false");
          damageEntity(e);
          if (e.getHealth() <= 0) {
            _tank.fill(LiquidDictionary.getLiquid("mobEssence", 100), true);
          }
        } finally {
          e.worldObj.getGameRules().setOrCreateGameRule("doMobLoot", "true");
          setIdleTicks(20);
        }
        return true;
      }
      damageEntity(e);
      if (e.getHealth() <= 0) {
        _tank.fill(LiquidDictionary.getLiquid("mobEssence", 100), true);
        setIdleTicks(20);
      } else {
        setIdleTicks(10);
      }
      return true;
    }
    setIdleTicks(getIdleTicksMax());
    return false;
  }