示例#1
0
  @Override
  public void drawButton(Minecraft mc, int x, int y) {
    if (this.drawButton) {

      int k = this.getHoverState(this.field_82253_i) - 1;
      if (icon == null) {
        k = 0;
        if (screen.AnvilEntity != null && screen.AnvilEntity.workRecipe != null) {
          PlanRecipe p = AnvilManager.getInstance().getPlan(screen.AnvilEntity.craftingPlan);
          if (p == null) return;
          RuleEnum[] Rules = p.rules;
          int[] ItemRules = screen.AnvilEntity.getItemRules();
          this.displayString = StringUtil.localize(Rules[ruleIndex].Name);
        }
      }

      TFC_Core.bindTexture(GuiAnvil.texture);
      GL11.glColor4ub(red, green, blue, (byte) 255);
      this.drawTexturedModalRect(
          this.xPosition,
          this.yPosition,
          this.bX + k * 16,
          this.bY + (ruleIndex * 22),
          this.bW,
          this.bH);

      this.field_82253_i =
          x >= this.xPosition
              && y >= this.yPosition
              && x < this.xPosition + this.width
              && y < this.yPosition + this.height;

      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      if (icon != null) {
        TFC_Core.bindTexture(TextureMap.locationBlocksTexture);
        this.drawTexturedModelRectFromIcon(
            this.xPosition, this.yPosition, icon, this.width, this.height);
      }

      this.mouseDragged(mc, x, y);

      if (field_82253_i) {
        FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
        screen.drawTooltip(x, y, this.displayString);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      }
    }
  }
示例#2
0
  /** Sets the models various rotation angles then renders the model. */
  @Override
  public void render(
      Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
    // super.render(entity, par2, par3, par4, par5, par6, par7);
    // this.setRotationAngles(par2, par3, par4, par5, par6, par7, entity);

    float percent = TFC_Core.getPercentGrown((IAnimal) entity);
    float ageScale = 2.0F - percent;
    float offset = 1.4f - percent;

    this.setRotationAngles(par2, par3, par4, par5, par6, par7, entity);
    if (entity instanceof IAnimal) {
      GL11.glPushMatrix();
      GL11.glTranslatef(0.0F, (0.75f - (0.75f * percent)), 0f);
      GL11.glScalef(1 / ageScale, 1 / ageScale, 1 / ageScale);
      this.wolfHeadMain.renderWithRotation(par7);
      this.wolfBody.render(par7);
      this.wolfLeg1.render(par7);
      this.wolfLeg2.render(par7);
      this.wolfLeg3.render(par7);
      this.wolfLeg4.render(par7);
      this.wolfTail.renderWithRotation(par7);
      this.wolfMane.render(par7);
      GL11.glPopMatrix();
    }
  }
  /**
   * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
   * world, entityPlayer
   */
  @Override
  public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer entity) {
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, entity, true);
    FoodStatsTFC fs = TFC_Core.getPlayerFoodStats(entity);

    if (mop == null) {
      if (is.getItemDamage() > 1 && fs.needDrink()) {
        entity.setItemInUse(is, this.getMaxItemUseDuration(is));
      }
    } else {
      if (mop.typeOfHit == EnumMovingObjectType.TILE) {
        int i = mop.blockX;
        int j = mop.blockY;
        int k = mop.blockZ;
        if (world.getBlockTileEntity(i, j, k) != null
            && world.getBlockTileEntity(i, j, k) instanceof TEBarrel) {
          TEBarrel TE = (TEBarrel) world.getBlockTileEntity(i, j, k);
          if (TE.checkValidAddition(13)) {
            return new ItemStack(TFCItems.WoodenBucketEmpty);
          }
        }
      }
    }
    return is;
  }
示例#4
0
  /** Drop 0-2 items of this living's type */
  @Override
  protected void dropFewItems(boolean par1, int par2) {
    float ageMod = TFC_Core.getPercentGrown(this);
    this.dropItem(
        Item.feather.itemID, (int) (ageMod * this.size_mod * (5 + this.rand.nextInt(10))));

    if (isAdult()) {
      float foodWeight =
          ageMod
              * (this.size_mod
                  * 40); // 528 oz (33lbs) is the average yield of lamb after slaughter and
      // processing

      TFC_Core.animalDropMeat(this, Item.chickenRaw, foodWeight);
      this.dropItem(Item.bone.itemID, rand.nextInt(2) + 1);
    }
  }
  @Override
  public ItemStack onEaten(ItemStack is, World world, EntityPlayer player) {
    FoodStatsTFC foodstats = TFC_Core.getPlayerFoodStats(player);
    if (!world.isRemote && foodstats.needFood()) {

      world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);

      foodstats.eatFood(is);
      foodstats.restoreWater(player, 8000);

      TFC_Core.setPlayerFoodStats(player, foodstats);

      is.itemID = TFCItems.WoodenBucketEmpty.itemID;
      is.stackTagCompound = null;
    }
    return is;
  }
示例#6
0
  /** Called when the block is clicked by a player. Args: x, y, z, entityPlayer */
  @Override
  public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) {
    boolean hasHammer = false;
    for (int i = 0; i < 9; i++) {
      if (entityplayer.inventory.mainInventory[i] != null
          && entityplayer.inventory.mainInventory[i].getItem() instanceof ItemHammer)
        hasHammer = true;
    }
    if (entityplayer.getCurrentEquippedItem() != null
        && entityplayer.getCurrentEquippedItem().getItem() instanceof ItemChisel
        && hasHammer) {
      MovingObjectPosition objectMouseOver = Helper.getMouseOverObject(entityplayer, world);
      if (objectMouseOver == null) {
        return false;
      }
      int side = objectMouseOver.sideHit;

      int id = world.getBlockId(x, y, z);
      byte meta = (byte) world.getBlockMetadata(x, y, z);

      byte newMeta = 0;
      if (side == 0) {
        newMeta = (byte) (newMeta | 4);
      }

      int rot =
          MathHelper.floor_double((double) (entityplayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
      byte flip = (byte) (newMeta & 4);
      byte m = 0;

      if (rot == 0) {
        m = (byte) (2 | flip);
      } else if (rot == 1) {
        m = (byte) (1 | flip);
      } else if (rot == 2) {
        m = (byte) (3 | flip);
      } else if (rot == 3) {
        m = (byte) (0 | flip);
      }

      int mode = 0;
      if (!TFC_Core.isClient()) {
        PlayerInfo pi = PlayerManagerTFC.getInstance().getPlayerInfoFromPlayer(entityplayer);

        if (pi != null) mode = pi.ChiselMode;
      } else mode = ItemChisel.mode;

      if (mode == 1) {
        ItemChisel.CreateStairs(world, x, y, z, id, meta, m);
        return true;
      } else if (mode == 2) {
        ItemChisel.CreateSlab(world, x, y, z, id, meta, side);
        return true;
      }
    }
    return false;
  }
示例#7
0
  @Override
  protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    TFC_Core.bindTexture(
        new ResourceLocation(Reference.ModID, Reference.AssetPathGui + "gui_mold.png"));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int w = (width - xSize) / 2;
    int h = (height - ySize) / 2;
    drawTexturedModalRect(w, h, 0, 0, xSize, ySize);

    drawTexturedModalRect(w + 85, h + 17, 176, 0, drawArrowScaled(22) + 1, 15);

    PlayerInventory.drawInventory(this, width, height, ySize - PlayerInventory.invYSize);
  }
示例#8
0
  @Override
  public void updateEntity() {
    TFC_Core.handleItemTicking(this, worldObj, xCoord, yCoord, zCoord);

    if (charcoalFirepit != null && !charcoalFirepit.isInactiveCharcoalFirepit()) {
      --fireTimer;
      if (fireTimer == 0) {
        if (blocksToBeSetOnFire.size() > 0) setOnFire(blocksToBeSetOnFire);

        fireTimer = 100;
      }
    }
  }
示例#9
0
  @Override
  public void render(
      Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
    this.setRotationAngles(par2, par3, par4, par5, par6, par7);

    float percent = TFC_Core.getPercentGrown((IAnimal) entity);
    float ageScale = 2.0F - percent;
    float ageHeadScale = (float) Math.sqrt(1 / ageScale);
    float offset = 1.4f - percent;
    GL11.glPushMatrix();

    GL11.glTranslatef(0.0F, (0.75f - (0.75f * percent)), 0f);
    GL11.glScalef(ageHeadScale, ageHeadScale, ageHeadScale);
    GL11.glTranslatef(0.0F, 0, 0.1875f - (0.1875f * percent));
    if (percent < 0.5) {
      horn1.isHidden = true; // rotateAngleX = (float)Math.PI;
      horn2.isHidden = true; // rotateAngleX = -(float)Math.PI;
      if (percent < 0.75) {
        horn1b.isHidden = true;
        horn2b.isHidden = true;
      }
    }

    if (((IAnimal) entity).getGender() == GenderEnum.MALE) {
      udders.isHidden = true;
    } else {
      horn1b.isHidden = true;
      horn2b.isHidden = true;
    }
    head.render(par7);
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, (0.75f - (0.75f * percent)), 0f);
    GL11.glScalef(1 / ageScale, 1 / ageScale, 1 / ageScale);

    body.render(par7);
    udders.render(par7);
    leg1.render(par7);
    leg2.render(par7);
    leg3.render(par7);
    leg4.render(par7);
    GL11.glPopMatrix();
  }
示例#10
0
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  @Override
  public void onLivingUpdate() {
    // Handle Hunger ticking
    if (hunger > 168000) {
      hunger = 168000;
    }
    if (hunger > 0) {
      hunger--;
    }

    syncData();
    if (isAdult()) {
      setGrowingAge(0);
    } else {
      setGrowingAge(-1);
    }

    roosterCrow();

    // Make sure that the vanilla egg timer is never after to reach 0 but always setting it back to
    // 9999
    this.timeUntilNextEgg = 9999;
    /** This Cancels out the changes made to growingAge by EntityAgeable */
    TFC_Core.PreventEntityDataUpdate = true;
    if (getGender() == GenderEnum.MALE) {
      nextEgg = 10000;
    }
    super.onLivingUpdate();
    TFC_Core.PreventEntityDataUpdate = false;

    if (hunger > 144000
        && rand.nextInt(100) == 0
        && getHealth() < TFC_Core.getEntityMaxHealth(this)
        && !isDead) {
      this.heal(1);
    }
  }
示例#11
0
  @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;
      }
    }
  }
示例#12
0
 @Override
 public boolean canCoordinateBeSpawn(int par1, int par2) {
   int var3 = this.worldObj.getFirstUncoveredBlock(par1, par2);
   // return var3 == Block.grass.blockID;
   return TFC_Core.isGrass(var3);
 }
  @Override
  public boolean generate(World world, Random random, int xCoord, int yCoord, int zCoord) {
    int treeHeight = random.nextInt(6) + 3;
    boolean flag = true;
    if (yCoord < 1 || yCoord + treeHeight + 1 > world.getHeight()) {
      return false;
    }
    for (int i1 = yCoord; i1 <= yCoord + 1 + treeHeight; i1++) {
      byte byte0 = 1;
      if (i1 == yCoord) {
        byte0 = 0;
      }
      if (i1 >= yCoord + 1 + treeHeight - 2) {
        byte0 = 2;
      }
      for (int i2 = xCoord - byte0; i2 <= xCoord + byte0 && flag; i2++) {
        for (int l2 = zCoord - byte0; l2 <= zCoord + byte0 && flag; l2++) {
          if (i1 >= 0 && i1 < world.getHeight()) {
            int j3 = world.getBlockId(i2, i1, l2);
            if (j3 != 0 && j3 != TFCBlocks.Leaves.blockID && j3 != TFCBlocks.Sapling.blockID) {
              flag = false;
            }
          } else {
            flag = false;
          }
        }
      }
    }

    if (!flag) {
      return false;
    }
    int var3 = world.getBlockId(xCoord, yCoord - 1, zCoord);
    if (!(TFC_Core.isSoil(var3)) || yCoord >= world.getHeight() - treeHeight - 1) {
      return false;
    }
    // DataLayer rockLayer1 =
    // ((TFCWorldChunkManager)world.getWorldChunkManager()).getRockLayerAt(xCoord, zCoord, 0);
    // set the block below the tree to dirt.
    // world.setBlockAndMetadata(xCoord, yCoord - 1, zCoord,
    // TFC_Core.getTypeForGrass(rockLayer1.data2), TFC_Core.getSoilMetaFromStone(rockLayer1.data1,
    // rockLayer1.data2));
    // Now we create the leaves. generates from the bottom up.
    for (int treeHeightOffset = yCoord + 1;
        treeHeightOffset <= yCoord + treeHeight;
        treeHeightOffset++) {
      int treeDiameter = treeHeightOffset - (yCoord + treeHeight);
      int treeRadius = 1 - treeDiameter / 2;

      for (int xPos = xCoord - 1; xPos <= xCoord + 1; xPos++) {
        int l3 = xPos - xCoord;
        for (int zPos = zCoord - 1; zPos <= zCoord + 1; zPos++) {
          int j4 = zPos - zCoord;
          if ((Math.abs(l3) != treeRadius
                  || Math.abs(j4) != treeRadius
                  || random.nextInt(2) != 0 && treeDiameter != 0)
              && world.getBlockId(xPos, treeHeightOffset, zPos) == 0) {
            setBlockAndMetadata(
                world, xPos, treeHeightOffset, zPos, TFCBlocks.Leaves.blockID, treeId);
          }
        }
      }
    }
    // Here we crate the tree trunk
    for (int l1 = 0; l1 < treeHeight; l1++) {
      int k2 = world.getBlockId(xCoord, yCoord + l1, zCoord);
      if (k2 == 0
          || k2 == TFCBlocks.Leaves.blockID
          || Block.blocksList[k2].canBeReplacedByLeaves(world, xCoord, yCoord + l1, zCoord)) {
        setBlockAndMetadata(world, xCoord, yCoord + l1, zCoord, TFCBlocks.Wood.blockID, treeId);
      }
    }

    return true;
  }
示例#14
0
  @Override
  public void generate(
      Random random,
      int chunkX,
      int chunkZ,
      World world,
      IChunkProvider chunkGenerator,
      IChunkProvider chunkProvider) {
    chunkX *= 16;
    chunkZ *= 16;

    int xCoord;
    int yCoord;
    int zCoord;

    int grassPerChunk = 0;
    int flowersPerChunk = 0;
    int mushroomsPerChunk = 0;

    DataLayer evt =
        ((TFCWorldChunkManager) world.provider.worldChunkMgr).getEVTLayerAt(chunkX, chunkZ);
    DataLayer rainfall =
        ((TFCWorldChunkManager) world.provider.worldChunkMgr).getRainfallLayerAt(chunkX, chunkZ);
    float bioTemperature;

    if (rainfall.floatdata1 >= 62.5f) {}

    if (rainfall.floatdata1 >= 125) {
      grassPerChunk += 12;
      flowersPerChunk += 1;
      mushroomsPerChunk += 1;
    }
    if (rainfall.floatdata1 >= 250) {
      grassPerChunk += 18;
      flowersPerChunk += 1;
      mushroomsPerChunk += 1;
    }
    if (rainfall.floatdata1 >= 500) {
      grassPerChunk += 24;
      flowersPerChunk += 1;
      mushroomsPerChunk += 1;
    }
    if (rainfall.floatdata1 >= 1000) {
      mushroomsPerChunk += 1;
    }
    if (rainfall.floatdata1 >= 2000) {
      mushroomsPerChunk += 1;
    }

    for (int i = 0; i < flowersPerChunk; ++i) {
      xCoord = chunkX + random.nextInt(16) + 8;
      zCoord = chunkZ + random.nextInt(16) + 8;
      yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord);
      bioTemperature = TFC_Climate.getBioTemperatureHeight(xCoord, yCoord, zCoord);

      if (bioTemperature > 1.5) {
        plantYellowGen.generate(world, random, xCoord, yCoord, zCoord);

        if (random.nextInt(4) == 0) {
          xCoord = chunkX + random.nextInt(16) + 8;
          zCoord = chunkZ + random.nextInt(16) + 8;
          yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord);
          bioTemperature = TFC_Climate.getBioTemperatureHeight(xCoord, yCoord, zCoord);
          if (bioTemperature > 1.5) {
            plantRedGen.generate(world, random, xCoord, yCoord, zCoord);
          }
        }
      }
    }

    for (int i = 0; i < grassPerChunk; ++i) {

      xCoord = chunkX + random.nextInt(16) + 8;
      zCoord = chunkZ + random.nextInt(16) + 8;
      yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord);

      bioTemperature = TFC_Climate.getBioTemperatureHeight(xCoord, yCoord, zCoord);
      if (bioTemperature >= 1.5) {
        //				WorldGenerator var6 = new WorldGenCustomTallGrass(Block.tallGrass.blockID, 1);
        //				var6.generate(world, random, xCoord, yCoord, zCoord);
        if (world.isAirBlock(xCoord, yCoord, zCoord)
            && ((BlockCustomTallGrass) Block.blocksList[Block.tallGrass.blockID])
                .canBlockStay(world, xCoord, yCoord, zCoord)) {
          world.setBlock(xCoord, yCoord, zCoord, Block.tallGrass.blockID, 1, 0x2);
        }
      }
    }

    for (int i = 0; i < mushroomsPerChunk; ++i) {
      if (random.nextInt(4) == 0) {
        xCoord = chunkX + random.nextInt(16) + 8;
        zCoord = chunkZ + random.nextInt(16) + 8;
        yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord);
        mushroomBrownGen.generate(world, random, xCoord, yCoord, zCoord);
      }

      if (random.nextInt(8) == 0) {
        xCoord = chunkX + random.nextInt(16) + 8;
        zCoord = chunkZ + random.nextInt(16) + 8;
        yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord);
        mushroomRedGen.generate(world, random, xCoord, yCoord, zCoord);
      }
    }

    if (random.nextInt(70) == 0 && rainfall.floatdata1 > 500) {
      xCoord = chunkX + random.nextInt(16) + 8;
      zCoord = chunkZ + random.nextInt(16) + 8;
      yCoord = world.getTopSolidOrLiquidBlock(xCoord, zCoord);
      switch (random.nextInt(9)) {
        default:
          {
            if (world.getBlockId(xCoord, yCoord, zCoord) == 0
                && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) {
              appleTree.generate(world, random, xCoord, yCoord, zCoord);
            }
            break;
          }
        case 1:
          {
            if (world.getBlockId(xCoord, yCoord, zCoord) == 0
                && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) {
              bananaTree.generate(world, random, xCoord, yCoord, zCoord);
            }
            break;
          }
        case 2:
          {
            if (world.getBlockId(xCoord, yCoord, zCoord) == 0
                && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) {
              orangeTree.generate(world, random, xCoord, yCoord, zCoord);
            }
            break;
          }
        case 3:
          {
            if (world.getBlockId(xCoord, yCoord, zCoord) == 0
                && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) {
              grappleTree.generate(world, random, xCoord, yCoord, zCoord);
            }
            break;
          }
        case 4:
          {
            if (world.getBlockId(xCoord, yCoord, zCoord) == 0
                && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) {
              lemonTree.generate(world, random, xCoord, yCoord, zCoord);
            }
            break;
          }
        case 5:
          {
            if (world.getBlockId(xCoord, yCoord, zCoord) == 0
                && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) {
              oliveTree.generate(world, random, xCoord, yCoord, zCoord);
            }
            break;
          }
        case 6:
          {
            if (world.getBlockId(xCoord, yCoord, zCoord) == 0
                && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) {
              cherryTree.generate(world, random, xCoord, yCoord, zCoord);
            }
            break;
          }
        case 7:
          {
            if (world.getBlockId(xCoord, yCoord, zCoord) == 0
                && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) {
              peachTree.generate(world, random, xCoord, yCoord, zCoord);
            }
            break;
          }
        case 8:
          {
            if (world.getBlockId(xCoord, yCoord, zCoord) == 0
                && TFC_Core.isGrass(world.getBlockId(xCoord, yCoord - 1, zCoord))) {
              plumTree.generate(world, random, xCoord, yCoord, zCoord);
            }
            break;
          }
          //                case 9:
          //                {
          //                    if(world.getBlockId(var2, var3, var4) == 0 &&
          // (world.getBlockId(var2, var3-1, var4) == mod_TFC_Core.terraGrass.blockID ||
          // world.getBlockId(var2, var3-1, var4) == mod_TFC_Core.terraGrass2.blockID))
          //                        cacaoTree.generate(world, rand, var2, var3, var4);
          //                    break;
          //                }
      }
    }
  }
示例#15
0
  @Override
  public boolean onUsed(
      World world,
      EntityPlayer player,
      int x,
      int y,
      int z,
      int blockID,
      int meta,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    byte newMeta = 0;
    if (side == 0) {
      newMeta = (byte) (newMeta | 4);
    }

    int rot = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    byte flip = (byte) (newMeta & 4);
    byte rotation = 0;

    if (rot == 0) {
      rotation = (byte) (2 | flip);
    } else if (rot == 1) {
      rotation = (byte) (1 | flip);
    } else if (rot == 2) {
      rotation = (byte) (3 | flip);
    } else if (rot == 3) {
      rotation = (byte) (0 | flip);
    }

    int mode = 0;
    PlayerInfo pi = null;

    int hasChisel = -1;
    int hasHammer = -1;

    for (int i = 0; i < 9; i++) {
      if (player.inventory.mainInventory[i] != null
          && player.inventory.mainInventory[i].getItem() instanceof ItemHammer) {
        hasHammer = i;
      }
    }

    if (player.inventory.mainInventory[player.inventory.currentItem] != null
        && player.inventory.mainInventory[player.inventory.currentItem].getItem()
            instanceof ItemChisel) {
      hasChisel = player.inventory.currentItem;
    }

    if (!world.isRemote) {
      pi = PlayerManagerTFC.getInstance().getPlayerInfoFromPlayer(player);

      if (pi != null) {
        mode = pi.ChiselMode;
      }
    } else {
      pi = PlayerManagerTFC.getInstance().getClientPlayer();
    }

    if (pi != null) {
      mode = pi.ChiselMode;
    }

    if (hasChisel >= 0) {
      if (mode == 0) {
        if (side == 0 && world.getBlockId(x, y + 1, z) == blockID) {
          return false;
        }

        CreateSmooth(world, x, y, z, blockID, meta);

        player.inventory.mainInventory[hasChisel].damageItem(1, player);

        return true;
      } else if (mode == 1) {
        if ((side == 0)
            && TFC_Core.isRawStone(blockID)
            && TFC_Core.isRawStone(world.getBlockId(x, y + 1, z))) {
          return false;
        }

        ItemChisel.CreateStairs(world, x, y, z, blockID, meta, rotation);

        player.inventory.mainInventory[hasChisel].damageItem(1, player);

        return true;
      } else if (mode == 2) {
        if ((side == 0)
            && TFC_Core.isRawStone(blockID)
            && TFC_Core.isRawStone(world.getBlockId(x, y + 1, z))) {
          return false;
        }

        ItemChisel.CreateSlab(world, x, y, z, blockID, meta, side);

        player.inventory.mainInventory[hasChisel].damageItem(1, player);

        return true;
      } else if (mode == 3 && pi.lockMatches(x, y, z)) {
        ItemChisel.CreateDetailed(world, x, y, z, blockID, meta, side, hitX, hitY, hitZ);
        if (random.nextInt(4) == 0) {
          player.inventory.mainInventory[hasChisel].damageItem(1, player);
        }
        return true;
      }
    }
    return true;
  }
示例#16
0
  @Override
  public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) {
    // we need to make sure teh palyer has the correct tool out
    boolean isAxeorSaw = false;
    ItemStack equip = entityplayer.getCurrentEquippedItem();
    if (equip != null) {
      for (int cnt = 0; cnt < Recipes.Axes.length && !isAxeorSaw; cnt++) {
        if (equip.getItem() == Recipes.Axes[cnt]) {
          isAxeorSaw = true;
        }
      }
      for (int cnt = 0; cnt < Recipes.Saws.length && !isAxeorSaw; cnt++) {
        if (equip.getItem() == Recipes.Saws[cnt]) {
          isAxeorSaw = true;
        }
      }
    }
    if (isAxeorSaw) {
      int x = i;
      int y = 0;
      int z = k;
      int count = 0;

      if (world.getBlockId(i, j + 1, k) == blockID || world.getBlockId(i, j - 1, k) == blockID) {
        // super.harvestBlock(world, entityplayer, i, j, k, l);
        boolean checkArray[][][] = new boolean[11][50][11];

        if (TFC_Core.isGrass(world.getBlockId(i, j + y - 1, k))
            || TFC_Core.isDirt(world.getBlockId(i, j + y - 1, k))) {
          boolean reachedTop = false;
          while (!reachedTop) {
            if (l != 9 && l != 15 && world.getBlockId(x, j + y + 1, z) == 0) {
              reachedTop = true;
            } else if ((l == 9 || l == 15)
                && world.getBlockId(x, j + y + 1, z) == 0
                && world.getBlockId(x + 1, j + y + 1, z) != blockID
                && world.getBlockId(x - 1, j + y + 1, z) != blockID
                && world.getBlockId(x, j + y + 1, z + 1) != blockID
                && world.getBlockId(x, j + y + 1, z - 1) != blockID
                && world.getBlockId(x - 1, j + y + 1, z - 1) != blockID
                && world.getBlockId(x - 1, j + y + 1, z + 1) != blockID
                && world.getBlockId(x + 1, j + y + 1, z + 1) != blockID
                && world.getBlockId(x + 1, j + y + 1, z - 1) != blockID) {
              reachedTop = true;
            }

            scanLogs(world, i, j + y, k, l, checkArray, 6, y, 6);

            y++;
          }
        }
      } else if (world.getBlockId(i + 1, j, k) == blockID
          || world.getBlockId(i - 1, j, k) == blockID
          || world.getBlockId(i, j, k + 1) == blockID
          || world.getBlockId(i, j, k - 1) == blockID) {
        Random R = new Random();
        if (R.nextInt(100) > 50 && isAxeorSaw) {
          dropBlockAsItem_do(world, i, j, k, new ItemStack(TFCItems.FruitTreeSapling1, 1, l));
        }
      }
    } else {
      world.setBlockAndMetadata(i, j, k, blockID, l);
    }
  }