Esempio n. 1
0
 private void logDebug(EntityPlayer player, String message) {
   if (player == null) {
     Logging.log(message);
   } else {
     Logging.message(player, EnumChatFormatting.YELLOW + message);
   }
 }
  @SubscribeEvent
  public void onBlockPlaceEvent(BlockEvent.PlaceEvent event) {
    float blocker = RadiationShieldRegistry.getBlocker(event.block);
    if (blocker >= 0.99f) {
      return;
    }

    World world = event.blockSnapshot.world;
    DRRadiationManager radiationManager = DRRadiationManager.getManager(world);
    Map<GlobalCoordinate, DRRadiationManager.RadiationSource> radiationSources =
        radiationManager.getRadiationSources();
    if (radiationSources.isEmpty()) {
      return;
    }

    int x = event.blockSnapshot.x;
    int y = event.blockSnapshot.y;
    int z = event.blockSnapshot.z;
    for (Map.Entry<GlobalCoordinate, DRRadiationManager.RadiationSource> entry :
        radiationSources.entrySet()) {
      DRRadiationManager.RadiationSource source = entry.getValue();
      float radius = source.getRadius();
      GlobalCoordinate gc = entry.getKey();
      Coordinate c = gc.getCoordinate();
      if (Math.abs(c.getX() - x) < radius
          && Math.abs(c.getY() - y) < radius
          && Math.abs(c.getZ() - z) < radius) {
        Logging.logDebug("Add blocker at: " + x + "," + y + "," + z);
        QuadTree radiationTree = source.getRadiationTree(world, c.getX(), c.getY(), c.getZ());
        radiationTree.addBlocker(x, y, z, blocker);
      }
    }
  }
Esempio n. 3
0
 private int calculateCostFactor(DimletKey key) {
   DimletEntry dimletEntry = KnownDimletConfiguration.getEntry(key);
   if (dimletEntry == null) {
     Logging.logError("Something went wrong for key: " + key);
     return 0;
   }
   return (int) (dimletEntry.getRfMaintainCost() * DimletConfiguration.afterCreationCostFactor);
 }
Esempio n. 4
0
 @Override
 public boolean onItemUse(
     ItemStack stack,
     EntityPlayer player,
     World world,
     int x,
     int y,
     int z,
     int side,
     float sx,
     float sy,
     float sz) {
   TileEntity te = world.getTileEntity(x, y, z);
   NBTTagCompound tagCompound = stack.getTagCompound();
   if (tagCompound == null) {
     tagCompound = new NBTTagCompound();
   }
   if (te instanceof CounterTileEntity) {
     tagCompound.setInteger("dim", world.provider.dimensionId);
     tagCompound.setInteger("monitorx", x);
     tagCompound.setInteger("monitory", y);
     tagCompound.setInteger("monitorz", z);
     Block block = player.worldObj.getBlock(x, y, z);
     String name = "<invalid>";
     if (block != null && !block.isAir(world, x, y, z)) {
       name = BlockInfo.getReadableName(block, world.getBlockMetadata(x, y, z));
     }
     tagCompound.setString("monitorname", name);
     if (world.isRemote) {
       Logging.message(player, "Counter module is set to block '" + name + "'");
     }
   } else {
     tagCompound.removeTag("dim");
     tagCompound.removeTag("monitorx");
     tagCompound.removeTag("monitory");
     tagCompound.removeTag("monitorz");
     tagCompound.removeTag("monitorname");
     if (world.isRemote) {
       Logging.message(player, "Counter module is cleared");
     }
   }
   stack.setTagCompound(tagCompound);
   return true;
 }
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (!world.isRemote) {
      int id = player.worldObj.provider.dimensionId;
      RfToolsDimensionManager dimensionManager =
          RfToolsDimensionManager.getDimensionManager(player.worldObj);
      DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
      if (dimensionInformation == null) {
        Logging.message(player, "Not an RFTools dimension!");
      } else {
        String name = dimensionInformation.getName();
        DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
        int power = storage != null ? storage.getEnergyLevel(id) : 0;

        Logging.message(
            player,
            EnumChatFormatting.BLUE
                + "Name: "
                + name
                + " (Id "
                + id
                + ")"
                + EnumChatFormatting.YELLOW
                + "    Power: "
                + power
                + " RF");
        if (player.isSneaking()) {
          Logging.message(
              player,
              EnumChatFormatting.RED
                  + "Description: "
                  + dimensionInformation.getDescriptor().getDescriptionString());
          System.out.println(
              "Description:  = " + dimensionInformation.getDescriptor().getDescriptionString());
        }
      }
      return stack;
    }
    return stack;
  }
Esempio n. 6
0
  private void func_147423_a(int chunkX4, int chunkY4, int chunkZ4) {
    this.noiseData4 =
        this.noiseGen6.generateNoiseOctaves(
            this.noiseData4, chunkX4, chunkZ4, 5, 5, 200.0D, 200.0D, 0.5D);
    this.noiseData1 =
        this.noiseGen3.generateNoiseOctaves(
            this.noiseData1,
            chunkX4,
            chunkY4,
            chunkZ4,
            5,
            33,
            5,
            8.555150000000001D,
            4.277575000000001D,
            8.555150000000001D);
    this.noiseData2 =
        this.noiseGen1.generateNoiseOctaves(
            this.noiseData2, chunkX4, chunkY4, chunkZ4, 5, 33, 5, 684.412D, 684.412D, 684.412D);
    this.noiseData3 =
        this.noiseGen2.generateNoiseOctaves(
            this.noiseData3, chunkX4, chunkY4, chunkZ4, 5, 33, 5, 684.412D, 684.412D, 684.412D);
    int l = 0;
    int i1 = 0;

    boolean domaze = false;
    boolean elevated = false;
    boolean donearlands =
        provider.dimensionInformation.getTerrainType() == TerrainType.TERRAIN_NEARLANDS;

    if (donearlands) {
      elevated = true;
    }

    if (provider.dimensionInformation.hasFeatureType(FeatureType.FEATURE_MAZE)) {
      domaze = true;
      long s2 = (((chunkX4 >> 2) + provider.seed + 13) * 314) + (chunkZ4 >> 2) * 17L;
      Random rand = new Random(s2);
      rand.nextFloat(); // Skip one.
      elevated = ((chunkX4 >> 2) & 1) == 0;
      if (rand.nextFloat() < .2f) {
        elevated = !elevated;
      }
    }

    if (donearlands) {
      int cx = chunkX4 >> 2;
      int cz = chunkZ4 >> 2;
      if (Math.abs(cx) < 5 && Math.abs(cz) < 5) {
        elevated = false;
      }
    }

    if (provider.biomesForGeneration == null) {
      Logging.log("Dimension " + world.provider.dimensionId + " has a problem! Ignoring for now.");
      return;
    }

    for (int j1 = 0; j1 < 5; ++j1) {
      for (int k1 = 0; k1 < 5; ++k1) {
        float f = 0.0F;
        float f1 = 0.0F;
        float f2 = 0.0F;
        byte b0 = 2;
        BiomeGenBase biomegenbase = provider.biomesForGeneration[j1 + 2 + (k1 + 2) * 10];

        for (int l1 = -b0; l1 <= b0; ++l1) {
          for (int i2 = -b0; i2 <= b0; ++i2) {
            BiomeGenBase biomegenbase1 =
                provider.biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10];
            float f3 = biomegenbase1.rootHeight;
            float f4 = biomegenbase1.heightVariation;

            if (domaze || donearlands) {
              if (f3 > 0.0F && elevated) {
                if (provider.worldType == WorldType.AMPLIFIED) {
                  f3 = 2.0F + f3 * 1.5f;
                  f4 = 1.0F + f4 * 3.0f;
                } else {
                  f3 = 2.0F + f3;
                  f4 = 0.5F + f4 * 1.5f;
                }
              } else {
                if (provider.worldType == WorldType.AMPLIFIED && f3 > 0.0f) {
                  f3 = 0.5F + f3 * 1.5F;
                  f4 = 0.5F + f4 * 2.0F;
                } else {
                  f4 = f4 * 0.5F;
                }
              }
            } else {
              if (provider.worldType == WorldType.AMPLIFIED && f3 > 0.0F) {
                f3 = 1.0F + f3 * 2.0F;
                f4 = 1.0F + f4 * 4.0F;
              }
            }

            float f5 = parabolicField[l1 + 2 + (i2 + 2) * 5] / (f3 + 2.0F);

            if (biomegenbase1.rootHeight > biomegenbase.rootHeight) {
              f5 /= 2.0F;
            }

            f += f4 * f5;
            f1 += f3 * f5;
            f2 += f5;
          }
        }

        f /= f2;
        f1 /= f2;
        f = f * 0.9F + 0.1F;
        f1 = (f1 * 4.0F - 1.0F) / 8.0F;
        double d12 = this.noiseData4[i1] / 8000.0D;

        if (d12 < 0.0D) {
          d12 = -d12 * 0.3D;
        }

        d12 = d12 * 3.0D - 2.0D;

        if (d12 < 0.0D) {
          d12 /= 2.0D;

          if (d12 < -1.0D) {
            d12 = -1.0D;
          }

          d12 /= 1.4D;
          d12 /= 2.0D;
        } else {
          if (d12 > 1.0D) {
            d12 = 1.0D;
          }

          d12 /= 8.0D;
        }

        ++i1;
        double d13 = f1;
        double d14 = f;
        d13 += d12 * 0.2D;
        d13 = d13 * 8.5D / 8.0D;
        double d5 = 8.5D + d13 * 4.0D;

        for (int j2 = 0; j2 < 33; ++j2) {
          double d6 = (j2 - d5) * 12.0D * 128.0D / 256.0D / d14;

          if (d6 < 0.0D) {
            d6 *= 4.0D;
          }

          double d7 = this.noiseData2[l] / 512.0D;
          double d8 = this.noiseData3[l] / 512.0D;
          double d9 = (this.noiseData1[l] / 10.0D + 1.0D) / 2.0D;
          double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6;

          if (j2 > 29) {
            double d11 = ((j2 - 29) / 3.0F);
            d10 = d10 * (1.0D - d11) + -10.0D * d11;
          }

          this.noiseField[l] = d10;
          ++l;
        }
      }
    }
  }