From c7a277da8e493e10c4bb740d475b41556e9e99d6 Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Tue, 26 Mar 2019 18:29:18 +0100 Subject: [PATCH] Fix transparency --- cubyz-common/src/io/cubyz/api/Registry.java | 4 ---- cubyz-common/src/io/cubyz/world/LocalWorld.java | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cubyz-common/src/io/cubyz/api/Registry.java b/cubyz-common/src/io/cubyz/api/Registry.java index 83387c7d..de842642 100644 --- a/cubyz-common/src/io/cubyz/api/Registry.java +++ b/cubyz-common/src/io/cubyz/api/Registry.java @@ -6,8 +6,6 @@ import java.util.List; import io.cubyz.CubyzLogger; public class Registry { - private int IDs = 0; - private HashMap hashMap = new HashMap<>(); private boolean debug = Boolean.parseBoolean(System.getProperty("registry.debugEnabled", "false")); private boolean alwaysError = Boolean.parseBoolean(System.getProperty("registry.dumpAsError", "true")); @@ -36,8 +34,6 @@ public class Registry { System.err.flush(); return; } - element.setID(IDs); - IDs++; hashMap.put(element.getRegistryID().toString(), element); if (debug) { CubyzLogger.instance.info("Registered " + getType(element.getClass()) + " as " + element.getRegistryID()); diff --git a/cubyz-common/src/io/cubyz/world/LocalWorld.java b/cubyz-common/src/io/cubyz/world/LocalWorld.java index 6df5ae59..ff4b7a80 100644 --- a/cubyz-common/src/io/cubyz/world/LocalWorld.java +++ b/cubyz-common/src/io/cubyz/world/LocalWorld.java @@ -224,11 +224,24 @@ public class LocalWorld extends World { public void generate() { Random r = new Random(); + int ID = 0; seed = r.nextInt(); blocks = new Block[CubzRegistries.BLOCK_REGISTRY.registered().length]; for (IRegistryElement ire : CubzRegistries.BLOCK_REGISTRY.registered()) { Block b = (Block) ire; - blocks[b.ID] = b; + if(!b.isTransparent()) { + blocks[ID] = b; + b.ID = ID; + ID++; + } + } + for (IRegistryElement ire : CubzRegistries.BLOCK_REGISTRY.registered()) { + Block b = (Block) ire; + if(b.isTransparent()) { + blocks[ID] = b; + b.ID = ID; + ID++; + } } }