Skip to content

Commit

Permalink
Allow surface prospecting mechanism to be user-configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
oitsjustjose committed Oct 29, 2018
1 parent 743149d commit 49a129d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ public static class Prospecting
@Config.Name("Prospector's Pickaxe Diameter")
@Config.RangeInt(min = 0, max = 255)
public int proPickDiameter = 5;

@Config.Name("Surface Prospecting Results")
@Config.Comment("SAMPLES means prospecting on the surface returns the samples found\n"
+ "OREBLOCKS means prospecting on the surface returns the first Geolosys-registered Ore Block it finds")
public SURFACE_PROSPECTING_TYPE surfaceProspectingResults = SURFACE_PROSPECTING_TYPE.SAMPLES;

public enum SURFACE_PROSPECTING_TYPE
{
SAMPLES, OREBLOCKS;
}
}

public static class UserEntries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.oitsjustjose.geolosys.Geolosys;
import com.oitsjustjose.geolosys.common.api.GeolosysAPI;
import com.oitsjustjose.geolosys.common.config.ModConfig;
import com.oitsjustjose.geolosys.common.config.ModConfig.Prospecting.SURFACE_PROSPECTING_TYPE;

import org.lwjgl.opengl.GL11;

Expand Down Expand Up @@ -297,23 +298,45 @@ private String findOreInChunk(World world, BlockPos pos)
{
ChunkPos tempPos = new ChunkPos(pos);

for (int x = tempPos.getXStart(); x <= tempPos.getXEnd(); x++)
SURFACE_PROSPECTING_TYPE searchType = ModConfig.prospecting.surfaceProspectingResults;

if (searchType == SURFACE_PROSPECTING_TYPE.OREBLOCKS)
{
for (int z = tempPos.getZStart(); z <= tempPos.getZEnd(); z++)
for (int x = tempPos.getXStart(); x <= tempPos.getXEnd(); x++)
{
for (int y = 0; y < world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).getY(); y++)
for (int z = tempPos.getZStart(); z <= tempPos.getZEnd(); z++)
{
for (Entry<IBlockState, IBlockState> e : GeolosysAPI.oreBlocks.entrySet())
for (int y = 0; y < world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).getY(); y++)
{
if (e.getValue() == world.getBlockState(new BlockPos(x, y, z)))
if (GeolosysAPI.oreBlocks.keySet().contains(world.getBlockState(new BlockPos(x, y, z))))
{
return getNameForBlockState(e.getKey()) + " "
return getNameForBlockState(world.getBlockState(new BlockPos(x, y, z))) + " "
+ Geolosys.proxy.translate("geolosys.pro_pick.tooltip.found_surface");
}
}
}
}
}
else
{
for (int x = tempPos.getXStart(); x <= tempPos.getXEnd(); x++)
{
for (int z = tempPos.getZStart(); z <= tempPos.getZEnd(); z++)
{
for (int y = 0; y < world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).getY(); y++)
{
for (Entry<IBlockState, IBlockState> e : GeolosysAPI.oreBlocks.entrySet())
{
if (e.getValue() == world.getBlockState(new BlockPos(x, y, z)))
{
return getNameForBlockState(e.getKey()) + " "
+ Geolosys.proxy.translate("geolosys.pro_pick.tooltip.found_surface");
}
}
}
}
}
}

return Geolosys.proxy.translate("geolosys.pro_pick.tooltip.nonefound_surface");
}
Expand Down

0 comments on commit 49a129d

Please sign in to comment.