Skip to content

Commit

Permalink
torch partially created
Browse files Browse the repository at this point in the history
  • Loading branch information
kismama committed Oct 1, 2024
1 parent 22da56c commit f38485d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions BlockGame.sln.DotSettings.user
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIInputDevice_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fea488c63231b42228efc7f0ed3b60217a1a0_003F83_003F2a398bb0_003FIInputDevice_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIKeyboard_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fea488c63231b42228efc7f0ed3b60217a1a0_003F15_003F3951e5ce_003FIKeyboard_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AImage_007BTPixel_007D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F98f0ece83ba33754ab932bd7b5c712d12f3a59029f9f14067f553a3a318c8f_003FImage_007BTPixel_007D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIndexOutOfRangeException_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fc7987f728178830c643e38a45e9c2d78378d769c8c34db12b928ef20c2369e_003FIndexOutOfRangeException_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AINumberBase_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F831d8675b7b5e822cad9ec86854c991a31b973d5394bc5caf35715bd68beeb_003FINumberBase_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AINumberBase_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F02e78f8104194b35842ed42446db13c0b2c800_003Ff2_003F7762ecef_003FINumberBase_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIsConst_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F050dd946ea7c4c8286a2e7b21d5e8d0ad19600_003Fa2_003F52606423_003FIsConst_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
Expand Down
25 changes: 25 additions & 0 deletions src/util/BlockModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
14 changes: 11 additions & 3 deletions src/util/Blocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
Binary file modified textures/blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f38485d

Please sign in to comment.