Skip to content

Instantly share code, notes, and snippets.

@dizzyd
Created August 12, 2018 02:48
Show Gist options
  • Save dizzyd/f02cd3f1103adcfd024f0c47a0f16ccd to your computer and use it in GitHub Desktop.
Save dizzyd/f02cd3f1103adcfd024f0c47a0f16ccd to your computer and use it in GitHub Desktop.
diff --git a/build.gradle b/build.gradle
index 17dbe52..92b79dc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup.
-version = "1.0.5"
+version = "1.0.5a1"
group= "Prospects"
archivesBaseName = "prospects"
diff --git a/src/main/java/com/dizzyd/prospects/world/OreDictCache.java b/src/main/java/com/dizzyd/prospects/world/OreDictCache.java
index 1a2a718..de1d417 100644
--- a/src/main/java/com/dizzyd/prospects/world/OreDictCache.java
+++ b/src/main/java/com/dizzyd/prospects/world/OreDictCache.java
@@ -15,7 +15,7 @@ import java.util.HashMap;
public class OreDictCache {
private static HashMap<String, ItemStack> oreParticles = new HashMap<>();
- private static HashMap<IBlockState, String> oreNames = new HashMap<>();
+ private static HashMap<Integer, String> oreNames = new HashMap<>();
private static String[] knownOres =
new String[]{"Coal", "Iron", "Gold", "Copper", "Lead", "Silver", "Uranium", "Nickel", "Ferrous", "Diamond", "Redstone", "Tin", "Aluminum", "Bauxite"};
@@ -68,7 +68,7 @@ public class OreDictCache {
}
IBlockState bs = states.get(meta);
String normalizedName = normalizeName(base);
- oreNames.put(bs, normalizedName);
+ oreNames.put(Block.getStateId(bs), normalizedName);
if (oreParticle != null) {
oreParticles.put(normalizedName, oreParticle);
}
@@ -76,7 +76,7 @@ public class OreDictCache {
}
public static String getOreName(IBlockState bs) {
- return oreNames.get(bs);
+ return oreNames.get(Block.getStateId(bs));
}
public static ItemStack getParticle(String name) {
@@ -102,22 +102,22 @@ public class OreDictCache {
}
private static void initGeolosysOres() {
- oreNames.put(getBlockState("geolosys:ore_vanilla", 1), "Redstone"); // Cinnabar
- oreNames.put(getBlockState("geolosys:ore_vanilla", 2), "Gold"); // Gold
- oreNames.put(getBlockState("geolosys:ore_vanilla", 5), "Diamond"); // Kimberlite
- oreNames.put(getBlockState("geolosys:ore", 0), "Iron"); // Hematite
- oreNames.put(getBlockState("geolosys:ore", 1), "Nickel"); // Limonite
- oreNames.put(getBlockState("geolosys:ore", 2), "Copper"); // Malachite
- oreNames.put(getBlockState("geolosys:ore", 3), "Copper"); // Azurite
- oreNames.put(getBlockState("geolosys:ore", 4), "Tin"); // Cassiterite
- oreNames.put(getBlockState("geolosys:ore", 5), "Tin"); // Teallite
- oreNames.put(getBlockState("geolosys:ore", 6), "Silver"); // Galena
- oreNames.put(getBlockState("geolosys:ore", 6), "Lead"); // Galena
- oreNames.put(getBlockState("geolosys:ore", 7), "Aluminum"); // Bauxite
- oreNames.put(getBlockState("geolosys:ore", 9), "Uranium"); // Autunite
+ oreNames.put(getStateId("geolosys:ore_vanilla", 1), "Redstone"); // Cinnabar
+ oreNames.put(getStateId("geolosys:ore_vanilla", 2), "Gold"); // Gold
+ oreNames.put(getStateId("geolosys:ore_vanilla", 5), "Diamond"); // Kimberlite
+ oreNames.put(getStateId("geolosys:ore", 0), "Iron"); // Hematite
+ oreNames.put(getStateId("geolosys:ore", 1), "Nickel"); // Limonite
+ oreNames.put(getStateId("geolosys:ore", 2), "Copper"); // Malachite
+ oreNames.put(getStateId("geolosys:ore", 3), "Copper"); // Azurite
+ oreNames.put(getStateId("geolosys:ore", 4), "Tin"); // Cassiterite
+ oreNames.put(getStateId("geolosys:ore", 5), "Tin"); // Teallite
+ oreNames.put(getStateId("geolosys:ore", 6), "Silver"); // Galena
+ oreNames.put(getStateId("geolosys:ore", 6), "Lead"); // Galena
+ oreNames.put(getStateId("geolosys:ore", 7), "Aluminum"); // Bauxite
+ oreNames.put(getStateId("geolosys:ore", 9), "Uranium"); // Autunite
}
- private static IBlockState getBlockState(String name, int meta) {
- return Block.getBlockFromName(name).getStateFromMeta(meta);
+ private static int getStateId(String name, int meta) {
+ return Block.getStateId(Block.getBlockFromName(name).getStateFromMeta(meta));
}
}
diff --git a/src/main/java/com/dizzyd/prospects/world/WorldData.java b/src/main/java/com/dizzyd/prospects/world/WorldData.java
index 8f28b7d..e2ebefe 100644
--- a/src/main/java/com/dizzyd/prospects/world/WorldData.java
+++ b/src/main/java/com/dizzyd/prospects/world/WorldData.java
@@ -140,8 +140,8 @@ public class WorldData extends WorldSavedData {
if (isStale(cx, cz)) {
// Create a new chunk info object
ChunkInfo cinfo = new ChunkInfo();
+ double startTime = System.nanoTime();
- Prospects.logger.debug("Scanning chunk [" + cx + ", " + cz + "]...");
for (int i = 1; i <= 256; i++) {
for (int j = 0; j < 16; j++) {
for (int k = 0; k < 16; k++) {
@@ -166,8 +166,8 @@ public class WorldData extends WorldSavedData {
}
}
- Prospects.logger.debug("Total blocks scanned: " + total);
- Prospects.logger.debug("Ore types found: " + cinfo.ores.size());
+ double elapsedTime = (System.nanoTime() - startTime) / 1000;
+ Prospects.logger.debug("[{}, {}] {} blocks scanned in {} us; {} ore types found.", cx, cz, total, elapsedTime, cinfo.ores.size());
cinfo.expiry = world.getWorldTime() + Prospects.config.chunk_expiry;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment