Transparent textures
+ the block selection detector now unselect when no block is looked at
1
.gitignore
vendored
@ -27,3 +27,4 @@ hs_err_pid*
|
|||||||
.recommenders/
|
.recommenders/
|
||||||
|
|
||||||
cubyz-client/logs/
|
cubyz-client/logs/
|
||||||
|
cubyz-client/cache
|
BIN
cubyz-client/cache/bedrock.png
vendored
Before Width: | Height: | Size: 20 KiB |
BIN
cubyz-client/cache/coal_ore.png
vendored
Before Width: | Height: | Size: 16 KiB |
BIN
cubyz-client/cache/diamond_ore.png
vendored
Before Width: | Height: | Size: 17 KiB |
BIN
cubyz-client/cache/dirt.png
vendored
Before Width: | Height: | Size: 17 KiB |
BIN
cubyz-client/cache/emerald_ore.png
vendored
Before Width: | Height: | Size: 17 KiB |
BIN
cubyz-client/cache/gold_ore.png
vendored
Before Width: | Height: | Size: 17 KiB |
BIN
cubyz-client/cache/iron_ore.png
vendored
Before Width: | Height: | Size: 16 KiB |
BIN
cubyz-client/cache/oak_leaves.png
vendored
Before Width: | Height: | Size: 16 KiB |
BIN
cubyz-client/cache/oak_log.png
vendored
Before Width: | Height: | Size: 13 KiB |
BIN
cubyz-client/cache/ruby_ore.png
vendored
Before Width: | Height: | Size: 17 KiB |
BIN
cubyz-client/cache/sand.png
vendored
Before Width: | Height: | Size: 13 KiB |
BIN
cubyz-client/cache/stone.png
vendored
Before Width: | Height: | Size: 20 KiB |
BIN
cubyz-client/cache/water.png
vendored
Before Width: | Height: | Size: 6.1 KiB |
@ -130,6 +130,13 @@ public class Cubyz implements IGameLogic {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Window window) throws Exception {
|
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;
|
//CubzLogger.useDefaultHandler = true;
|
||||||
gameUI = new UISystem();
|
gameUI = new UISystem();
|
||||||
gameUI.init(window);
|
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 ArrayList<Chunk> EMPTY_CHUNK_LIST = new ArrayList<Chunk>();
|
||||||
public static final Block[] EMPTY_BLOCK_LIST = new Block[0];
|
public static final Block[] EMPTY_BLOCK_LIST = new Block[0];
|
||||||
|
|
||||||
|
float playerBobbing;
|
||||||
|
boolean bobbingUp;
|
||||||
@Override
|
@Override
|
||||||
public void render(Window window) {
|
public void render(Window window) {
|
||||||
if (window.shouldClose()) {
|
if (window.shouldClose()) {
|
||||||
@ -280,13 +289,29 @@ public class Cubyz implements IGameLogic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (world != null) {
|
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) {
|
if (playerInc.y != 0) {
|
||||||
world.getLocalPlayer().vy = playerInc.y;
|
world.getLocalPlayer().vy = playerInc.y;
|
||||||
}
|
}
|
||||||
if (playerInc.x != 0) {
|
if (playerInc.x != 0) {
|
||||||
world.getLocalPlayer().vx = playerInc.x;
|
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) {
|
if (world != null) {
|
||||||
renderer.render(window, ctx, new Vector3f(0.3F, 0.3F, 0.3F), light, world.getChunks(), world.getBlocks());
|
renderer.render(window, ctx, new Vector3f(0.3F, 0.3F, 0.3F), light, world.getChunks(), world.getBlocks());
|
||||||
|
@ -23,8 +23,8 @@ public class CubyzMeshSelectionDetector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return selected spatial
|
* Return selected block instance
|
||||||
* @return selected spatial, or null if none.
|
* @return selected block instance, or null if none.
|
||||||
*/
|
*/
|
||||||
public BlockInstance getSelectedBlockInstance() {
|
public BlockInstance getSelectedBlockInstance() {
|
||||||
return selectedSpatial;
|
return selectedSpatial;
|
||||||
@ -37,6 +37,7 @@ public class CubyzMeshSelectionDetector {
|
|||||||
|
|
||||||
public void selectSpatial(List<Chunk> chunks, Vector3f position, Vector3f dir) {
|
public void selectSpatial(List<Chunk> chunks, Vector3f position, Vector3f dir) {
|
||||||
float closestDistance = Float.POSITIVE_INFINITY;
|
float closestDistance = Float.POSITIVE_INFINITY;
|
||||||
|
selectedSpatial = null;
|
||||||
for (Chunk ch : chunks) {
|
for (Chunk ch : chunks) {
|
||||||
if(!ch.isLoaded())
|
if(!ch.isLoaded())
|
||||||
continue;
|
continue;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package io.cubyz.utils;
|
package io.cubyz.utils;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -37,10 +36,8 @@ public class TextureConverter {
|
|||||||
System.err.println("Could not read cache of " + name + " texture");
|
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();
|
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, 0, 0, 512, 512, null);
|
||||||
g2d.drawImage(in, 512, 0, 512, 512, null);
|
g2d.drawImage(in, 512, 0, 512, 512, null);
|
||||||
g2d.drawImage(in, 0, 512, 512, 512, null);
|
g2d.drawImage(in, 0, 512, 512, 512, null);
|
||||||
|
@ -7,8 +7,4 @@ public class OakLeaves extends Block {
|
|||||||
setID("cubyz:oak_leaves");
|
setID("cubyz:oak_leaves");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|