Skip to content

Commit

Permalink
Fix Flaxbeard#143 crashes related to config changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaxbeard committed May 1, 2020
1 parent a984293 commit 3ccb11d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,20 @@ public static OilWorldInfo getOilWorldInfo(World world, int chunkX, int chunkZ)
if (!empty)
{
Biome biome = world.getBiomeForCoordsBody(new BlockPos(chunkX << 4, 64, chunkZ << 4));
int weight = Math.abs(query % getTotalWeight(dim, biome));
for (Map.Entry<ReservoirType, Integer> e : reservoirList.entrySet())
int totalWeight = getTotalWeight(dim, biome);
if (totalWeight > 0)
{
if (e.getKey().validDimension(dim) && e.getKey().validBiome(biome))
int weight = Math.abs(query % totalWeight);
for (Map.Entry<ReservoirType, Integer> e : reservoirList.entrySet())
{
weight -= e.getValue();
if (weight < 0)
if (e.getKey().validDimension(dim) && e.getKey().validBiome(biome))
{
res = e.getKey();
break;
weight -= e.getValue();
if (weight < 0)
{
res = e.getKey();
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public static void handleItemTooltip(ItemTooltipEvent event)

int amnt = ItemNBTHelper.getInt(stack, "oil");
List<String> tooltip = event.getToolTip();
if (amnt > 0)
if (res != null && amnt > 0)
{
int est = (amnt / 1000) * 1000;
String test = new DecimalFormat("#,###.##").format(est);
Expand Down Expand Up @@ -417,7 +417,7 @@ public static void renderCoresampleInfo(RenderGameOverlayEvent.Post event)
}

String s = I18n.format("chat.immersivepetroleum.info.coresample.noOil");
if (amnt > 0)
if (res != null && amnt > 0)
{
int est = (amnt / 1000) * 1000;
String test = new DecimalFormat("#,###.##").format(est);
Expand Down

0 comments on commit 3ccb11d

Please sign in to comment.