Transparent textures

+ the block selection detector now unselect when no block is looked at
This commit is contained in:
Randy 2019-03-25 13:13:50 +01:00
parent c39b059e51
commit 8b02f5794c
18 changed files with 32 additions and 12 deletions

3
.gitignore vendored
View File

@ -26,4 +26,5 @@ hs_err_pid*
.metadata/
.recommenders/
cubyz-client/logs/
cubyz-client/logs/
cubyz-client/cache

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -130,6 +130,13 @@ public class Cubyz implements IGameLogic {
@Override
public void init(Window window) throws Exception {
// Delete cache
File cache = new File("cache");
if (cache.exists()) {
for (File f : cache.listFiles()) {
f.delete();
}
}
//CubzLogger.useDefaultHandler = true;
gameUI = new UISystem();
gameUI.init(window);
@ -273,6 +280,8 @@ public class Cubyz implements IGameLogic {
public static final ArrayList<Chunk> EMPTY_CHUNK_LIST = new ArrayList<Chunk>();
public static final Block[] EMPTY_BLOCK_LIST = new Block[0];
float playerBobbing;
boolean bobbingUp;
@Override
public void render(Window window) {
if (window.shouldClose()) {
@ -280,13 +289,29 @@ public class Cubyz implements IGameLogic {
}
if (world != null) {
if (playerInc.x != 0 || playerInc.z != 0) { // while walking
if (bobbingUp) {
playerBobbing += 0.005f;
if (playerBobbing >= 0.05f) {
bobbingUp = false;
}
} else {
playerBobbing -= 0.005f;
if (playerBobbing <= -0.05f) {
bobbingUp = true;
}
}
} else {
//System.out.println("no bobbing");
//playerBobbing = 0;
}
if (playerInc.y != 0) {
world.getLocalPlayer().vy = playerInc.y;
}
if (playerInc.x != 0) {
world.getLocalPlayer().vx = playerInc.x;
}
ctx.getCamera().setPosition(world.getLocalPlayer().getPosition().x, world.getLocalPlayer().getPosition().y + 1.5f, world.getLocalPlayer().getPosition().z);
ctx.getCamera().setPosition(world.getLocalPlayer().getPosition().x, world.getLocalPlayer().getPosition().y + 1.5f + playerBobbing, world.getLocalPlayer().getPosition().z);
}
if (world != null) {
renderer.render(window, ctx, new Vector3f(0.3F, 0.3F, 0.3F), light, world.getChunks(), world.getBlocks());

View File

@ -23,8 +23,8 @@ public class CubyzMeshSelectionDetector {
}
/**
* Return selected spatial
* @return selected spatial, or null if none.
* Return selected block instance
* @return selected block instance, or null if none.
*/
public BlockInstance getSelectedBlockInstance() {
return selectedSpatial;
@ -37,6 +37,7 @@ public class CubyzMeshSelectionDetector {
public void selectSpatial(List<Chunk> chunks, Vector3f position, Vector3f dir) {
float closestDistance = Float.POSITIVE_INFINITY;
selectedSpatial = null;
for (Chunk ch : chunks) {
if(!ch.isLoaded())
continue;

View File

@ -1,6 +1,5 @@
package io.cubyz.utils;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
@ -37,10 +36,8 @@ public class TextureConverter {
System.err.println("Could not read cache of " + name + " texture");
}
}
BufferedImage out = new BufferedImage(1024, 1024, BufferedImage.TYPE_INT_RGB);
BufferedImage out = new BufferedImage(1024, 1024, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = out.createGraphics();
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, 1024, 1024);
g2d.drawImage(in, 0, 0, 512, 512, null);
g2d.drawImage(in, 512, 0, 512, 512, null);
g2d.drawImage(in, 0, 512, 512, 512, null);

View File

@ -7,8 +7,4 @@ public class OakLeaves extends Block {
setID("cubyz:oak_leaves");
}
public void update() {
}
}