Make water more watery

This commit is contained in:
IntegratedQuantum 2019-03-25 18:52:05 +01:00
parent ab5947c363
commit ed8bb9b778
6 changed files with 18 additions and 6 deletions

View File

@ -334,7 +334,7 @@ public class Cubyz implements IGameLogic {
if (breakCooldown == 0) { if (breakCooldown == 0) {
breakCooldown = 10; breakCooldown = 10;
BlockInstance bi = msd.getSelectedBlockInstance(); BlockInstance bi = msd.getSelectedBlockInstance();
if (bi.getBlock().getHardness() != -1f) { if (bi != null && bi.getBlock().getHardness() != -1f) {
world.removeBlock(bi.getX(), bi.getY(), bi.getZ()); world.removeBlock(bi.getX(), bi.getY(), bi.getZ());
} else { } else {
return; return;

View File

@ -43,6 +43,8 @@ public class CubyzMeshSelectionDetector {
continue; continue;
try { try {
for (BlockInstance bi : ch.getVisibles()) { for (BlockInstance bi : ch.getVisibles()) {
if(!bi.getBlock().isSolid())
continue;
((BlockSpatial) bi.getSpatial()).setSelected(false); ((BlockSpatial) bi.getSpatial()).setSelected(false);
min.set(bi.getPosition()); min.set(bi.getPosition());
max.set(bi.getPosition()); max.set(bi.getPosition());

View File

@ -14,7 +14,6 @@ public class Block implements IRegistryElement {
private String texture; private String texture;
private float hardness; private float hardness;
private boolean solid = true; 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; private boolean selectable = true;
public String getTexture() { public String getTexture() {

View File

@ -5,6 +5,7 @@ public class OakLeaves extends Block {
public OakLeaves() { public OakLeaves() {
setTexture("oak_leaves"); setTexture("oak_leaves");
setID("cubyz:oak_leaves"); setID("cubyz:oak_leaves");
this.transparent = true;
} }
} }

View File

@ -6,6 +6,8 @@ public class Water extends Block {
setTexture("water"); setTexture("water");
setID("cubyz:water"); setID("cubyz:water");
setSelectable(false); setSelectable(false);
setSolid(false);
transparent = true;
} }
} }

View File

@ -122,7 +122,7 @@ public class Chunk {
if(generated) { if(generated) {
BlockInstance[] neighbors = inst0.getNeighbors(); BlockInstance[] neighbors = inst0.getNeighbors();
for (int i = 0; i < neighbors.length; i++) { for (int i = 0; i < neighbors.length; i++) {
if (neighbors[i] == null) { if (blocksLight(neighbors[i], inst0.getBlock().isTransparent())) {
visibles.add(inst0); visibles.add(inst0);
break; break;
} }
@ -134,7 +134,7 @@ public class Chunk {
BlockInstance[] neighbors1 = neighbors[i].getNeighbors(); BlockInstance[] neighbors1 = neighbors[i].getNeighbors();
boolean vis = true; boolean vis = true;
for (int j = 0; j < neighbors1.length; j++) { for (int j = 0; j < neighbors1.length; j++) {
if (neighbors1[j] == null) { if (blocksLight(neighbors1[j], neighbors[i].getBlock().isTransparent())) {
vis = false; vis = false;
break; break;
} }
@ -232,7 +232,8 @@ public class Chunk {
int px = bi.getX()&15; int px = bi.getX()&15;
int py = bi.getZ()&15; int py = bi.getZ()&15;
for (int i = 0; i < neighbors.length; i++) { 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 != 0 || i != 0 || chx0)
&& (px != 15 || i != 1 || chx1) && (px != 15 || i != 1 || chx1)
&& (py != 0 || i != 3 || chy0) && (py != 0 || i != 3 || chy0)
@ -259,7 +260,7 @@ public class Chunk {
if(ch.contains(inst0)) { if(ch.contains(inst0)) {
continue; continue;
} }
if (inst0.getNeighbor(neighbor[k]) == null) { if (blocksLight(inst0.getNeighbor(neighbor[k]), inst0.getBlock().isTransparent())) {
ch.revealBlock(inst0); ch.revealBlock(inst0);
continue; 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. // This function only allows a less than 50% of the underground to be ores.
public BlockInstance selectOre(float rand, int height) { public BlockInstance selectOre(float rand, int height) {
float chance1 = 0.0F; float chance1 = 0.0F;