Esempio n. 1
0
  @Override
  public void processCommand(ICommandSender sender, String[] params) {
    MinecraftServer server = MinecraftServer.getServer();
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);
    WorldServer world =
        server.worldServerForDimension(player.getEntityWorld().provider.dimensionId);

    if (!TFCOptions.enableDebugMode) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Debug Mode Required"));
      return;
    }

    if (params.length == 0) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk"));
      Chunk chunk = world.getChunkFromBlockCoords((int) player.posX, (int) player.posZ);
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = 0; y < 256; y++) {
            Block id = chunk.getBlock(x, y, z);
            if (id != TFCBlocks.Ore
                && id != TFCBlocks.Ore2
                && id != TFCBlocks.Ore3
                && id != Blocks.bedrock)
              world.setBlock(
                  x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    } else if (params.length == 1) {
      TFC_Core.sendInfoMessage(
          player,
          new ChatComponentText(
              "Stripping Chunks Within a Radius of " + Integer.parseInt(params[0])));
      int radius = Integer.parseInt(params[0]);
      for (int i = -radius; i <= radius; i++) {
        for (int k = -radius; k <= radius; k++) {
          Chunk chunk =
              world.getChunkFromBlockCoords(
                  (int) player.posX + (i * 16), (int) player.posZ + (k * 16));
          for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
              for (int y = 0; y < 256; y++) {
                Block id = chunk.getBlock(x, y, z);
                if (id != TFCBlocks.Ore
                    && id != TFCBlocks.Ore2
                    && id != TFCBlocks.Ore3
                    && id != Blocks.bedrock)
                  world.setBlock(
                      x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    }
  }
Esempio n. 2
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(Items.feather, (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, TFCItems.chickenRaw, foodWeight);
      this.dropItem(Items.bone, rand.nextInt(2) + 1);
    }
  }
Esempio n. 3
0
  /** Called upon block activation (right click on the block.) */
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    TEHopper te = getHopperTE(world, x, y, z);
    if (world.isRemote) {
      if (te != null && te.pressBlock != null && player.isSneaking()) {
        te.pressBlock = null;
        te.pressCooldown = 0;
      }
      return true;
    } else {
      if (te != null && te.pressCooldown == 0) {
        player.openGui(TerraFirmaCraft.instance, 49, world, x, y, z);
      } else if (te != null && te.pressBlock != null && player.isSneaking()) {
        TFC_Core.giveItemToPlayer(te.pressBlock, player);
        te.pressBlock = null;
        te.pressCooldown = 0;
      }

      return true;
    }
  }
Esempio n. 4
0
  @Override
  public void drawButton(Minecraft mc, int x, int y) {
    if (this.visible) {
      int k = this.getHoverState(this.field_146123_n) - 1;

      TFC_Core.bindTexture(GuiPlanSelection.texture);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      this.drawTexturedModalRect(this.xPosition, this.yPosition, 176, k * 18, 18, 18);
      this.field_146123_n =
          isPointInRegion(
              x,
              y); // x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width
                  // && y < this.yPosition + this.height;

      if (item != null) {
        renderInventorySlot(item, this.xPosition + 1, this.yPosition + 1);
      }

      this.mouseDragged(mc, x, y);

      if (field_146123_n) {
        FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
        screen.drawTooltip(x, y, this.displayString);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      }
    }
  }
Esempio n. 5
0
 public int getSkillTotal(EntityPlayer p) {
   int skill = 0;
   int total = 0;
   for (String s : skillsList) {
     total++;
     skill += TFC_Core.getSkillStats(p).getSkillRaw(s);
   }
   if (total > 0) return skill / total;
   return 0;
 }
Esempio n. 6
0
  @Override
  public ArrayList<ItemStack> getDrops(
      World world, int x, int y, int z, int metadata, int fortune) {
    if (!TFC_Core.isSaltWater(world.getBlock(x, y + 1, z)))
      return super.getDrops(world, x, y, z, metadata, fortune);

    ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
    ret.add(getSeaWeed(world.rand));
    TEWaterPlant te = (TEWaterPlant) world.getTileEntity(x, y, z);
    ret.add(new ItemStack(te.getBlockType(), 1, metadata));
    return ret;
  }
Esempio n. 7
0
 /* Left-Click Harvest Berries */
 @Override
 public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityplayer) {
   if (!world.isRemote) {
     int meta = world.getBlockMetadata(x, y, z);
     if (TFC_Core.isSaltWater(world.getBlock(x, y + 1, z))
         && entityplayer.inventory.getCurrentItem() != null
         && entityplayer.inventory.getCurrentItem().getItem() instanceof ItemKnife) {
       dropBlockAsItem(world, x, y, z, getSeaWeed(world.rand));
       doBeforeFall(world, x, y, z);
     }
   }
 }
Esempio n. 8
0
 private boolean isWestStackValid(World world, int x, int y, int z) {
   if (((world.getBlock(x, y, z).getMaterial() == Material.rock
               || world.getBlock(x, y, z).getMaterial() == Material.iron)
           && world.getBlock(x, y, z).isNormalCube())
       || TFC_Core.isEastFaceSolid(
           world, x, y,
           z)) // Since its the West Block, we need to make sure the East side facing the stack is
               // solid
   {
     return true;
   }
   return false;
 }
  @SubscribeEvent
  public void onEntityHurt(LivingHurtEvent event) {
    EntityLivingBase entity = event.entityLiving;
    if (entity instanceof EntityPlayer) {
      float curMaxHealth =
          (float)
              ((EntityPlayer) entity)
                  .getEntityAttribute(SharedMonsterAttributes.maxHealth)
                  .getAttributeValue();
      float newMaxHealth = FoodStatsTFC.getMaxHealth((EntityPlayer) entity);
      float h = ((EntityPlayer) entity).getHealth();
      if (newMaxHealth != curMaxHealth)
        ((EntityPlayer) entity)
            .getEntityAttribute(SharedMonsterAttributes.maxHealth)
            .setBaseValue(newMaxHealth);
      if (newMaxHealth < h) ((EntityPlayer) entity).setHealth(newMaxHealth);
    }

    if (event.source == DamageSource.onFire) {
      event.ammount = 50;
    } else if (event.source == DamageSource.fall) {
      float healthMod = TFC_Core.getEntityMaxHealth(entity) / 1000f;
      event.ammount *= 80 * healthMod;
    } else if (event.source == DamageSource.drown) {
      event.ammount = 50;
    } else if (event.source == DamageSource.lava) {
      event.ammount = 100;
    } else if (event.source == DamageSource.inWall) {
      event.ammount = 100;
    } else if (event.source == DamageSource.fallingBlock) {
      event.ammount = 100;
    } else if (event.source.isExplosion()) {
      event.ammount *= 30;
    } else if (event.source == DamageSource.magic && entity.getHealth() > 25) {
      event.ammount = 25;
    } else if ("player".equals(event.source.damageType)
        || "mob".equals(event.source.damageType)
        || "arrow".equals(event.source.damageType)) {
      event.ammount = applyArmorCalculations(entity, event.source, event.ammount);
      if ("arrow".equals(event.source.damageType)) {
        Entity e = ((EntityDamageSourceIndirect) event.source).getSourceOfDamage();
        if (e instanceof EntityJavelin) {
          ((EntityJavelin) e).setDamageTaken((short) (((EntityJavelin) e).damageTaken + 10));
          if (((EntityJavelin) e).damageTaken >= ((EntityJavelin) e).pickupItem.getMaxDamage()) {
            e.setDead();
          }
        }
      }
    }
  }
Esempio n. 10
0
  @Override
  public boolean onUsedHandler(
      World world,
      EntityPlayer player,
      int x,
      int y,
      int z,
      Block id,
      int meta,
      int side,
      float hitX,
      float hitY,
      float hitZ) {

    if (TFC_Core.isNaturalStone(world.getBlock(x, y + 1, z))
        && TFC_Core.isNaturalStone(world.getBlock(x, y + 2, z))) {
      return false;
    }

    int hasChisel = hasChisel(player);
    if (hasChisel >= 0) {
      if (id == TFCBlocks.stoneIgIn) {
        world.setBlock(x, y, z, TFCBlocks.stoneIgInSmooth, meta, 0x2);
      } else if (id == TFCBlocks.stoneIgEx) {
        world.setBlock(x, y, z, TFCBlocks.stoneIgExSmooth, meta, 0x2);
      } else if (id == TFCBlocks.stoneSed) {
        world.setBlock(x, y, z, TFCBlocks.stoneSedSmooth, meta, 0x2);
      } else if (id == TFCBlocks.stoneMM) {
        world.setBlock(x, y, z, TFCBlocks.stoneMMSmooth, meta, 0x2);
      }

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

    return true;
  }
Esempio n. 11
0
  public boolean isStackValid(int i, int j, int k) {
    Block yNegBlock = worldObj.getBlock(i, j - 1, k);
    if (yNegBlock != TFCBlocks.Molten
        && worldObj.getBlock(i, j - 1, k).getMaterial() != Material.rock
        && !worldObj.getBlock(i, j - 1, k).isNormalCube()
        && yNegBlock != TFCBlocks.BlastFurnace
        && TFC_Core.isTopFaceSolid(worldObj, i, j - 1, k)) {
      return false;
    }

    maxValidStackSize = 0;
    for (int num = 0; num < 5; num++) {
      if (!((BlockBlastFurnace) TFCBlocks.BlastFurnace).checkStackAt(worldObj, i, j + num, k))
        break;
      maxValidStackSize++;
    }
    if (maxValidStackSize == 0) return false;
    return true;
  }
Esempio n. 12
0
  @Override
  public void updateEntity() {
    if (!worldObj.isRemote) TFC_Core.handleItemTicking(this, worldObj, xCoord, yCoord, zCoord);

    hasQuern = storage[2] != null;

    if (shouldRotate) {
      rotatetimer++;
      if (rotatetimer
          == 90) // This needs to be 73 if speed is * 1 in TESRQuern, use 90 for speed * 4
      {
        rotatetimer = 0;
        shouldRotate = false;
        if (!worldObj.isRemote) {
          if (processItem() && storage[2] != null) damageStackInSlot(2);
        }
      }
    }
  }
Esempio n. 13
0
  /**
   * Returns a boolean indicating whether or not the current location for the tree, spanning basePos
   * to to the height limit, is valid.
   */
  private boolean validTreeLocation() {
    int[] var1 = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]};
    int[] var2 =
        new int[] {this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2]};
    Block var3 = this.worldObj.getBlock(this.basePos[0], this.basePos[1] - 1, this.basePos[2]);

    if (!(TFC_Core.isSoil(var3))) {
      return false;
    } else {
      int var4 = this.checkBlockLine(var1, var2);

      if (var4 == -1) {
        return true;
      } else if (var4 < 6) {
        return false;
      } else {
        this.heightLimit = var4;
        return true;
      }
    }
  }
Esempio n. 14
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);
    }
  }
Esempio n. 15
0
  @Override
  public boolean generate(World world, Random rand, int x, int y, int z) {
    Block block;
    do {
      block = world.getBlock(x, y, z);
      if (!(block.isLeaves(world, x, y, z) || block.isAir(world, x, y, z))) {
        break;
      }
      --y;
    } while (y > 0);

    Block block1 = world.getBlock(x, y, z);

    if (TFC_Core.isSoil(block1)) {
      ++y;
      this.setBlockAndNotifyAdequately(world, x, y, z, TFCBlocks.logNatural, this.meta);

      for (int l = y; l <= y + 2; ++l) {
        int i1 = l - y;
        int j1 = 2 - i1;

        for (int k1 = x - j1; k1 <= x + j1; ++k1) {
          int l1 = k1 - x;

          for (int i2 = z - j1; i2 <= z + j1; ++i2) {
            int j2 = i2 - z;

            if ((Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0)
                && world.getBlock(k1, l, i2).canBeReplacedByLeaves(world, k1, l, i2)) {
              this.setBlockAndNotifyAdequately(world, k1, l, i2, TFCBlocks.leaves, this.meta);
            }
          }
        }
      }
    }
    return true;
  }
Esempio n. 16
0
  @Override
  public void render(
      Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
    float percent = TFC_Core.getPercentGrown((IAnimal) entity);
    float ageScale = 2.0F - percent;
    float ageHeadScale = (float) Math.pow(1 / ageScale, 0.66);
    // float offset = 1.4f - percent;

    this.setRotationAngles(par2, par3, par4, par5, par6, par7, entity);
    if (entity instanceof IAnimal) {
      if (((IAnimal) entity).getGender() == GenderEnum.MALE) {
        if (((IAnimal) entity).isAdult()) {
          tusk1.isHidden = false;
          tusk2.isHidden = false;
        }
      }

      GL11.glPushMatrix();

      GL11.glTranslatef(0.0F, (0.75f - (0.75f * percent)), 0f);
      GL11.glScalef(ageHeadScale, ageHeadScale, ageHeadScale);
      GL11.glTranslatef(0.0F, (ageScale - 1) * -0.125f, 0.1875f - (0.1875f * percent));
      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);
      leg1.render(par7);
      leg2.render(par7);
      leg3.render(par7);
      leg4.render(par7);
      GL11.glPopMatrix();
    }
  }
Esempio n. 17
0
  @Override
  public void updateEntity() {
    if (!worldObj.isRemote) {
      CreateTuyereBlock();

      if (oreCount < 0) oreCount = 0;
      if (charcoalCount < 0) charcoalCount = 0;

      /* Create a list of all the items that are falling into the stack */
      List list =
          worldObj.getEntitiesWithinAABB(
              EntityItem.class,
              AxisAlignedBB.getBoundingBox(
                  xCoord, yCoord, zCoord, xCoord + 1, yCoord + moltenCount + 1.1, zCoord + 1));

      /*Create a list of any players that are inside the chimney*/
      List playerList =
          worldObj.getEntitiesWithinAABB(
              EntityPlayer.class,
              AxisAlignedBB.getBoundingBox(
                  xCoord, yCoord, zCoord, xCoord + 1, yCoord + moltenCount + 1.1, zCoord + 1));

      if (moltenCount == 0) moltenCount = 1;
      /*
       * Make sure the list isn't null or empty and that the stack is
       * valid 1 layer above the Molten Ore
       */
      if (list != null
          && !list.isEmpty()
          && ((BlockBlastFurnace) TFCBlocks.BlastFurnace)
              .checkStackAt(worldObj, xCoord, yCoord + moltenCount, zCoord)
          && (playerList == null || playerList.isEmpty())) {
        /*
         * Iterate through the list and check for charcoal, coke, and
         * ore
         */
        for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
          EntityItem entity = (EntityItem) iterator.next();
          boolean _isOre = TFC_Core.isOreIron(entity.getEntityItem());

          if (entity.getEntityItem().getItem() == TFCItems.Coal
                  && entity.getEntityItem().getItemDamage() == 1
              || entity.getEntityItem().getItem() == TFCItems.Coke) {
            for (int c = 0; c < entity.getEntityItem().stackSize; c++) {
              if (getTotalCount() < 40 && charcoalCount < (this.maxValidStackSize * 4)) {
                charcoalCount++;
                entity.getEntityItem().stackSize--;
              }
            }

            if (entity.getEntityItem().stackSize == 0) entity.setDead();
          }
          /*
           * If the item that's been tossed in is a type of Ore and it
           * can melt down into something then add the ore to the list
           * of items in the fire.
           */
          else if ((TFC_ItemHeat.IsCookable(entity.getEntityItem()) != -1 && _isOre)
              || (!_isOre && entity.getEntityItem().getItem() instanceof ISmeltable)) {
            int c = entity.getEntityItem().stackSize;
            int nonConsumedOre = 0;
            for (; c > 0; c--) {
              if (getTotalCount() < 40 && oreCount < (this.maxValidStackSize * 4)) {
                if (foundFlux(moltenCount)
                    && AddOreToFire(
                        new ItemStack(
                            entity.getEntityItem().getItem(),
                            1,
                            entity.getEntityItem().getItemDamage()))) oreCount += 1;
                else nonConsumedOre++;
              } else {
                nonConsumedOre++;
              }
            }

            if (c + nonConsumedOre == 0) entity.setDead();
            else {
              ItemStack is = entity.getEntityItem();
              is.stackSize = c + nonConsumedOre;
              entity.setEntityItemStack(is);
            }
          }
        }
      }

      /* Handle the temperature of the Bloomery */
      HandleTemperature();

      if (cookDelay > 0) cookDelay--;

      for (int i = 0; i < fireItemStacks.length && isValid; i++) {
        /* Handle temperature for each item in the stack */
        careForInventorySlot(fireItemStacks[i]);
        /* Cook each input item */
        if (worldObj.getBlock(xCoord, yCoord - 1, zCoord) == TFCBlocks.Crucible) {
          CookItem(i);
        }
      }

      // Every 5 seconds we do a validity check and update the molten ore
      // count
      if (slowCounter > 100) {
        // Here we make sure that the forge is valid
        isValid = CheckValidity();
        moltenCount = updateMoltenBlocks();
      }
      slowCounter++;
    }
  }
Esempio n. 18
0
  @Override
  public void updateEntity() {
    if (!worldObj.isRemote) {
      // Create a list of all the items that are falling onto the firepit
      List list =
          worldObj.getEntitiesWithinAABB(
              EntityItem.class,
              AxisAlignedBB.getBoundingBox(
                  xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1.1, zCoord + 1));

      if (list != null
          && !list.isEmpty()
          && fireItemStacks[0] == null) // Only go through the list if more fuel can fit.
      {
        // Iterate through the list and check for logs and peat
        for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
          EntityItem entity = (EntityItem) iterator.next();
          ItemStack is = entity.getEntityItem();
          Item item = is.getItem();

          if (item == TFCItems.logs || item == Item.getItemFromBlock(TFCBlocks.peat)) {
            for (int c = 0; c < is.stackSize; c++) {
              if (fireItemStacks[0] == null) // Secondary check for empty input slot.
              {
                /**
                 * Place a copy of only one of the logs into the fuel slot, due to the stack
                 * limitation of the fuel slots. Do not change to fireItemStacks[0] = is;
                 */
                setInventorySlotContents(0, new ItemStack(item, 1, is.getItemDamage()));
                is.stackSize--;
                handleFuelStack(); // Attempt to shift the fuel down so more fuel can be added
                                   // within the same for loop.
              }
            }

            if (is.stackSize == 0) entity.setDead();
          }
        }
      }

      // Here we take care of the item that we are cooking in the fire
      careForInventorySlot(fireItemStacks[1]);
      careForInventorySlot(fireItemStacks[7]);
      careForInventorySlot(fireItemStacks[8]);

      smokeFoods();

      /*hasCookingPot = fireItemStacks[1] != null &&fireItemStacks[1].getItem() == TFCItems.PotteryPot &&
      fireItemStacks[1].getItemDamage() == 1;*/

      // Now we cook the input item
      cookItem();

      // push the input fuel down the stack
      handleFuelStack();

      if (fireTemp < 1 && worldObj.getBlockMetadata(xCoord, yCoord, zCoord) != 0) {
        worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3);
        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
      } else if (fireTemp >= 1 && worldObj.getBlockMetadata(xCoord, yCoord, zCoord) != 1) {
        worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 3);
        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
      }

      // If the fire is still burning and has fuel
      if (fuelTimeLeft > 0 && fireTemp >= 1) {
        if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) != 2) {
          worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 2, 3);
          worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
        }
      } else if (fuelTimeLeft <= 0
          && fireTemp >= 1
          && fireItemStacks[5] != null
          && (!worldObj.canLightningStrikeAt(xCoord, yCoord, zCoord)
                  && !worldObj.canLightningStrikeAt(xCoord, yCoord + 1, zCoord)
              || !worldObj.isRaining())) {
        if (fireItemStacks[5] != null) {
          EnumFuelMaterial m = TFC_Core.getFuelMaterial(fireItemStacks[5]);
          fuelTasteProfile = m.ordinal();
          fireItemStacks[5] = null;
          fuelTimeLeft = m.burnTimeMax;
          fuelBurnTemp = m.burnTempMax;
        }
      }

      // Calculate the fire temp
      float desiredTemp = handleTemp();

      handleTempFlux(desiredTemp);

      // Here we handle the bellows
      handleAirReduction();

      // do a last minute check to verify stack size
      if (fireItemStacks[7] != null) {
        if (fireItemStacks[7].stackSize <= 0) fireItemStacks[7].stackSize = 1;
      }

      if (fireItemStacks[8] != null) {
        if (fireItemStacks[8].stackSize <= 0) fireItemStacks[8].stackSize = 1;
      }

      if (fuelTimeLeft <= 0) TFC_Core.handleItemTicking(this, worldObj, xCoord, yCoord, zCoord);
    }
  }
Esempio n. 19
0
 /**
  * Actually renders the given argument. This is a synthetic bridge method, always casting down its
  * argument and then handing it off to a worker function which does the actual work. In all
  * probabilty, the class Render is generic (Render<T extends Entity) and this method has signature
  * public void doRender(T entity, double d, double d1, double d2, float f, float f1). But JAD is
  * pre 1.5 so doesn't do that.
  */
 @Override
 public void doRender(
     Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
   this.shadowSize = 0.35f + (TFC_Core.getPercentGrown((IAnimal) par1Entity) * 0.35f);
   super.doRender(par1Entity, par2, par4, par6, par8, par9);
 }
Esempio n. 20
0
  @Override
  public void processCommand(ICommandSender sender, String[] params) {
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);

    if (!TFCOptions.enableDebugMode) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Debug Mode Required"));
      return;
    }

    MinecraftServer server = MinecraftServer.getServer();
    WorldServer world =
        server.worldServerForDimension(player.getEntityWorld().provider.dimensionId);
    if (params.length == 0) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk"));
      Chunk chunk = world.getChunkFromBlockCoords((int) player.posX, (int) player.posZ);
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = 0; y < 256; y++) {
            Block id = chunk.getBlock(x, y, z);
            if (id != Blocks.air
                && id != TFCBlocks.ore
                && id != TFCBlocks.ore2
                && id != TFCBlocks.ore3
                && id != Blocks.bedrock) {
              if (TFC_Core.isGround(
                  id)) // Automatically replace ground blocks to help with performance
              {
                world.setBlock(
                    x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
              } else {
                Boolean isOre = false;
                Iterator iter = WorldGenOre.oreList.values().iterator();
                while (iter.hasNext()) {
                  OreSpawnData osd = (OreSpawnData) iter.next();
                  if (osd != null && id == osd.block) {
                    isOre = true;
                    break;
                  }
                }

                if (!isOre) {
                  world.setBlock(
                      x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
                }
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    } else if (params.length == 1) {
      TFC_Core.sendInfoMessage(
          player,
          new ChatComponentText(
              "Stripping Chunks Within a Radius of " + Integer.parseInt(params[0])));
      int radius = Integer.parseInt(params[0]);
      for (int i = -radius; i <= radius; i++) {
        for (int k = -radius; k <= radius; k++) {
          Chunk chunk =
              world.getChunkFromBlockCoords((int) player.posX + i * 16, (int) player.posZ + k * 16);
          for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
              for (int y = 0; y < 256; y++) {
                Block id = chunk.getBlock(x, y, z);
                if (id != Blocks.air
                    && id != TFCBlocks.ore
                    && id != TFCBlocks.ore2
                    && id != TFCBlocks.ore3
                    && id != Blocks.bedrock) {
                  if (TFC_Core.isGround(
                      id)) // Automatically replace ground blocks to help with performance
                  {
                    world.setBlock(
                        x + (chunk.xPosition * 16),
                        y,
                        z + (chunk.zPosition * 16),
                        Blocks.air,
                        0,
                        2);
                  } else {
                    Boolean isOre = false;
                    Iterator iter = WorldGenOre.oreList.values().iterator();
                    while (iter.hasNext()) {
                      OreSpawnData osd = (OreSpawnData) iter.next();
                      if (osd != null && id == osd.block) {
                        isOre = true;
                        break;
                      }
                    }

                    if (!isOre) {
                      world.setBlock(
                          x + (chunk.xPosition * 16),
                          y,
                          z + (chunk.zPosition * 16),
                          Blocks.air,
                          0,
                          2);
                    }
                  }
                }
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    }
  }
Esempio n. 21
0
  @Override
  public void updateEntity() {
    if (!worldObj.isRemote) {
      ItemStack itemstack = storage[INPUT_SLOT];
      BarrelPreservativeRecipe preservative =
          BarrelManager.getInstance()
              .findMatchingPreservativeRepice(this, itemstack, fluid, sealed);
      if (itemstack != null && fluid != null && fluid.getFluid() == TFCFluids.FRESHWATER) {
        if (TFC_ItemHeat.hasTemp(itemstack)) {
          float temp = TFC_ItemHeat.getTemp(itemstack);
          if (fluid.amount >= 1 && temp > 1) {
            temp -= 50;
            fluid.amount -= 1;
            TFC_ItemHeat.setTemp(itemstack, temp);
            TFC_ItemHeat.handleItemHeat(itemstack);
          }
        }
      }
      if (fluid != null && itemstack != null && itemstack.getItem() instanceof IFood) {
        float w = ((IFood) itemstack.getItem()).getFoodWeight(itemstack);
        if (fluid.getFluid() == TFCFluids.VINEGAR) {
          // If the food is brined then we attempt to pickle it
          if (Food.isBrined(itemstack)
              && !Food.isPickled(itemstack)
              && w / fluid.amount <= Global.FOOD_MAX_WEIGHT / this.getMaxLiquid()
              && this.getSealed()
              && sealtime != 0
              && TFC_Time.getTotalHours() - sealtime >= 4) {
            fluid.amount -= 1 * w;
            Food.setPickled(itemstack, true);
          }
        }
      }

      if (preservative == null) {
        // No preservative was matched - decay normally
        TFC_Core.handleItemTicking(this, this.worldObj, xCoord, yCoord, zCoord);
      } else {
        float env = preservative.getEnvironmentalDecayFactor();
        float base = preservative.getBaseDecayModifier();
        if (Float.isNaN(env) || env < 0.0) {
          TFC_Core.handleItemTicking(this, this.worldObj, xCoord, yCoord, zCoord);
        } else if (Float.isNaN(base) || base < 0.0) {
          TFC_Core.handleItemTicking(this, this.worldObj, xCoord, yCoord, zCoord, env);
        } else {
          TFC_Core.handleItemTicking(this, this.worldObj, xCoord, yCoord, zCoord, env, base);
        }
      }

      // If lightning can strike here then it means that the barrel can see the sky, so rain can hit
      // it. If true then we fill
      // the barrel when its raining.
      if (!this.getSealed() && worldObj.canLightningStrikeAt(xCoord, yCoord + 1, zCoord)) {
        int count = getInvCount();
        if (count == 0 || count == 1 && this.getInputStack() != null) {
          if (this.fluid == null) fluid = new FluidStack(TFCFluids.FRESHWATER, 1);
          else if (this.fluid != null && fluid.getFluid() == TFCFluids.FRESHWATER)
            fluid.amount = Math.min(fluid.amount + 1, getMaxLiquid());
        }
      }

      // We only want to bother ticking food once per 5 seconds to keep overhead low.
      processTimer++;
      if (processTimer > 100) {
        processItems();
        processTimer = 0;
      }

      // Here we handle item stacks that are too big for MC to handle such as when making mortar.
      // If the stack is > its own max stack size then we split it and add it to the invisible solid
      // storage area or
      // spawn the item in the world if there is no room left.
      if (this.getFluidLevel() > 0 && getInputStack() != null) {
        int count = 1;
        while (this.getInputStack().stackSize > getInputStack().getMaxStackSize()) {
          ItemStack is = getInputStack().splitStack(getInputStack().getMaxStackSize());
          if (count < this.storage.length && this.getStackInSlot(count) == null) {
            this.setInventorySlotContents(count, is);
          } else {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, xCoord, yCoord, zCoord, is));
          }
          count++;
        }
      }

      // Move any items in the solid storage slots to the main slot if they exist and the barrel has
      // liquid.
      else if (this.getFluidLevel() > 0 && getInputStack() == null && this.getInvCount() > 0) {
        for (int i = 0; i < storage.length; i++) {
          if (storage[i] != null) {
            storage[INPUT_SLOT] = storage[i].copy();
            storage[i] = null;
            break;
          }
        }
      }

      // Reset our fluid if all of the liquid is gone.
      if (fluid != null && fluid.amount == 0) fluid = null;

      // Handle adding fluids to the barrel if the barrel is currently in input mode.
      if (mode == MODE_IN) {
        ItemStack container = getInputStack();
        FluidStack inLiquid = FluidContainerRegistry.getFluidForFilledItem(container);

        if (container != null && container.getItem() instanceof IFluidContainerItem) {
          FluidStack isfs = ((IFluidContainerItem) container.getItem()).getFluid(container);
          if (isfs != null && addLiquid(isfs)) {
            ((IFluidContainerItem) container.getItem())
                .drain(
                    container,
                    ((IFluidContainerItem) container.getItem()).getCapacity(container),
                    true);
          }
        } else if (inLiquid != null && container != null && container.stackSize == 1) {
          if (addLiquid(inLiquid)) {
            this.setInventorySlotContents(0, FluidContainerRegistry.drainFluidContainer(container));
          }
        }
      }
      // Drain liquid from the barrel to a container if the barrel is in output mode.
      else if (mode == MODE_OUT) {
        ItemStack container = getInputStack();

        if (container != null
            && fluid != null
            && container.getItem() instanceof IFluidContainerItem) {
          FluidStack isfs = ((IFluidContainerItem) container.getItem()).getFluid(container);
          if (isfs == null || fluid.isFluidEqual(isfs)) {
            fluid.amount -=
                ((IFluidContainerItem) container.getItem()).fill(container, fluid, true);
            if (fluid.amount == 0) fluid = null;
          }
        } else if (FluidContainerRegistry.isEmptyContainer(container)) {
          this.setInventorySlotContents(0, this.removeLiquid(getInputStack()));
        }
      }
    }
  }
Esempio n. 22
0
  private boolean checkHorizontal(World world, int x, int y, int z, boolean flip) {
    int dir = world.getBlockMetadata(x, y, z) & 3;

    if (flip) dir = flipDir(dir);

    int[] map = sidesMap[dir];

    boolean l = false;
    boolean r = false;
    if ((world.getBlock(x - map[0], y, z - map[1]).getMaterial() == Material.rock
            || world.getBlock(x - map[0], y, z - map[1]).getMaterial() == Material.iron)
        && world.getBlock(x - map[0], y, z - map[1]).isOpaqueCube()) l = true;

    if (!l && world.getBlock(x - map[0], y, z - map[1]) == TFCBlocks.Detailed
        || world.getBlock(x - map[0], y, z - map[1]) == TFCBlocks.stoneSlabs) {
      switch (dir) {
        case 0:
          if (TFC_Core.isNorthFaceSolid(world, x - map[0], y, z - map[1])
              && TFC_Core.isEastFaceSolid(world, x - map[0], y, z - map[1])) l = true;
          break;
        case 1:
          if (TFC_Core.isEastFaceSolid(world, x - map[0], y, z - map[1])
              && TFC_Core.isSouthFaceSolid(world, x - map[0], y, z - map[1])) l = true;
          break;
        case 2:
          if (TFC_Core.isSouthFaceSolid(world, x - map[0], y, z - map[1])
              && TFC_Core.isEastFaceSolid(world, x - map[0], y, z - map[1])) l = true;
          break;
        case 3:
          if (TFC_Core.isWestFaceSolid(world, x - map[0], y, z - map[1])
              && TFC_Core.isSouthFaceSolid(world, x - map[0], y, z - map[1])) l = true;
          break;
      }

      if (!TFC_Core.isBottomFaceSolid(world, x - map[0], y, z - map[1])) l = false;
      if (!TFC_Core.isTopFaceSolid(world, x - map[0], y, z - map[1])) l = false;
    }

    if ((world.getBlock(x + map[0], y, z + map[1]).getMaterial() == Material.rock
            || world.getBlock(x + map[0], y, z + map[1]).getMaterial() == Material.iron)
        && world.getBlock(x + map[0], y, z + map[1]).isOpaqueCube()) r = true;

    if (!r && world.getBlock(x + map[0], y, z + map[1]) == TFCBlocks.Detailed
        || world.getBlock(x + map[0], y, z + map[1]) == TFCBlocks.stoneSlabs) {
      switch (dir) {
        case 0:
          if (TFC_Core.isNorthFaceSolid(world, x + map[0], y, z + map[1])
              && TFC_Core.isWestFaceSolid(world, x + map[0], y, z + map[1])) r = true;
          break;
        case 1:
          if (TFC_Core.isEastFaceSolid(world, x + map[0], y, z + map[1])
              && TFC_Core.isNorthFaceSolid(world, x + map[0], y, z + map[1])) r = true;
          break;
        case 2:
          if (TFC_Core.isSouthFaceSolid(world, x + map[0], y, z + map[1])
              && TFC_Core.isWestFaceSolid(world, x + map[0], y, z + map[1])) r = true;
          break;
        case 3:
          if (TFC_Core.isWestFaceSolid(world, x + map[0], y, z + map[1])
              && TFC_Core.isNorthFaceSolid(world, x + map[0], y, z + map[1])) r = true;
          break;
      }
    }

    if (!TFC_Core.isBottomFaceSolid(world, x + map[0], y, z + map[1])) r = false;
    if (!TFC_Core.isTopFaceSolid(world, x + map[0], y, z + map[1])) r = false;

    if (l && r) return true;

    return false;
  }
Esempio n. 23
0
  /** Called upon block activation (right click on the block.) */
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (world.isRemote) {
      return true;
    } else {
      int i1 = world.getBlockMetadata(x, y, z);

      if (!isBlockHeadOfBed(i1)) {
        int j1 = getDirection(i1);
        x += footBlockToHeadBlockMap[j1][0];
        z += footBlockToHeadBlockMap[j1][1];

        if (world.getBlock(x, y, z) != this) return true;

        i1 = world.getBlockMetadata(x, y, z);
      }

      if (world.provider.canRespawnHere() && world.getBiomeGenForCoords(x, z) != TFCBiome.hell) {
        if (isBedOccupied(i1)) {
          EntityPlayer entityplayer1 = null;
          Iterator iterator = world.playerEntities.iterator();

          while (iterator.hasNext()) {
            EntityPlayer entityplayer2 = (EntityPlayer) iterator.next();

            if (entityplayer2.isPlayerSleeping()) {
              ChunkCoordinates chunkcoordinates = entityplayer2.playerLocation;

              if (chunkcoordinates.posX == x
                  && chunkcoordinates.posY == y
                  && chunkcoordinates.posZ == z) {
                entityplayer1 = entityplayer2;
              }
            }
          }

          if (entityplayer1 != null) {
            TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.bed.occupied"));
            return true;
          }

          setBedOccupied(world, x, y, z, false);
        }

        EnumStatus enumstatus = player.sleepInBedAt(x, y, z);

        if (enumstatus == EnumStatus.OK) {
          TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.customBed.sleep"));
          setBedOccupied(world, x, y, z, true);
          return true;
        } else {
          if (enumstatus == EnumStatus.NOT_POSSIBLE_NOW)
            TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.bed.noSleep"));
          else if (enumstatus == EnumStatus.NOT_SAFE)
            TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.bed.notSafe"));

          return true;
        }
      } else {
        double d0 = x + 0.5D;
        double d1 = y + 0.5D;
        double d2 = z + 0.5D;
        world.setBlockToAir(x, y, z);
        int k1 = getDirection(i1);
        x += footBlockToHeadBlockMap[k1][0];
        z += footBlockToHeadBlockMap[k1][1];

        if (world.getBlock(x, y, z) == this) {
          world.setBlockToAir(x, y, z);
          d0 = (d0 + x + 0.5D) / 2.0D;
          d1 = (d1 + y + 0.5D) / 2.0D;
          d2 = (d2 + z + 0.5D) / 2.0D;
        }

        world.newExplosion((Entity) null, x + 0.5F, y + 0.5F, z + 0.5F, 5.0F, true, true);
        return true;
      }
    }
  }
 public static void handleItemTicking(
     IInventory te, World world, int xCoord, int yCoord, int zCoord, int tickCount) {
   if ((tickCount) % 20 == 0) {
     TFC_Core.handleItemTicking(te, world, xCoord, yCoord, zCoord);
   }
 }
Esempio n. 25
0
  private boolean checkVertical(World world, int x, int y, int z, boolean flip) {
    int dir = world.getBlockMetadata(x, y, z) & 3;

    if (flip) dir = flipDir(dir);

    boolean b = false;
    boolean t = false;
    if ((world.getBlock(x, y - 1, z).getMaterial() == Material.rock
            || world.getBlock(x, y - 1, z).getMaterial() == Material.iron)
        && world.getBlock(x, y - 1, z).isOpaqueCube()) b = true;

    if (!b && world.getBlock(x, y - 1, z) == TFCBlocks.Detailed
        || world.getBlock(x, y - 1, z) == TFCBlocks.stoneSlabs) {
      switch (dir) {
        case 0:
          if (TFC_Core.isNorthFaceSolid(world, x, y - 1, z)
              && TFC_Core.isEastFaceSolid(world, x, y - 1, z)
              && TFC_Core.isWestFaceSolid(world, x, y - 1, z)) b = true;
          break;
        case 1:
          if (TFC_Core.isEastFaceSolid(world, x, y - 1, z)
              && TFC_Core.isNorthFaceSolid(world, x, y - 1, z)
              && TFC_Core.isSouthFaceSolid(world, x, y - 1, z)) b = true;
          break;
        case 2:
          if (TFC_Core.isSouthFaceSolid(world, x, y - 1, z)
              && TFC_Core.isEastFaceSolid(world, x, y - 1, z)
              && TFC_Core.isWestFaceSolid(world, x, y - 1, z)) b = true;
          break;
        case 3:
          if (TFC_Core.isWestFaceSolid(world, x, y - 1, z)
              && TFC_Core.isNorthFaceSolid(world, x, y - 1, z)
              && TFC_Core.isSouthFaceSolid(world, x, y - 1, z)) b = true;
          break;
      }

      if (!TFC_Core.isTopFaceSolid(world, x, y - 1, z)) b = false;
    }

    if ((world.getBlock(x, y + 1, z).getMaterial() == Material.rock
            || world.getBlock(x, y + 1, z).getMaterial() == Material.iron)
        && world.getBlock(x, y + 1, z).isOpaqueCube()) t = true;

    if (!t && world.getBlock(x, y + 1, z) == TFCBlocks.Detailed
        || world.getBlock(x, y + 1, z) == TFCBlocks.stoneSlabs) {
      switch (dir) {
        case 0:
          if (TFC_Core.isNorthFaceSolid(world, x, y + 1, z)
              && TFC_Core.isEastFaceSolid(world, x, y + 1, z)
              && TFC_Core.isWestFaceSolid(world, x, y + 1, z)) t = true;
          break;
        case 1:
          if (TFC_Core.isEastFaceSolid(world, x, y + 1, z)
              && TFC_Core.isNorthFaceSolid(world, x, y + 1, z)
              && TFC_Core.isSouthFaceSolid(world, x, y + 1, z)) t = true;
          break;
        case 2:
          if (TFC_Core.isSouthFaceSolid(world, x, y + 1, z)
              && TFC_Core.isEastFaceSolid(world, x, y + 1, z)
              && TFC_Core.isWestFaceSolid(world, x, y + 1, z)) t = true;
          break;
        case 3:
          if (TFC_Core.isWestFaceSolid(world, x, y + 1, z)
              && TFC_Core.isNorthFaceSolid(world, x, y + 1, z)
              && TFC_Core.isSouthFaceSolid(world, x, y + 1, z)) t = true;
          break;
      }

      if (!TFC_Core.isBottomFaceSolid(world, x, y + 1, z)
          || !TFC_Core.isTopFaceSolid(world, x, y + 1, z)) t = false;
    }

    if (b && t) return true;

    return false;
  }
Esempio n. 26
0
 /**
  * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
  * (coordinates passed are their own) Args: x, y, z, neighbor Block
  */
 @Override
 public void onNeighborBlockChange(World world, int x, int y, int z, Block b) {
   if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z))
     TFC_Core.setBlockToAirWithDrops(world, x, y, z);
 }