diff --git a/BlockGame.sln.DotSettings.user b/BlockGame.sln.DotSettings.user index 9adafb5..0b11aba 100644 --- a/BlockGame.sln.DotSettings.user +++ b/BlockGame.sln.DotSettings.user @@ -34,6 +34,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/src/util/BlockModel.cs b/src/util/BlockModel.cs index 2bc40fa..b13e63e 100644 --- a/src/util/BlockModel.cs +++ b/src/util/BlockModel.cs @@ -156,6 +156,31 @@ public static BlockModel makePartialCube(UVPair[] uvs) { return model; } + //makeTorch + public static BlockModel makeTorch(UVPair[] uvs) { + var model = new BlockModel(); + model.faces = new Face[5]; + // west + model.faces[0] = new(7/16f, 0.5f, 9/16f, 7/16f, 0, 9/16f, 7/16f, 0, 7/16f, 7/16f, 0.5f, 7/16f, uvs[0]+new UVPair(1/16f,0.5f), uvs[0] + new UVPair(3/16f, 1f), RawDirection.WEST, true, true); + // east + model.faces[1] = new(9/16f, 0.5f, 7/16f, 9/16f, 0, 7/16f, 9/16f, 0, 9/16f, 9/16f, 0.5f, 9/16f, uvs[0]+new UVPair(1/16f,0.5f), uvs[0] + new UVPair(3/16f, 1f), RawDirection.EAST, true, true); + // south + model.faces[2] = new(7/16f, 0.5f, 7/16f, 7/16f, 0, 7/16f, 9/16f, 0, 7/16f, 9/16f, 0.5f, 7/16f, uvs[0]+new UVPair(1/16f,0.5f), uvs[0] + new UVPair(3/16f, 1f), RawDirection.SOUTH, true, true); + // north + model.faces[3] = new(9/16f, 0.5f, 9/16f, 9/16f, 0, 9/16f, 7/16f, 0, 9/16f, 7/16f, 0.5f, 9/16f, uvs[0]+new UVPair(1/16f,0.5f), uvs[0] + new UVPair(3/16f, 1f), RawDirection.NORTH, true, true); + // up + model.faces[4] = new(7/16f, 0.5f, 9/16f, 7/16f, 0.5f, 7/16f, 9/16f, 0.5f, 7/16f, 9/16f, 0.5f, 9/16f, uvs[5], uvs[5]+new UVPair(2/16f,2/16f), RawDirection.UP, true, true); + // down + //model.faces[5] = new(8+offset1/2f, 0, 10/16f, 8+offset1/2f, 0, 10/16f, 8-offset1/2f, 0, 10/16f, 8-offset1/2f, 0, 10/16f, uvs[4], uvs[4]+new UVPair(offset1, offset1), RawDirection.DOWN, true, true); + + //model.faces[6] = new(0+offset1, 1, 1-offset1, 0+offset1, 1-offset, 1-offset1, 0+offset1, 1-offset, 0+offset1, 0+offset1, 1, 0+offset1, uvs[2] + new UVPair(offset1,0), uvs[2]+new UVPair(1-offset1, offset) , RawDirection.WEST, true, true); + //model.faces[7] = new(1-offset1, 1, 0+offset1, 1-offset1, 1-offset, 0+offset1, 1-offset1, 1-offset, 1-offset1, 1-offset1, 1, 1-offset1, uvs[2] + new UVPair(offset1,0), uvs[2]+new UVPair(1-offset1, offset), RawDirection.EAST, true, true); + //model.faces[8] = new(0+offset1, 1, 0+offset1, 0+offset1, 1-offset, 0+offset1, 1-offset1, 1-offset, 0+offset1, 1-offset1, 1, 0+offset1, uvs[2] + new UVPair(offset1,0), uvs[2]+new UVPair(1-offset1, offset), RawDirection.SOUTH, true, true); + //model.faces[9] = new(1-offset1, 1, 1-offset1, 1-offset1, 1-offset, 1-offset1, 0+offset1, 1-offset, 1-offset1, 0+offset1, 1, 1-offset1, uvs[2] + new UVPair(offset1,0), uvs[2]+new UVPair(1-offset1, offset), RawDirection.NORTH, true, true); + //model.faces[10] = new(0+offset1, 1, 1-offset1, 0+offset1, 1, 0+offset1, 1-offset1, 1, 0+offset1, 1-offset1, 1, 1-offset1, uvs[4] + new UVPair(offset1,offset1), uvs[4]+new UVPair(1-offset1, 1-offset1), RawDirection.UP, true, true); + return model; + } + public static BlockModel emptyBlock() { var model = new BlockModel(); model.faces = []; diff --git a/src/util/Blocks.cs b/src/util/Blocks.cs index 7521231..b00a483 100644 --- a/src/util/Blocks.cs +++ b/src/util/Blocks.cs @@ -19,7 +19,7 @@ public class Blocks { public static bool[] translucentCache = new bool[MAXBLOCKS]; public static bool[] inventoryBlacklist = new bool[MAXBLOCKS]; - public static readonly int maxBlock = 44; + public static readonly int maxBlock = 45; public static Block register(Block block) { return blocks[block.id] = block; @@ -64,11 +64,10 @@ public static bool isBlacklisted(int block) { public static Block HELLSTONE = register(new Block(7, "Hellstone", BlockModel.makeCube(Block.grassUVs(8, 0, 9, 0, 9, 0))).light(15)); public static Block GLASS = register(new Block(8, "Glass", BlockModel.makeCube(Block.cubeUVs(6, 0))).transparency()); - public static Block LANTERN = register(new Block(9, "Lantern", BlockModel.makePartialCube(Block.grassUVs(15, 1, 13, 1, 14, 1))).light(15).partialBlock()); + public static Block LANTERN = register(new Block(9, "Lantern", BlockModel.makePartialCube(Block.grassUVs(15, 1, 13, 1, 14, 1))).light(14).partialBlock()); public static Block TALL_GRASS = register(new Flower(43, "Tall Grass", BlockModel.makeGrass(Block.crossUVs(9,1)))).transparency().noCollision(); public static Block SHORT_GRASS = register(new Flower(44, "Short Grass", BlockModel.makeGrass(Block.crossUVs(8,1)))).transparency().shortGrassAABB().noCollision(); - public static Block YELLOW_FLOWER = register(new Flower(10, "Yellow Flower", BlockModel.makeGrass(Block.crossUVs(10,1))).transparency().flowerAABB().noCollision()); public static Block RED_FLOWER = register(new Flower(11, "Red Flower", BlockModel.makeGrass(Block.crossUVs(11,1))).transparency().flowerAABB().noCollision()); @@ -111,6 +110,8 @@ public static bool isBlacklisted(int block) { public static Block AMBER_ORE = register(new Block(41, "Amber Ore", BlockModel.makeCube(Block.cubeUVs(12, 0)))); public static Block VIOLET_ORE = register(new Block(42, "Violet Ore", BlockModel.makeCube(Block.cubeUVs(13, 0)))); + public static Block TORCH = register(new Block(45, "Torch", BlockModel.makeTorch(Block.grassUVs(4, 1,1, 1, 4,1))).partialBlock().torchAABB()); + public static bool isSolid(int block) { return block != 0 && get(block).type == BlockType.SOLID; } @@ -291,6 +292,13 @@ public Block shortGrassAABB() { return this; } + public Block torchAABB() { + var offset = 6 / 16f; + selectionAABB = new AABB(new Vector3D(0 + offset, 0, 0 + offset), new Vector3D(1 - offset, 1, 1 - offset)); + noCollision(); + return this; + } + public Block(ushort id, string name, BlockModel model) { this.id = id; this.name = name; diff --git a/textures/blocks.png b/textures/blocks.png index c56e832..7920189 100644 Binary files a/textures/blocks.png and b/textures/blocks.png differ