public void drawScreen(int par1, int par2, float par3) {
   super.drawScreen(par1, par2, par3);
   boolean op = false; // TODO: Check if player is OP
   if (Keyboard.isKeyDown(Keyboard.KEY_O) && op) {
     player.openGui(ModUncrafting.instance, 1, worldObj, x, y, z);
   }
 }
Пример #2
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityplayer,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    super.onBlockActivated(world, x, y, z, entityplayer, side, hitX, hitY, hitZ);
    TileEntityQuern te = (TileEntityQuern) world.getBlockTileEntity(x, y, z);
    if (!world.isRemote) {
      if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.storage[2] != null) {
        te.shouldRotate = true;
        world.playSoundEffect(x, y, z, TFC_Sounds.STONEDRAG, 1, 1);
      } else if ((!te.shouldRotate && (hitX < 0.65 || hitZ < 0.65)) || te.storage[2] == null) {
        entityplayer.openGui(TerraFirmaCraft.instance, 33, world, x, y, z);
      }
    } else if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.hasQuern) {
      te.shouldRotate = true;
    }

    return true;
  }
Пример #3
0
 public void openGui(EntityPlayer player, int id, World world, int x, int y, int z) {
   if (debugGui)
     System.out.printf(
         "BaseMod.openGui: for %s with id %s in %s at (%s, %s, %s)\n",
         /*base*/ this, id, world, x, y, z);
   player.openGui(/*base*/ this, id, world, x, y, z);
 }
  @Override
  public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) {
    // we need to make sure the player has the correct tool out
    boolean isAxeorSaw = false;
    boolean isHammer = false;
    ItemStack equip = entityplayer.getCurrentEquippedItem();
    if (!world.isRemote) {
      if (equip != null) {
        for (int cnt = 0; cnt < Recipes.Axes.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Axes[cnt]) {
            isAxeorSaw = true;
            if (cnt < 4) isStone = true;
          }
        }
        //				for(int cnt = 0; cnt < Recipes.Saws.length && !isAxeorSaw; cnt++)
        //				{
        //					if(equip.getItem() == Recipes.Saws[cnt])
        //					{
        //						isAxeorSaw = true;
        //					}
        //				}
        for (int cnt = 0; cnt < Recipes.Hammers.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Hammers[cnt]) {
            isHammer = true;
          }
        }
      }
      if (isAxeorSaw) {
        damage = -1;
        ProcessTree(world, i, j, k, l, equip);

        if (damage + equip.getItemDamage() > equip.getMaxDamage()) {
          int ind = entityplayer.inventory.currentItem;
          entityplayer.inventory.setInventorySlotContents(ind, null);
          world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
        } else {
          equip.damageItem(damage, entityplayer);
        }
      } else if (isHammer) {
        EntityItem item =
            new EntityItem(
                world,
                i + 0.5,
                j + 0.5,
                k + 0.5,
                new ItemStack(Item.stick, 1 + world.rand.nextInt(3)));
        world.spawnEntityInWorld(item);
      } else {
        world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
      }
    }
  }
Пример #5
0
 private void handleArea(
     World world,
     int i,
     int j,
     int k,
     EntityPlayer entityplayer,
     TileEntityToolRack te,
     int slot,
     int dir) {
   boolean hasToolInHand =
       entityplayer.getCurrentEquippedItem() != null
           && (entityplayer.getCurrentEquippedItem().getItem() instanceof ItemTool
               || entityplayer.getCurrentEquippedItem().getItem() instanceof ItemWeapon
               || entityplayer.getCurrentEquippedItem().getItem() instanceof ItemHoe
               || entityplayer.getCurrentEquippedItem().getItem() instanceof ItemProPick);
   if (te.storage[slot] == null && hasToolInHand) {
     te.storage[slot] = entityplayer.getCurrentEquippedItem().copy();
     entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = null;
   } else if (te.storage[slot] != null) {
     te.ejectItem(slot, dir);
     te.storage[slot] = null;
   }
 }
Пример #6
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);
    }
  }