Пример #1
0
  private static int findFuelValue(ItemStack stack) {
    try {
      Item item = stack.getItem();

      if (item instanceof ItemBlock) {
        Block block = InvTools.getBlockFromStack(stack);

        String name = block.getUnlocalizedName();
        if (name != null && name.contains("blockScaffold")) return 0;
      }

      //            if (itemID == Item.coal.itemID && stack.getItemDamage() == 0)
      //                return 1600;

      if (item == Items.blaze_rod) return 1000;

      FluidStack liquid = FluidItemHelper.getFluidStackInContainer(stack);
      if (liquid != null && Fluids.LAVA.get() == liquid.getFluid()) return liquid.amount;

      String name = stack.getItem().getUnlocalizedName();
      if (name != null && name.contains("itemScrap")) return 0;

      return TileEntityFurnace.getItemBurnTime(stack);
    } catch (Exception ex) {
      Game.logThrowable(
          "Error in Fuel Handler! Is some mod creating items that are not compliant with standards?",
          ex);
    }
    return 0;
  }
Пример #2
0
 @Override
 public void onPostBlockPlaced(World world, int x, int y, int z, int meta) {
   super.onPostBlockPlaced(world, x, y, z, meta);
   if (RailcraftConfig.printSignalDebug()) {
     Game.logTrace(Level.INFO, 10, "Signal Block onPostBlockPlaced. [{0}, {1}, {2}]", x, y, y);
   }
   TileEntity tile = world.getTileEntity(x, y, z);
   if (tile instanceof TileSignalFoundation) ((TileSignalFoundation) tile).onBlockPlaced();
 }
Пример #3
0
 @Override
 public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
   if (RailcraftConfig.printSignalDebug()) {
     Game.logTrace(Level.INFO, 10, "Signal Block breakBlock. [{0}, {1}, {2}]", x, y, z);
   }
   TileEntity tile = world.getTileEntity(x, y, z);
   if (tile instanceof TileSignalFoundation) ((TileSignalFoundation) tile).onBlockRemoval();
   super.breakBlock(world, x, y, z, block, meta);
 }
Пример #4
0
 @Override
 public void onBlockPlacedBy(
     World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) {
   if (RailcraftConfig.printSignalDebug()) {
     Game.logTrace(Level.INFO, 10, "Signal Block onBlockPlacedBy. [{0}, {1}, {2}]", x, y, z);
   }
   TileEntity tile = world.getTileEntity(x, y, z);
   if (tile instanceof TileSignalFoundation)
     ((TileSignalFoundation) tile).onBlockPlacedBy(entityliving, stack);
 }
Пример #5
0
  @Override
  public boolean onItemUse(
      ItemStack itemstack,
      EntityPlayer player,
      World world,
      int i,
      int j,
      int k,
      int l,
      float par8,
      float par9,
      float par10) {
    Block block = world.getBlock(i, j, k);
    if (TrackTools.isRailBlock(block)) {
      if (Game.isHost(world) && !CartTools.isMinecartAt(world, i, j, k, 0, null, true)) {
        int meta = ((BlockRailBase) block).getBasicRailMetadata(world, null, i, j, k);
        if (meta == 0 || meta == 1) {
          int playerYaw = -90 - MathHelper.floor_float(player.rotationYaw);
          for (; playerYaw > 360; playerYaw -= 360) ;
          for (; playerYaw < 0; playerYaw += 360) ;
          ForgeDirection facing = ForgeDirection.EAST;
          if (Math.abs(90 - playerYaw) <= 45) {
            facing = ForgeDirection.NORTH;
          } else if (Math.abs(180 - playerYaw) <= 45) {
            facing = ForgeDirection.WEST;
          } else if (Math.abs(270 - playerYaw) <= 45) {
            facing = ForgeDirection.SOUTH;
          }

          if (meta == 0 && facing == ForgeDirection.WEST) {
            facing = ForgeDirection.NORTH;
          } else if (meta == 0 && facing == ForgeDirection.EAST) {
            facing = ForgeDirection.SOUTH;
          } else if (meta == 1 && facing == ForgeDirection.SOUTH) {
            facing = ForgeDirection.EAST;
          } else if (meta == 1 && facing == ForgeDirection.NORTH) {
            facing = ForgeDirection.WEST;
          }

          //					System.out.println("PlayerYaw = " + playerYaw + " Yaw = " + facing + " Meta = " +
          // meta);

          EntityMinecart bore =
              new EntityTunnelBore(world, (float) i + 0.5F, (float) j, (float) k + 0.5F, facing);
          CartTools.setCartOwner(bore, player);
          world.spawnEntityInWorld(bore);
        }
      }
      itemstack.stackSize--;
      return true;
    } else {
      return false;
    }
  }
Пример #6
0
 @Override
 public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
   try {
     TileEntity tile = world.getTileEntity(x, y, z);
     if (tile instanceof TileSignalFoundation) {
       TileSignalFoundation structure = (TileSignalFoundation) tile;
       if (structure.getSignalType().needsSupport()
           && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP))
         world.func_147480_a(x, y, z, true);
       else structure.onNeighborBlockChange(block);
     }
   } catch (StackOverflowError error) {
     Game.logThrowable(Level.ERROR, "Error in BlockSignalBase.onNeighborBlockChange()", 10, error);
     throw error;
   }
 }