diff --git a/src/projectzombie/display/DisplayWindow.java b/src/projectzombie/display/DisplayWindow.java index b93e0bd..e3a68cd 100755 --- a/src/projectzombie/display/DisplayWindow.java +++ b/src/projectzombie/display/DisplayWindow.java @@ -47,6 +47,7 @@ public class DisplayWindow implements IMainloopTask public int glsl_discard_coords; public int glsl_do_discard_coords; public int glsl_do_lighting; + public int glsl_do_texture; public int glsl_model; public int glsl_camera; public int glsl_projection; @@ -144,6 +145,7 @@ public class DisplayWindow implements IMainloopTask glsl_discard_coords = GL33.glGetUniformLocation(environmentRenderer.program, "discard_coords"); glsl_do_discard_coords = GL33.glGetUniformLocation(environmentRenderer.program, "do_discard_coords"); glsl_do_lighting = GL33.glGetUniformLocation(environmentRenderer.program, "do_lighting"); + glsl_do_texture = GL33.glGetUniformLocation(environmentRenderer.program, "do_texture"); glsl_color = GL33.glGetUniformLocation(environmentRenderer.program, "color"); glsl_contrast = GL33.glGetUniformLocation(environmentRenderer.program, "contrast"); glsl_billboard = GL33.glGetUniformLocation(environmentRenderer.program, "billboard"); @@ -214,7 +216,8 @@ public class DisplayWindow implements IMainloopTask environmentRenderer.use(); DisplayLighting.updateLighting(); - GL33.glUniform1f(glsl_mist, 0); + GL33.glUniform1f(glsl_mist, 0.0078125f); + GL33.glUniform1i(glsl_do_texture, 1); if(Main.player.getHydration() < 0.2) { GL33.glUniform1f(glsl_contrast, (float)(0.2 - Main.player.getHydration()) * 1.6f); diff --git a/src/projectzombie/entity/Entity.java b/src/projectzombie/entity/Entity.java index 50bc962..defc466 100755 --- a/src/projectzombie/entity/Entity.java +++ b/src/projectzombie/entity/Entity.java @@ -320,47 +320,60 @@ public abstract class Entity implements ClassBdf private boolean moveIsLegal(Vec2d pos) { - Vec2i t_pos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0); - Chunk chunk = Main.world.getLayer().getChunk(pos); - tile_back = chunk.getBackTile(t_pos); - tile_front = chunk.getFrontTile(t_pos); + Layer layer = Main.world.getLayer(); // Is this entity solid if(isSolid) { - // Check the tile the player is standing on - Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0); + final Vec2i[] positions = { + new Vec2i(-1, -1), + new Vec2i(1, -1), + new Vec2i(1, 1), + new Vec2i(-1, 1), + new Vec2i(1, 0), + new Vec2i(0, 1), + new Vec2i(-1, 0), + new Vec2i(0, -1), + new Vec2i(0, 0), + }; + for(Vec2i tpos_offset : positions) { - // Get the tile - Tile t = tile_back.tile; + // Check the tile the player is standing on + Vec2i tpos = new Vec2i( + MathHelpers.floor(pos.x) + tpos_offset.x, + MathHelpers.floor(pos.y) + tpos_offset.y); + + TileState tile_back = layer.getBackTile(tpos); + TileState tile_front = layer.getFrontTile(tpos); - // Check the tiles hitbox if the tile is solid - if(t.tileSolid) { - // Is the entity in the tiles hitbox - Vec2d check = pos.subtract(new Vec2d(tpos.x + 0.5, tpos.y + 0.5)); - if(Math.max(Math.abs(check.x), Math.abs(check.y)) <= t.tileHitbox) + // Get the tile + Tile t = tile_back.tile; + + // Check the tiles hitbox if the tile is solid + if(t.tileSolid) { - // Send back false - return false; + // Is the entity in the tiles hitbox + Vec2d check = pos.subtract(tpos.toDouble()); + if(t.inHitbox(tile_back, check)) { + return false; + } } } - } - - { - // Get the front tile - Tile t = tile_front.tile; - // Check the tiles hitbox if the tile is solid - if(t.tileSolid) { - // Is the entity in the tiles hitbox - Vec2d check = pos.subtract(new Vec2d(tpos.x + 0.5, tpos.y + 0.5)); - if(Math.max(Math.abs(check.x), Math.abs(check.y)) <= t.tileHitbox) + // Get the front tile + Tile t = tile_front.tile; + + // Check the tiles hitbox if the tile is solid + if(t.tileSolid) { - // Send back false - return false; + // Is the entity in the tiles hitbox + Vec2d check = pos.subtract(tpos.toDouble()); + if(t.inHitbox(tile_front, check)) { + return false; + } } } } diff --git a/src/projectzombie/entity/player/EntityPlayer.java b/src/projectzombie/entity/player/EntityPlayer.java index 60c2107..7eb3033 100755 --- a/src/projectzombie/entity/player/EntityPlayer.java +++ b/src/projectzombie/entity/player/EntityPlayer.java @@ -61,6 +61,7 @@ public class EntityPlayer extends Entity implements public boolean dead = false; public boolean in_animation = false; public int attackedCooldown = 0; + private int particle_spawn_cooldown = 0; private ArrayList tasks; private Inventory inventory; @@ -285,7 +286,7 @@ public class EntityPlayer extends Entity implements if(is.isEmpty() || !is.item.onPlayerLeftClick(is, Main.world.getLayer(), this, place_pos)) { - boolean isTool = is.item instanceof ItemTool; + boolean isTool = !is.isEmpty() && is.item instanceof ItemTool; ItemTool tool = isTool ? (ItemTool) is.item : null; double speed = isTool ? ((ItemTool) is.item).toolSpeed(is) : 1; Vec2i pos = place_pos.toInt(); @@ -309,6 +310,16 @@ public class EntityPlayer extends Entity implements break_pos = pos; } + particle_spawn_cooldown += 1; + + if(particle_spawn_cooldown > 10) { + particle_spawn_cooldown -= 10; + + layer.spawnEntity(new ParticleBreak( + new Vec3d(pos.x + 0.5, 0, pos.y + 0.5), + new Vec3d(0, 0, 0), ts.tile.getModel(ts.meta), 2)); + } + if(break_progress > ts.tile.hardness) { ItemStack[] stacks = ts.tile.getTileDrops(ts); @@ -431,11 +442,37 @@ public class EntityPlayer extends Entity implements model.render(); ItemStack holding = inventory.getItem(inventory_hand); + Vec2d place_pos = getPos().xz().add(MathHelpers.moveTowards2(0.5, Math.toRadians(angle))); + Vec3d ppos = getPos(); + + { + boolean isTool = !holding.isEmpty() && holding.item instanceof ItemTool; + ItemTool tool = isTool ? (ItemTool) holding.item : null; + Vec2i pos = place_pos.toInt(); + + for(int ti=0;ti<2;ti++) + { + TileState ts; + + if(ti == 0) { + ts = layer.getFrontTile(pos); + } else { + ts = layer.getBackTile(pos); + } + + if(ts.tile.canTileBreak(ts, holding, tool) || ts.tile.canUse(ts)) + { + Models.TILE_BORDER.setModel(Matrix4.translate( + new Vec3d(pos.x + 0.5 - ppos.x, 0, pos.y + 0.5 - ppos.z))); + Models.TILE_BORDER.render(); + + break; + } + } + } if(holding != null && !holding.isEmpty()) { - Vec3d ppos = getPos(); - Model model_place = holding.item.getPlaceModel(holding); Model model_spawn = holding.item.getSpawnModel(holding); Vec2d pos = ppos.xz().add(MathHelpers.moveTowards2(1, Math.toRadians(angle))); @@ -449,13 +486,15 @@ public class EntityPlayer extends Entity implements if(render_place_model) { - model_place.setModel(Matrix4.translate(Math.floor(pos.x) - ppos.x + 0.5, 0.001, Math.floor(pos.y) - ppos.z + 0.5)); + model_place.setModel(Matrix4.translate(new Vec3d( + MathHelpers.floor(pos.x) + 0.5 - ppos.x, 0.00390625, + MathHelpers.floor(pos.y) + 0.5 - ppos.z))); model_place.render(); } if(model_spawn != null) { - model_spawn.setModel(Matrix4.translate(pos.x - ppos.x, 0.001, pos.y - ppos.z)); + model_spawn.setModel(Matrix4.translate(pos.x - ppos.x, 0, pos.y - ppos.z)); model_spawn.render(); } diff --git a/src/projectzombie/init/Models.java b/src/projectzombie/init/Models.java index 0c6cbc8..c93fed9 100755 --- a/src/projectzombie/init/Models.java +++ b/src/projectzombie/init/Models.java @@ -15,6 +15,7 @@ import projectzombie.model.ModelRandom; import projectzombie.model.ModelRock; import projectzombie.model.ModelTallGrass; import projectzombie.model.ModelTile; +import projectzombie.model.ModelTileBorder; import projectzombie.model.ModelTree; import projectzombie.model.ModelTreeSnow; import projectzombie.model.ModelVertical; @@ -24,6 +25,7 @@ public class Models { public static final Model EMPTY = new ModelEmpty(); public static final Model TILE_MISSING = new ModelTile(Resources.TEX_EMPTY); + public static final Model TILE_BORDER = new ModelTileBorder(); public static final Model TILE_TALL_GRASS = new ModelTallGrass(); public static final Model TILE_GRASS = new ModelGrass(); diff --git a/src/projectzombie/init/Tiles.java b/src/projectzombie/init/Tiles.java index 9e33268..b743e5e 100755 --- a/src/projectzombie/init/Tiles.java +++ b/src/projectzombie/init/Tiles.java @@ -37,6 +37,7 @@ import projectzombie.tiles.TileVoid; import projectzombie.tiles.TileWall; import projectzombie.tiles.TileWater; import projectzombie.tiles.TileWoodFloor; +import projectzombie.tiles.TileWoodWall; import projectzombie.tiles.TileWorkbench; public class Tiles @@ -90,6 +91,7 @@ public class Tiles register(ORE); register(COAL); register(WOOD_FLOOR); + register(WOOD_WALL); } public static final Tile GRASS = new TileGrass(); @@ -127,4 +129,5 @@ public class Tiles public static final Tile ORE = new TileOre(); public static final Tile COAL = new TileCoal(); public static final Tile WOOD_FLOOR = new TileWoodFloor(); + public static final Tile WOOD_WALL = new TileWoodWall(); } diff --git a/src/projectzombie/items/ItemWoodWall.java b/src/projectzombie/items/ItemWoodWall.java index 6b7fd1b..5b9ff51 100644 --- a/src/projectzombie/items/ItemWoodWall.java +++ b/src/projectzombie/items/ItemWoodWall.java @@ -1,11 +1,18 @@ package projectzombie.items; import gl_engine.MathHelpers; +import gl_engine.vec.Vec2d; +import gl_engine.vec.Vec2i; import projectzombie.Main; +import projectzombie.entity.player.EntityPlayer; import projectzombie.init.Models; +import projectzombie.init.Tiles; +import projectzombie.items.modifier.ItemModifierMeta; import projectzombie.model.Model; import projectzombie.model.ModelItem; import projectzombie.util.ItemStack; +import projectzombie.util.TileState; +import projectzombie.world.layer.Layer; public class ItemWoodWall extends Item { @@ -21,6 +28,28 @@ public class ItemWoodWall extends Item public ModelItem getModel(ItemStack stack) { return Models.ITEM_WOOD_WALL; } + + @Override + public boolean showPlaceModel(Layer layer, Vec2i pos, ItemStack stack) { + return layer.getFrontTile(pos).tile.isNaturalFloorItem; + } + + @Override + public boolean onPlayerRightClick(ItemStack stack, Layer layer, EntityPlayer player, Vec2d place_pos) + { + Vec2i pos = place_pos.toInt(); + + if(!showPlaceModel(layer, pos, stack)) { + return false; + } + + int angle = (int)MathHelpers.mod(Main.player.angle / 90 + 0.5, 4); + + stack.count -= 1; + layer.setFrontTile(new TileState(Tiles.WOOD_WALL, ItemModifierMeta.getStackMeta(stack) * 4 + angle), pos); + + return true; + } @Override public String getName(ItemStack stack) { diff --git a/src/projectzombie/model/ModelChunkBorder.java b/src/projectzombie/model/ModelChunkBorder.java index 4c64bf7..998a929 100644 --- a/src/projectzombie/model/ModelChunkBorder.java +++ b/src/projectzombie/model/ModelChunkBorder.java @@ -1,7 +1,10 @@ package projectzombie.model; +import org.lwjgl.opengl.GL33; + import gl_engine.texture.TextureRef3D; import gl_engine.vec.Vec2d; +import projectzombie.Main; import projectzombie.init.Resources; public class ModelChunkBorder extends Model @@ -10,61 +13,58 @@ public class ModelChunkBorder extends Model @Override public int getSize() { - return 16; + return 8; } @Override public int getIndexSize() { - return 24; + return 8; + } + + @Override + public void render() + { + if(bound != this) { + bind(); + } + + GL33.glUniform1i(Main.window.glsl_do_texture, 0); + GL33.glDrawElements(GL33.GL_LINES, getIndexSize(), GL33.GL_UNSIGNED_INT, 0); + GL33.glUniform1i(Main.window.glsl_do_texture, 1); } @Override public float[] getVerticies() { float w = 16; - float h = 0.0625f; + float h = 0.03125f; float f = 0b10; float c = 0b000000111111111111; float o = 0.5f; return new float[] { - 0-o, 0, 0-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - w-o, 0, 0-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - w-o, h, 0-o, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - 0-o, h, 0-o, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + 0-o, h, 0-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + w-o, h, 0-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - 0-o, 0, w-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - w-o, 0, w-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - w-o, h, w-o, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - 0-o, h, w-o, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + 0-o, h, w-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + w-o, h, w-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - 0-o, 0, 0-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - 0-o, 0, w-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - 0-o, h, w-o, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - 0-o, h, 0-o, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + 0-o, h, 0-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + 0-o, h, w-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - w-o, 0, 0-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - w-o, 0, w-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - w-o, h, w-o, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, - w-o, h, 0-o, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + w-o, h, 0-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + w-o, h, w-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, }; } @Override public int[] getIndicies() { return new int[] { - 0, 1, 2, - 2, 3, 0, - - 4, 5, 6, - 6, 7, 4, - - 8, 9, 10, - 10, 11, 8, - - 12, 13, 14, - 14, 15, 12, + 0, 1, + 2, 3, + 4, 5, + 6, 7, }; } @@ -74,8 +74,6 @@ public class ModelChunkBorder extends Model return new TextureRef3D[] { ref, ref, ref, ref, ref, ref, ref, ref, - ref, ref, ref, ref, - ref, ref, ref, ref, }; } diff --git a/src/projectzombie/model/ModelTileBorder.java b/src/projectzombie/model/ModelTileBorder.java new file mode 100644 index 0000000..6b39703 --- /dev/null +++ b/src/projectzombie/model/ModelTileBorder.java @@ -0,0 +1,87 @@ +package projectzombie.model; + +import org.lwjgl.opengl.GL33; + +import gl_engine.texture.TextureRef3D; +import projectzombie.Main; +import projectzombie.init.Resources; + +public class ModelTileBorder extends Model +{ + private static final TextureRef3D ref = Resources.ATLAS.get("/gui/pixel_white.png"); + + @Override + public int getSize() { + return 8; + } + + @Override + public int getIndexSize() { + return 8; + } + + @Override + public void render() + { + if(bound != this) { + bind(); + } + + GL33.glUniform1i(Main.window.glsl_do_texture, 0); + GL33.glDrawElements(GL33.GL_LINES, getIndexSize(), GL33.GL_UNSIGNED_INT, 0); + GL33.glUniform1i(Main.window.glsl_do_texture, 1); + } + + @Override + public float[] getVerticies() + { + float h = 0.03125f; + float f = 0b10; + float c = 0b101111101111101111; + float o = 0.5f; + + return new float[] + { + 0-o, h, 0-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + 1-o, h, 0-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + + 0-o, h, 1-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + 1-o, h, 1-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + + 0-o, h, 0-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + 0-o, h, 1-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + + 1-o, h, 0-o, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + 1-o, h, 1-o, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, c, f, + }; + } + + @Override + public int[] getIndicies() { + return new int[] { + 0, 1, + 2, 3, + 4, 5, + 6, 7, + }; + } + + @Override + public TextureRef3D[] getTextures() + { + return new TextureRef3D[] { + ref, ref, ref, ref, + ref, ref, ref, ref, + }; + } + + @Override + public double getHeight() { + return 1; + } + + @Override + public double getWidth() { + return 16; + } +} diff --git a/src/projectzombie/model/ModelWall.java b/src/projectzombie/model/ModelWall.java index 5dbbcf6..66c7c0c 100644 --- a/src/projectzombie/model/ModelWall.java +++ b/src/projectzombie/model/ModelWall.java @@ -48,90 +48,109 @@ public class ModelWall extends Model @Override public float[] getVerticies() { - float x1=0, x2=0, x3=0, x4=0, z1=0, z2=0, z3=0, z4=0; + float x1=0, x2=0, x3=0, x4=0, x5=0, x6=0, z1=0, z2=0, z3=0, z4=0, z5=0, z6=0; switch(rotation) { case 0: - z1 = -0.5f; - z2 = -0.5f; - z3 = -0.25f; - z4 = -0.25f; + z1 = 0.5f; + z2 = 0.25f; x1 = 0.5f; - x2 = 0.5f; - x3 = -0.5f; - x4 = -0.5f; + x2 = -0.5f; break; case 1: - x1 = -0.5f; - x2 = -0.5f; - x3 = -0.25f; - x4 = -0.25f; + x1 = 0.5f; + x2 = 0.25f; z1 = 0.5f; - z2 = 0.5f; - z3 = -0.5f; - z4 = -0.5f; + z2 = -0.5f; break; case 2: - z1 = 0.5f; - z2 = 0.5f; - z3 = 0.25f; - z4 = 0.25f; + z1 = -0.5f; + z2 = -0.25f; x1 = 0.5f; - x2 = 0.5f; - x3 = -0.5f; - x4 = -0.5f; + x2 = -0.5f; break; case 3: - x1 = 0.5f; - x2 = 0.5f; - x3 = 0.25f; - x4 = 0.25f; + x1 = -0.5f; + x2 = -0.25f; z1 = 0.5f; - z2 = 0.5f; - z3 = -0.5f; - z4 = -0.5f; + z2 = -0.5f; break; } + if(rotation % 2 == 0) { + x3 = x1; + x4 = x2; + x5 = x2; + x6 = x1; + z3 = z1; + z4 = z1; + z5 = z2; + z6 = z2; + } + + else { + x3 = x1; + x4 = x1; + x5 = x2; + x6 = x2; + z3 = z1; + z4 = z2; + z5 = z2; + z6 = z1; + } + return new float[] { x1, 0, z1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x2, 0, z3, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x2, 1, z3, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x1, 0, z2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x1, 1, z2, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x1, 1, z1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x3, 0, z1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x4, 0, z3, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x4, 1, z3, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x3, 1, z1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x2, 0, z1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x2, 0, z2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x2, 1, z2, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x2, 1, z1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x1, 0, z1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x3, 0, z2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x3, 1, z2, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x2, 0, z1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x2, 1, z1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, x1, 1, z1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x1, 0, z3, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x3, 0, z4, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x3, 1, z4, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x1, 1, z3, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x1, 0, z2, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x2, 0, z2, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x2, 1, z2, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x1, 1, z2, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x1, 1, z1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x3, 1, z1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x3, 1, z3, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, - x1, 1, z3, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x3, 1, z3, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x4, 1, z4, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x5, 1, z5, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, + x6, 1, z6, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, }; } @Override - public TextureRef3D[] getTextures() { - return new TextureRef3D[] { - front, front, front, front, - front, front, front, front, - side, side, side, side, - side, side, side, side, - top, top, top, top, - }; + public TextureRef3D[] getTextures() + { + if(rotation % 2 == 0) { + return new TextureRef3D[] { + side, side, side, side, + side, side, side, side, + front, front, front, front, + front, front, front, front, + top, top, top, top, + }; + } + + else { + return new TextureRef3D[] { + front, front, front, front, + front, front, front, front, + side, side, side, side, + side, side, side, side, + top, top, top, top, + }; + } } @Override diff --git a/src/projectzombie/tiles/Tile.java b/src/projectzombie/tiles/Tile.java index c6d2121..1340825 100755 --- a/src/projectzombie/tiles/Tile.java +++ b/src/projectzombie/tiles/Tile.java @@ -1,5 +1,6 @@ package projectzombie.tiles; +import gl_engine.vec.Vec2d; import gl_engine.vec.Vec2i; import projectzombie.entity.Entity; import projectzombie.items.ItemTool; @@ -23,6 +24,17 @@ public abstract class Tile public boolean isNaturalFloorItem = false; public int hardness = -1; + public boolean inHitbox(TileState state, Vec2d pos) { + return (pos.x > 0.5 - tileHitbox && + pos.x < 0.5 + tileHitbox && + pos.y > 0.5 - tileHitbox && + pos.y < 0.5 + tileHitbox); + } + + public boolean canUse(TileState state) { + return false; + } + public void onWalkedOn(Chunk chunk, Layer layer, Vec2i pos, Entity entity, TileState state) { } diff --git a/src/projectzombie/tiles/TileAbstractWall.java b/src/projectzombie/tiles/TileAbstractWall.java new file mode 100644 index 0000000..9100ee1 --- /dev/null +++ b/src/projectzombie/tiles/TileAbstractWall.java @@ -0,0 +1,25 @@ +package projectzombie.tiles; + +import gl_engine.vec.Vec2d; +import projectzombie.util.TileState; + +public abstract class TileAbstractWall extends Tile +{ + public TileAbstractWall() { + tileSolid = true; + } + + @Override + public boolean inHitbox(TileState state, Vec2d pos) + { + switch(state.meta % 4) + { + case 0: return pos.x > -0.125 && pos.x < 1.125 && pos.y > 0.5 && pos.y < 1.125; + case 1: return pos.y > -0.125 && pos.y < 1.125 && pos.x > 0.5 && pos.x < 1.125; + case 2: return pos.x > -0.125 && pos.x < 1.125 && pos.y > -0.125 && pos.y < 0.5; + case 3: return pos.y > -0.125 && pos.y < 1.125 && pos.x > -0.125 && pos.x < 0.5; + } + + return false; + } +} diff --git a/src/projectzombie/tiles/TileBlastFurnace.java b/src/projectzombie/tiles/TileBlastFurnace.java index 788a76f..ce69f9f 100644 --- a/src/projectzombie/tiles/TileBlastFurnace.java +++ b/src/projectzombie/tiles/TileBlastFurnace.java @@ -38,6 +38,11 @@ public class TileBlastFurnace extends Tile return Models.TILE_BLAST_FURNACE; } + @Override + public boolean canUse(TileState state) { + return true; + } + @Override public boolean onActivated(Layer layer, Vec2i tpos, Entity entity, TileState state) { super.onActivated(layer, tpos, entity, state); diff --git a/src/projectzombie/tiles/TileBossPortal.java b/src/projectzombie/tiles/TileBossPortal.java index 2eccba8..554fb5f 100755 --- a/src/projectzombie/tiles/TileBossPortal.java +++ b/src/projectzombie/tiles/TileBossPortal.java @@ -30,6 +30,11 @@ public class TileBossPortal extends Tile this.unbreakable = true; } + @Override + public boolean canUse(TileState state) { + return true; + } + @Override public double getLightLevel(TileState state, Vec2i pos) { return 0.6; diff --git a/src/projectzombie/tiles/TileCampfire.java b/src/projectzombie/tiles/TileCampfire.java index a26f382..024c092 100644 --- a/src/projectzombie/tiles/TileCampfire.java +++ b/src/projectzombie/tiles/TileCampfire.java @@ -27,6 +27,11 @@ public class TileCampfire extends Tile this.hardness = 800; } + @Override + public boolean canUse(TileState state) { + return true; + } + @Override public double getLightLevel(TileState state, Vec2i pos) { return 1 - MathHelpers.squared(1 - state.meta / 16.0); diff --git a/src/projectzombie/tiles/TileChest.java b/src/projectzombie/tiles/TileChest.java index 78294fe..673b386 100755 --- a/src/projectzombie/tiles/TileChest.java +++ b/src/projectzombie/tiles/TileChest.java @@ -29,6 +29,11 @@ public class TileChest extends Tile implements TileBulletBreakable } + @Override + public boolean canUse(TileState state) { + return true; + } + private void spawnItem(Chunk chunk, Vec2i pos, ItemStack stack) { chunk.spawnEntity(new EntityItem(pos.xny().toDouble(), new Vec3d(0, 0, 0), stack)); } diff --git a/src/projectzombie/tiles/TileClayPot.java b/src/projectzombie/tiles/TileClayPot.java index cd82530..0f80a5c 100644 --- a/src/projectzombie/tiles/TileClayPot.java +++ b/src/projectzombie/tiles/TileClayPot.java @@ -27,6 +27,11 @@ public class TileClayPot extends Tile hardness = 100; } + @Override + public boolean canUse(TileState state) { + return true; + } + @Override public Model getModel(byte meta) { diff --git a/src/projectzombie/tiles/TileHemp.java b/src/projectzombie/tiles/TileHemp.java index 91b4369..b9d063a 100644 --- a/src/projectzombie/tiles/TileHemp.java +++ b/src/projectzombie/tiles/TileHemp.java @@ -20,6 +20,11 @@ public class TileHemp extends Tile this.hardness = 5000; } + @Override + public boolean canUse(TileState state) { + return state.meta > 3; + } + @Override public void tickRandomly(Layer layer, Chunk chunk, TileState state, Vec2i pos) { super.tickRandomly(layer, chunk, state, pos); diff --git a/src/projectzombie/tiles/TileLadderUp.java b/src/projectzombie/tiles/TileLadderUp.java index 8bbd426..5c9a187 100755 --- a/src/projectzombie/tiles/TileLadderUp.java +++ b/src/projectzombie/tiles/TileLadderUp.java @@ -19,6 +19,11 @@ public class TileLadderUp extends Tile this.unbreakable = true; } + @Override + public boolean canUse(TileState state) { + return true; + } + @Override public boolean onActivated(Layer layer, Vec2i pos, Entity entity, TileState state) { diff --git a/src/projectzombie/tiles/TilePortalDown.java b/src/projectzombie/tiles/TilePortalDown.java index 7e1c51c..9233838 100755 --- a/src/projectzombie/tiles/TilePortalDown.java +++ b/src/projectzombie/tiles/TilePortalDown.java @@ -18,6 +18,11 @@ public class TilePortalDown extends Tile this.unbreakable = true; } + @Override + public boolean canUse(TileState state) { + return true; + } + @Override public boolean onActivated(Layer layer, Vec2i pos, Entity entity, TileState state) { diff --git a/src/projectzombie/tiles/TileWater.java b/src/projectzombie/tiles/TileWater.java index 7130f97..629eea7 100755 --- a/src/projectzombie/tiles/TileWater.java +++ b/src/projectzombie/tiles/TileWater.java @@ -22,7 +22,11 @@ public class TileWater extends Tile this.slowness = 0.5; this.unbreakable = true; this.hardness = 800; - this.isNaturalFloorItem = true; + } + + @Override + public boolean canUse(TileState state) { + return true; } @Override diff --git a/src/projectzombie/tiles/TileWoodWall.java b/src/projectzombie/tiles/TileWoodWall.java index 93d0113..ce08b5c 100644 --- a/src/projectzombie/tiles/TileWoodWall.java +++ b/src/projectzombie/tiles/TileWoodWall.java @@ -9,17 +9,17 @@ import projectzombie.model.Model; import projectzombie.util.ItemStack; import projectzombie.util.TileState; -public class TileWoodWall extends Tile +public class TileWoodWall extends TileAbstractWall { public TileWoodWall() { - tileSolid = true; - + light_dissipation = 0.5; + hardness = 800; } @Override public boolean canTileBreak(TileState state, ItemStack stack, ItemTool tool) { - return tool.toolType(stack) == ItemToolType.HATCHET; + return tool != null && tool.toolType(stack) == ItemToolType.HATCHET; } @Override diff --git a/src/projectzombie/tiles/TileWorkbench.java b/src/projectzombie/tiles/TileWorkbench.java index d5b99a3..8b2a22b 100644 --- a/src/projectzombie/tiles/TileWorkbench.java +++ b/src/projectzombie/tiles/TileWorkbench.java @@ -20,6 +20,11 @@ public class TileWorkbench extends Tile tileHitbox = 0.4; hardness = 200; } + + @Override + public boolean canUse(TileState state) { + return true; + } @Override public Model getModel(byte meta) { diff --git a/src/resources/shader/environmentRenderer.fsh b/src/resources/shader/environmentRenderer.fsh index 3b23fed..2ecd565 100644 --- a/src/resources/shader/environmentRenderer.fsh +++ b/src/resources/shader/environmentRenderer.fsh @@ -25,6 +25,7 @@ uniform vec2 lightmap_size; uniform int do_lighting; uniform int do_discard_coords; +uniform int do_texture; uniform vec4 discard_coords; uniform vec4 color; @@ -70,7 +71,7 @@ vec3 interpolate2RGB(float x, float y, vec3 v00, vec3 v01, vec3 v10, vec3 v11) { void main() { - vec4 textureRGB = texture(atlas, pTexture); + vec4 textureRGB = do_texture == 0 ? vec4(1) : texture(atlas, pTexture); if(mode == 0) { diff --git a/src/resources/texture/tile/wood_door_front.png b/src/resources/texture/tile/wood_door_front.png new file mode 100644 index 0000000..d2204ae Binary files /dev/null and b/src/resources/texture/tile/wood_door_front.png differ diff --git a/src/resources/texture/tile/wood_door_top.png b/src/resources/texture/tile/wood_door_top.png new file mode 100644 index 0000000..832d975 Binary files /dev/null and b/src/resources/texture/tile/wood_door_top.png differ diff --git a/src/resources/texture/tile/wood_snow_door_front.png b/src/resources/texture/tile/wood_snow_door_front.png new file mode 100644 index 0000000..36b6704 Binary files /dev/null and b/src/resources/texture/tile/wood_snow_door_front.png differ diff --git a/src/resources/texture/tile/wood_snow_door_top.png b/src/resources/texture/tile/wood_snow_door_top.png new file mode 100644 index 0000000..a4df6d8 Binary files /dev/null and b/src/resources/texture/tile/wood_snow_door_top.png differ diff --git a/src/resources/texture/tile/wood_snow_wall_front.png b/src/resources/texture/tile/wood_snow_wall_front.png index d5087fb..2584160 100644 Binary files a/src/resources/texture/tile/wood_snow_wall_front.png and b/src/resources/texture/tile/wood_snow_wall_front.png differ diff --git a/src/resources/texture/tile/wood_snow_wall_top.png b/src/resources/texture/tile/wood_snow_wall_top.png index c56199f..cd310c6 100644 Binary files a/src/resources/texture/tile/wood_snow_wall_top.png and b/src/resources/texture/tile/wood_snow_wall_top.png differ