コード例 #1
0
ファイル: TFCProvider.java プロジェクト: Kseon73/TFCraft
 @Override
 public boolean canBlockFreeze(int x, int y, int z, boolean byWater) {
   if (TFC_Climate.getHeightAdjustedTemp(x, y, z) <= 0
       && (worldObj.getBlockMaterial(x, y, z) == Material.water
           || worldObj.getBlockMaterial(x, y, z) == Material.ice)) return true;
   return false;
 }
コード例 #2
0
ファイル: TECrucible.java プロジェクト: jack42/TFCraft
  @Override
  public void updateEntity() {
    if (!worldObj.isRemote) {
      inputTick++;
      outputTick++;
      tempTick++;
      /*Heat the crucible based on the Forge beneath it*/
      if (worldObj.getBlockId(xCoord, yCoord - 1, zCoord) == TFCBlocks.Forge.blockID) {
        TileEntityForge te =
            (TileEntityForge) worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
        if (te.fireTemperature > temperature) {
          temperature++;
        }
      }
      if (tempTick > 22) {
        tempTick = 0;
        if (temperature > TFC_Climate.getHeightAdjustedTemp(xCoord, yCoord, zCoord)) {
          temperature--;
        }
      }

      ItemStack stackToSmelt = storage[0];
      if (stackToSmelt != null) {
        Item itemToSmelt = stackToSmelt.getItem();

        if (itemToSmelt instanceof ItemMeltedMetal && TFC_ItemHeat.getIsLiquid(storage[0])) {
          if (inputTick > 5) {
            if (currentAlloy != null
                && currentAlloy.outputType != null
                && itemToSmelt.itemID == currentAlloy.outputType.MeltedItemID) {
              this.addMetal(MetalRegistry.instance.getMetalFromItem(itemToSmelt), (short) 1);
              if (stackToSmelt.getItemDamage() + 1 >= storage[0].getMaxDamage()) {
                storage[0] = new ItemStack(TFCItems.CeramicMold, 1, 1);
              } else {
                stackToSmelt.setItemDamage(stackToSmelt.getItemDamage() + 1);
              }
            } else {
              this.addMetal(MetalRegistry.instance.getMetalFromItem(itemToSmelt), (short) 1);
              if (stackToSmelt.getItemDamage() + 1 >= stackToSmelt.getMaxDamage()) {
                storage[0] = new ItemStack(TFCItems.CeramicMold, 1, 1);
              } else {
                stackToSmelt.setItemDamage(stackToSmelt.getItemDamage() + 1);
              }
            }
            inputTick = 0;
            updateGui((byte) 0);
          }
        } else if (itemToSmelt instanceof ISmeltable
            && ((ISmeltable) itemToSmelt).isSmeltable(stackToSmelt)
            && !TFC_Core.isOreIron(stackToSmelt)
            && temperature >= TFC_ItemHeat.getMeltingPoint(stackToSmelt)) {
          Metal mType = ((ISmeltable) itemToSmelt).GetMetalType(stackToSmelt);
          if (addMetal(mType, ((ISmeltable) itemToSmelt).GetMetalReturnAmount(stackToSmelt))) {
            temperature *= 0.9f;

            if (stackToSmelt.stackSize <= 1) {
              storage[0] = null;
            }

            updateGui((byte) 0);
          }
        }
      }
      // Metal Output handling
      if (currentAlloy != null
          && storage[1] != null
          && currentAlloy.outputType != null
          && outputTick >= 3
          && temperature >= TFC_ItemHeat.getMeltingPoint(currentAlloy.outputType)) {
        if (storage[1].itemID == TFCItems.CeramicMold.itemID) {
          storage[1] = new ItemStack(Item.itemsList[currentAlloy.outputType.MeltedItemID], 1, 99);
          TFC_ItemHeat.SetTemperature(storage[1], temperature);
          // currentAlloy.outputAmount--;
          drainOutput(1.0f);
          updateGui((byte) 1);
        } else if (storage[1].itemID == currentAlloy.outputType.MeltedItemID
            && storage[1].getItemDamage() > 0) {
          storage[1].setItemDamage(storage[1].getItemDamage() - 1);
          float inTemp = TFC_ItemHeat.GetTemperature(storage[1]);
          float temp = (temperature - inTemp) / 2;
          TFC_ItemHeat.SetTemperature(storage[1], inTemp + temp);
          // System.out.println(temperature +", "+inTemp+", "+temp);
          // currentAlloy.outputAmount--;
          drainOutput(1.0f);
          storage[1].stackSize = 1;
          updateGui((byte) 1);
        }
        outputTick = 0;
      }

      if (currentAlloy != null && currentAlloy.outputAmount <= 0) {
        metals = new HashMap();
        updateCurrentAlloy();
        this.updateGui((byte) 2);
        currentAlloy = null;
      }

      if (storage[1] != null && storage[1].stackSize <= 0) {
        storage[1].stackSize = 1;
      }
      if (inputTick > 5) {
        inputTick = 0;
      }
      if (outputTick >= 3) {
        outputTick = 0;
      }
    }
  }
コード例 #3
0
ファイル: TFCProvider.java プロジェクト: Kseon73/TFCraft
 @Override
 public boolean canSnowAt(int x, int y, int z) {
   if (TFC_Climate.getHeightAdjustedTemp(x, y, z) <= 0) return true;
   return false;
 }
コード例 #4
0
ファイル: GuiCalendar.java プロジェクト: TurEduard/TFCraft1
  @Override
  public void drawScreen(int par1, int par2, float par3) {
    this.mc.func_110434_K().func_110577_a(texture);

    int var4 = this.guiLeft;
    int var5 = this.guiTop;

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2;
    drawTexturedModalRect(l, i1, 0, 0, xSize, ySize);

    drawCenteredString(
        fontRenderer, StringUtil.localize("gui.Calendar.Calendar"), l + 87, i1 + 16, 0xFFFFFF);
    drawCenteredString(
        fontRenderer,
        StringUtil.localize("gui.Calendar.Season") + " : " + TFC_Time.seasons[TFC_Time.getMonth()],
        l + 87,
        i1 + 26,
        0x000000);

    drawCenteredString(
        fontRenderer,
        StringUtil.localize("gui.Calendar.Day") + " : " + TFC_Time.Days[TFC_Time.getDayOfWeek()],
        l + 87,
        i1 + 36,
        0x000000);
    int dom = TFC_Time.getDayOfMonth();
    int month = TFC_Time.currentMonth;

    if (dom == 7 && month == 4) {
      drawCenteredString(
          fontRenderer,
          StringUtil.localize("gui.Calendar.DateBioxx") + ", " + (1000 + TFC_Time.getYear()),
          l + 87,
          i1 + 46,
          0x000000);
    } else {
      drawCenteredString(
          fontRenderer,
          StringUtil.localize("gui.Calendar.Date")
              + " : "
              + dom
              + " "
              + TFC_Time.months[month]
              + ", "
              + (1000 + TFC_Time.getYear()),
          l + 87,
          i1 + 46,
          0x000000);
    }

    float temp =
        Math.round(
            (TFC_Climate.getHeightAdjustedTemp(
                (int) player.posX, (int) player.posY, (int) player.posZ)));

    // drawCenteredString(fontRenderer,"Temperature : " + (int)temp + "C", l + 87, i1+56, 0x000000);
    // drawCenteredString(fontRenderer,"Month : " + , l + 87, i1+36, 0x000000);

    long h = TFC_Time.getHour();
    String hour = "";
    if (h == 0) {
      hour = StringUtil.localize("gui.Calendar.WitchHour");
    } else {
      hour += h;
    }
    drawCenteredString(
        fontRenderer,
        StringUtil.localize("gui.Calendar.Hour") + " : " + hour,
        l + 87,
        i1 + 56,
        0x000000);
    // drawCenteredString(fontRenderer,"EVT : " +
    // ((TFCWorldChunkManager)world.provider.worldChunkMgr).getEVTLayerAt((int) player.posX, (int)
    // player.posZ).floatdata1, l + 87, i1+76, 0x000000);

    // int rain = (int) TFC_Climate.getRainfall((int) player.posX,(int) player.posY, (int)
    // player.posZ);
    // drawCenteredString(fontRenderer,"Rain : " + rain, l + 87, i1+86, 0x000000);

    for (int var6 = 0; var6 < this.buttonList.size(); ++var6) {
      GuiButton var7 = (GuiButton) this.buttonList.get(var6);
      var7.drawButton(this.mc, par1, par2);
    }
  }
コード例 #5
0
  @Override
  public void updateTick(World world, int i, int j, int k, Random rand) {
    FloraManager manager = FloraManager.getInstance();
    FloraIndex fi = manager.findMatchingIndex(this.getType(world.getBlockMetadata(i, j, k)));

    float temp = TFC_Climate.getHeightAdjustedTemp(i, j, k);

    if (!world.isRemote
        && world.getBlockTileEntity(i, j, k) != null
        && TFC_Time.currentMonth < 6
        && fi != null
        && temp >= fi.minTemp
        && temp < fi.maxTemp) {
      TileEntityFruitTreeWood te = (TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k);
      int t = 1;
      if (TFC_Time.currentMonth < 3) t = 2;

      int leafGrowthRate = 20;
      int trunkGrowTime = 30;
      int branchGrowTime = 20;

      // grow upward
      if (te.birthTimeWood + trunkGrowTime < TFC_Time.totalDays()
          && te.height < 3
          && te.isTrunk
          && rand.nextInt(16 / t) == 0
          && (world.getBlockId(i, j + 1, k) == 0
              || world.getBlockId(i, j + 1, k) == TFCBlocks.fruitTreeLeaves.blockID)) {
        world.setBlockAndMetadata(i, j + 1, k, this.blockID, world.getBlockMetadata(i, j, k));
        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j + 1, k)).setTrunk(true);
        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j + 1, k)).setHeight(te.height + 1);
        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j + 1, k)).setBirth();

        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k)).setBirthWood(trunkGrowTime);
      } else if (te.birthTimeWood + branchGrowTime < TFC_Time.totalDays()
          && te.height == 2
          && te.isTrunk
          && rand.nextInt(16 / t) == 0
          && world.getBlockId(i, j + 1, k) != blockID) {
        int r = rand.nextInt(4);
        if (r == 0 && world.getBlockId(i + 1, j, k) == 0
            || world.getBlockId(i + 1, j, k) == TFCBlocks.fruitTreeLeaves.blockID) {
          world.setBlockAndMetadata(i + 1, j, k, this.blockID, world.getBlockMetadata(i, j, k));
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i + 1, j, k)).setTrunk(false);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i + 1, j, k)).setHeight(te.height);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i + 1, j, k)).setBirth();
        } else if (r == 1 && world.getBlockId(i, j, k - 1) == 0
            || world.getBlockId(i, j, k - 1) == TFCBlocks.fruitTreeLeaves.blockID) {
          world.setBlockAndMetadata(i, j, k - 1, this.blockID, world.getBlockMetadata(i, j, k));
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k - 1)).setTrunk(false);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k - 1)).setHeight(te.height);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k - 1)).setBirth();
        } else if (r == 2 && world.getBlockId(i - 1, j, k) == 0
            || world.getBlockId(i - 1, j, k) == TFCBlocks.fruitTreeLeaves.blockID) {
          world.setBlockAndMetadata(i - 1, j, k, this.blockID, world.getBlockMetadata(i, j, k));
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i - 1, j, k)).setTrunk(false);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i - 1, j, k)).setHeight(te.height);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i - 1, j, k)).setBirth();
        } else if (r == 3 && world.getBlockId(i, j, k + 1) == 0
            || world.getBlockId(i, j, k + 1) == TFCBlocks.fruitTreeLeaves.blockID) {
          world.setBlockAndMetadata(i, j, k + 1, this.blockID, world.getBlockMetadata(i, j, k));
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k + 1)).setTrunk(false);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k + 1)).setHeight(te.height);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k + 1)).setBirth();
        }

        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k)).setBirthWood(branchGrowTime);
      } else if (te.birthTimeWood + 1 < TFC_Time.totalDays()
          && rand.nextInt(leafGrowthRate) == 0
          && world.getBlockId(i, j + 2, k) != blockID) {
        if (world.getBlockId(i, j + 1, k) == 0
            && world.getBlockId(i, j + 2, k) == 0
            && BlockFruitLeaves.canStay(
                world, i, j + 1, k, TFCBlocks.fruitTreeLeaves.blockID)) // above
        {
          world.setBlockAndMetadata(
              i, j + 1, k, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i, j + 1, k);
        } else if (world.getBlockId(i + 1, j, k) == 0
            && world.getBlockId(i + 1, j + 1, k) == 0
            && BlockFruitLeaves.canStay(
                world, i + 1, j, k, TFCBlocks.fruitTreeLeaves.blockID)) // +x
        {
          world.setBlockAndMetadata(
              i + 1, j, k, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i + 1, j, k);
        } else if (world.getBlockId(i - 1, j, k) == 0
            && world.getBlockId(i - 1, j + 1, k) == 0
            && BlockFruitLeaves.canStay(
                world, i - 1, j, k, TFCBlocks.fruitTreeLeaves.blockID)) // -x
        {
          world.setBlockAndMetadata(
              i - 1, j, k, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i - 1, j, k);
        } else if (world.getBlockId(i, j, k + 1) == 0
            && world.getBlockId(i, j + 1, k + 1) == 0
            && BlockFruitLeaves.canStay(
                world, i, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID)) // +z
        {
          world.setBlockAndMetadata(
              i, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i, j, k + 1);
        } else if (world.getBlockId(i, j, k - 1) == 0
            && world.getBlockId(i, j + 1, k - 1) == 0
            && BlockFruitLeaves.canStay(
                world, i, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID)) // -z
        {
          world.setBlockAndMetadata(
              i, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i, j, k - 1);
        } else if (world.getBlockId(i + 1, j, k - 1) == 0
            && world.getBlockId(i + 1, j + 1, k - 1) == 0
            && BlockFruitLeaves.canStay(
                world, i + 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID)) // +x/-z
        {
          world.setBlockAndMetadata(
              i + 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i + 1, j, k - 1);
        } else if (world.getBlockId(i + 1, j, k + 1) == 0
            && world.getBlockId(i + 1, j + 1, k + 1) == 0
            && BlockFruitLeaves.canStay(
                world, i + 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID)) // +x/+z
        {
          world.setBlockAndMetadata(
              i + 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i + 1, j, k + 1);
        } else if (world.getBlockId(i - 1, j, k - 1) == 0
            && world.getBlockId(i - 1, j + 1, k - 1) == 0
            && BlockFruitLeaves.canStay(
                world, i - 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID)) // -x/-z
        {
          world.setBlockAndMetadata(
              i - 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i - 1, j, k - 1);
        } else if (world.getBlockId(i - 1, j, k + 1) == 0
            && world.getBlockId(i - 1, j + 1, k + 1) == 0
            && BlockFruitLeaves.canStay(
                world, i - 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID)) // -x/+z
        {
          world.setBlockAndMetadata(
              i - 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i - 1, j, k + 1);
        }
      }
    }
  }