diff --git a/cubyz-client/src/io/cubyz/client/Cubyz.java b/cubyz-client/src/io/cubyz/client/Cubyz.java index bba376c9..6d9cbe7c 100644 --- a/cubyz-client/src/io/cubyz/client/Cubyz.java +++ b/cubyz-client/src/io/cubyz/client/Cubyz.java @@ -334,7 +334,7 @@ public class Cubyz implements IGameLogic { if (breakCooldown == 0) { breakCooldown = 10; BlockInstance bi = msd.getSelectedBlockInstance(); - if (bi.getBlock().getHardness() != -1f) { + if (bi != null && bi.getBlock().getHardness() != -1f) { world.removeBlock(bi.getX(), bi.getY(), bi.getZ()); } else { return; diff --git a/cubyz-client/src/io/cubyz/client/CubyzMeshSelectionDetector.java b/cubyz-client/src/io/cubyz/client/CubyzMeshSelectionDetector.java index 600ad84d..be2f4e4d 100644 --- a/cubyz-client/src/io/cubyz/client/CubyzMeshSelectionDetector.java +++ b/cubyz-client/src/io/cubyz/client/CubyzMeshSelectionDetector.java @@ -43,6 +43,8 @@ public class CubyzMeshSelectionDetector { continue; try { for (BlockInstance bi : ch.getVisibles()) { + if(!bi.getBlock().isSolid()) + continue; ((BlockSpatial) bi.getSpatial()).setSelected(false); min.set(bi.getPosition()); max.set(bi.getPosition()); diff --git a/cubyz-common/src/io/cubyz/blocks/Block.java b/cubyz-common/src/io/cubyz/blocks/Block.java index d4a1e8c8..0026f37c 100644 --- a/cubyz-common/src/io/cubyz/blocks/Block.java +++ b/cubyz-common/src/io/cubyz/blocks/Block.java @@ -14,7 +14,6 @@ public class Block implements IRegistryElement { private String texture; private float hardness; private boolean solid = true; - //NOTE FOR ZEN: This variable is mostly making the fluids non-selectable! Also i couln't find where you made the blocks selected. Please make if this is false, then the block isn't blue (selected)!! private boolean selectable = true; public String getTexture() { diff --git a/cubyz-common/src/io/cubyz/blocks/OakLeaves.java b/cubyz-common/src/io/cubyz/blocks/OakLeaves.java index 83b0b888..45c4c7f7 100644 --- a/cubyz-common/src/io/cubyz/blocks/OakLeaves.java +++ b/cubyz-common/src/io/cubyz/blocks/OakLeaves.java @@ -5,6 +5,7 @@ public class OakLeaves extends Block { public OakLeaves() { setTexture("oak_leaves"); setID("cubyz:oak_leaves"); + this.transparent = true; } } \ No newline at end of file diff --git a/cubyz-common/src/io/cubyz/blocks/Water.java b/cubyz-common/src/io/cubyz/blocks/Water.java index 5dfadcde..58079288 100644 --- a/cubyz-common/src/io/cubyz/blocks/Water.java +++ b/cubyz-common/src/io/cubyz/blocks/Water.java @@ -6,6 +6,8 @@ public class Water extends Block { setTexture("water"); setID("cubyz:water"); setSelectable(false); + setSolid(false); + transparent = true; } } diff --git a/cubyz-common/src/io/cubyz/world/Chunk.java b/cubyz-common/src/io/cubyz/world/Chunk.java index 64ddd0a4..12cdd912 100644 --- a/cubyz-common/src/io/cubyz/world/Chunk.java +++ b/cubyz-common/src/io/cubyz/world/Chunk.java @@ -122,7 +122,7 @@ public class Chunk { if(generated) { BlockInstance[] neighbors = inst0.getNeighbors(); for (int i = 0; i < neighbors.length; i++) { - if (neighbors[i] == null) { + if (blocksLight(neighbors[i], inst0.getBlock().isTransparent())) { visibles.add(inst0); break; } @@ -134,7 +134,7 @@ public class Chunk { BlockInstance[] neighbors1 = neighbors[i].getNeighbors(); boolean vis = true; for (int j = 0; j < neighbors1.length; j++) { - if (neighbors1[j] == null) { + if (blocksLight(neighbors1[j], neighbors[i].getBlock().isTransparent())) { vis = false; break; } @@ -232,7 +232,8 @@ public class Chunk { int px = bi.getX()&15; int py = bi.getZ()&15; for (int i = 0; i < neighbors.length; i++) { - if (neighbors[i] == null && (j != 0 || i != 4) + if (blocksLight(neighbors[i], bi.getBlock().isTransparent()) + && (j != 0 || i != 4) && (px != 0 || i != 0 || chx0) && (px != 15 || i != 1 || chx1) && (py != 0 || i != 3 || chy0) @@ -259,7 +260,7 @@ public class Chunk { if(ch.contains(inst0)) { continue; } - if (inst0.getNeighbor(neighbor[k]) == null) { + if (blocksLight(inst0.getNeighbor(neighbor[k]), inst0.getBlock().isTransparent())) { ch.revealBlock(inst0); continue; } @@ -270,6 +271,13 @@ public class Chunk { } } + public boolean blocksLight(BlockInstance bi, boolean transparent) { + if(bi == null || (bi.getBlock().isTransparent() && !transparent)) { + return true; + } + return false; + } + // This function only allows a less than 50% of the underground to be ores. public BlockInstance selectOre(float rand, int height) { float chance1 = 0.0F;