Skip to content

Commit

Permalink
Remove all the commented java code.
Browse files Browse the repository at this point in the history
Most of it is already implemented elsewhere or no longer applicable and would need to be rewritten from scratch.
closes #129
  • Loading branch information
IntegratedQuantum committed Apr 20, 2024
1 parent c9f9dbf commit e2459d1
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 1,143 deletions.
13 changes: 0 additions & 13 deletions src/assets.zig
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,3 @@ pub fn deinit() void {
biomes_zig.deinit();
blocks_zig.deinit();
}

//TODO:
// private void registerBlock(int block, Resource id, JsonObject json, Registry<DataOrientedRegistry> registries, NoIDRegistry<Ore> oreRegistry) {
// // block entities:
// if (json.has("blockEntity")) {
// try {
// Blocks.setBlockEntity(block, Class.forName(json.getString("blockEntity", "")).asSubclass(BlockEntity.class));
// } catch (ClassNotFoundException e) {
// Logger.error(e);
// }
// }
// }
//}
47 changes: 0 additions & 47 deletions src/blocks.zig
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,6 @@ pub const Block = packed struct {
pub inline fn mode(self: Block) *RotationMode {
return _mode[self.typ];
}

// TODO:
// /**
// * Fires the blocks on click event(usually nothing or GUI opening).
// * @param world
// * @param pos
// * @return if the block did something on click.
// */
// public static boolean onClick(int block, World world, Vector3i pos) {
// if (gui[block & TYPE_MASK] != null) {
// GameLauncher.logic.openGUI("cubyz:workbench", new Inventory(26)); // TODO: Care about the inventory.
// return true;
// }
// return false;
// }
};


Expand Down Expand Up @@ -554,38 +539,6 @@ pub const meshes = struct {
meshes.size += 1;
}

// TODO: (this one requires thinking about the allocated memory!)
// public static void reloadTextures() {
// for(int i = 0; i < blockTextures.size(); i++) {
// try {
// blockTextures.set(i, ImageIO.read(new File(textureIDs.get(i).replace(":animation", ""))));
// } catch(IOException e) {
// Logger.warning("Could not read image from path "+textureIDs.get(i));
// Logger.warning(e);
// blockTextures.set(i, blockTextures.get(0));
// }
// }
// generateTextureArray();
// }


// TODO:
// public static void loadMeshes() {
// // Goes through all meshes that were newly added:
// for(; loadedMeshes < size; loadedMeshes++) {
// if (meshes[loadedMeshes] == null) {
// meshes[loadedMeshes] = Meshes.cachedDefaultModels.get(models[loadedMeshes]);
// if (meshes[loadedMeshes] == null) {
// if(models[loadedMeshes].isEmpty())
// continue;
// Resource rs = new Resource(models[loadedMeshes]);
// meshes[loadedMeshes] = new Mesh(ModelLoader.loadModel(rs, "assets/" + rs.getMod() + "/models/3d/" + rs.getID()));
// Meshes.cachedDefaultModels.put(models[loadedMeshes], meshes[loadedMeshes]);
// }
// }
// }
// }

pub fn preProcessAnimationData(time: u32) void {
animationShader.bind();
graphics.c.glUniform1ui(animationUniforms.time, time);
Expand Down
24 changes: 1 addition & 23 deletions src/chunk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -298,28 +298,6 @@ pub const Chunk = struct {
return self.data.getValue(index);
}

pub fn getNeighbors(self: *const Chunk, x: i32, y: i32, z: i32, neighborsArray: *[6]Block) void {
x &= chunkMask;
y &= chunkMask;
z &= chunkMask;
for(Neighbors.relX, 0..) |_, i| {
const xi = x + Neighbors.relX[i];
const yi = y + Neighbors.relY[i];
const zi = z + Neighbors.relZ[i];
if (xi == (xi & chunkMask) and yi == (yi & chunkMask) and zi == (zi & chunkMask)) { // Simple double-bound test for coordinates.
neighborsArray[i] = self.getBlock(xi, yi, zi);
} else {
// TODO: What about other chunks?
// NormalChunk ch = world.getChunk(xi + wx, yi + wy, zi + wz);
// if (ch != null) {
// neighborsArray[i] = ch.getBlock(xi & chunkMask, yi & chunkMask, zi & chunkMask);
// } else {
// neighborsArray[i] = 1; // Some solid replacement, in case the chunk isn't loaded. TODO: Properly choose a solid block.
// }
}
}
}

pub fn updateFromLowerResolution(self: *Chunk, other: *const Chunk) void {
const xOffset = if(other.wx != self.wx) chunkSize/2 else 0; // Offsets of the lower resolution chunk in this chunk.
const yOffset = if(other.wy != self.wy) chunkSize/2 else 0;
Expand Down Expand Up @@ -388,7 +366,7 @@ pub const Chunk = struct {
self.mutex.lock();
defer self.mutex.unlock();
if(self.wasChanged) {
// TODO: ChunkIO.storeChunkToFile(world, this);
// TODO: Actually store the chunk
self.wasChanged = false;
// Update the next lod chunk:
if(self.pos.voxelSize != 1 << settings.highestLOD) {
Expand Down
4 changes: 0 additions & 4 deletions src/entity.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pub const ClientEntity = struct {

width: f64,
height: f64,
// TODO:
// public final EntityType type;

pos: Vec3d = undefined,
rot: Vec3f = undefined,
Expand All @@ -35,8 +33,6 @@ pub const ClientEntity = struct {
pub fn init(self: *ClientEntity, json: JsonElement, allocator: NeverFailingAllocator) void {
self.* = ClientEntity{
.id = json.get(u32, "id", std.math.maxInt(u32)),
// TODO:
// CubyzRegistries.ENTITY_REGISTRY.getByID(json.getString("type", null)),
.width = json.get(f64, "width", 1),
.height = json.get(f64, "height", 1),
.name = allocator.dupe(u8, json.get([]const u8, "name", "")),
Expand Down
14 changes: 0 additions & 14 deletions src/game.zig
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ pub const World = struct {
blockPalette: *assets.BlockPalette = undefined,
itemDrops: ClientItemDropManager = undefined,
playerBiome: Atomic(*const main.server.terrain.biomes.Biome) = undefined,

// public final ArrayList<String> chatHistory = new ArrayList<>();

pub fn init(self: *World, ip: []const u8, manager: *ConnectionManager) !void {
self.* = .{
Expand All @@ -117,8 +115,6 @@ pub const World = struct {
};
self.itemDrops.init(main.globalAllocator, self);
Player.inventory__SEND_CHANGES_TO_SERVER = Inventory.init(main.globalAllocator, 32);
// TODO:
// player = new ClientPlayer(this, 0);
network.Protocols.handShake.clientSide(self.conn, settings.playerName);

main.Window.setMouseGrabbed(true);
Expand Down Expand Up @@ -153,16 +149,6 @@ pub const World = struct {
self.spawn[1] = jsonSpawn.get(f32, "y", 0);
self.spawn[2] = jsonSpawn.get(f32, "z", 0);

// TODO:
// if(Server.world != null) {
// // Share the registries of the local server:
// registries = Server.world.getCurrentRegistries();
// } else {
// registries = new CurrentWorldRegistries(this, "serverAssets/", blockPalette);
// }
//
// // Call mods for this new world. Mods sometimes need to do extra stuff for the specific world.
// ModLoader.postWorldGen(registries);
try assets.loadWorldAssets("serverAssets", self.blockPalette);
Player.loadFrom(json.getChild("player"));
Player.id = json.get(u32, "player_id", std.math.maxInt(u32));
Expand Down
61 changes: 2 additions & 59 deletions src/itemdrop.zig
Original file line number Diff line number Diff line change
Expand Up @@ -196,38 +196,6 @@ pub const ItemDropManager = struct {
}
}

//TODO:
// public void checkEntity(Entity ent) {
// for(int ii = 0; ii < size; ii++) {
// int i = indices[ii] & 0xffff;
// int i3 = 3*i;
// if (pickupCooldown[i] >= 0) continue; // Item cannot be picked up yet.
// if (Math.abs(ent.position.x - posxyz[i3]) < ent.width + PICKUP_RANGE && Math.abs(ent.position.y + ent.height/2 - posxyz[i3 + 1]) < ent.height + PICKUP_RANGE && Math.abs(ent.position.z - posxyz[i3 + 2]) < ent.width + PICKUP_RANGE) {
// if(ent.getInventory().canCollect(itemStacks[i].getItem())) {
// if(ent instanceof Player) {
// // Needs to go through the network.
// for(User user : Server.users) {
// if(user.player == ent) {
// Protocols.GENERIC_UPDATE.itemStackCollect(user, itemStacks[i]);
// remove(i);
// ii--;
// break;
// }
// }
// } else {
// int newAmount = ent.getInventory().addItem(itemStacks[i].getItem(), itemStacks[i].getAmount());
// if(newAmount != 0) {
// itemStacks[i].setAmount(newAmount);
// } else {
// remove(i);
// ii--;
// }
// }
// }
// }
// }
// }

pub fn addFromBlockPosition(self: *ItemDropManager, blockPos: Vec3i, vel: Vec3d, itemStack: ItemStack, despawnTime: i32) void {
self.add(
vec.floatFromInt(f64, blockPos) + Vec3d { // TODO: Consider block bounding boxes.
Expand Down Expand Up @@ -325,16 +293,6 @@ pub const ItemDropManager = struct {
// lastUpdates.add(new JsonInt(i));
// }
}
// TODO: Check if/how this is needed:
// public Vector3d getPosition(int index) {
// index *= 3;
// return new Vector3d(posxyz[index], posxyz[index+1], posxyz[index+2]);
// }
//
// public Vector3f getRotation(int index) {
// index *= 3;
// return new Vector3f(rotxyz[index], rotxyz[index+1], rotxyz[index+2]);
// }

fn updateEnt(self: *ItemDropManager, chunk: *Chunk, pos: *Vec3d, vel: *Vec3d, deltaTime: f64) void {
main.utils.assertLocked(&self.mutex);
Expand Down Expand Up @@ -432,21 +390,12 @@ pub const ItemDropManager = struct {
}

fn checkBlock(self: *ItemDropManager, chunk: *Chunk, pos: *Vec3d, blockPos: Vec3i) bool {
// TODO:
// TODO: Check if the item drop collides with the block in the given location.
_ = self;
_ = chunk;
_ = pos;
_ = blockPos;
return false;
// // Transform to chunk-relative coordinates:
// int block = chunk.getBlockPossiblyOutside(x - chunk.wx, y - chunk.wy, z - chunk.wz);
// if (block == 0) return false;
// // Check if the item entity is inside the block:
// boolean isInside = true;
// if (Blocks.mode(block).changesHitbox()) {
// isInside = Blocks.mode(block).checkEntity(new Vector3d(posxyz[index3], posxyz[index3+1]-RADIUS, posxyz[index3+2]), RADIUS, DIAMETER, x, y, z, block);
// }
// return isInside && Blocks.solid(block);
}
};

Expand Down Expand Up @@ -740,13 +689,7 @@ pub const ItemDropRenderer = struct {
if(itemDrops.list.items(.itemStack)[i].item) |item| {
var pos = itemDrops.list.items(.pos)[i];
const rot = itemDrops.list.items(.rot)[i];
// TODO: lighting:
// int x = (int)(manager.posxyz[index3] + 1.0f);
// int y = (int)(manager.posxyz[index3+1] + 1.0f);
// int z = (int)(manager.posxyz[index3+2] + 1.0f);
//
// int light = Cubyz.world.getLight(x, y, z, ambientLight, ClientSettings.easyLighting);
const light: u32 = 0xffffffff;
const light: u32 = 0xffffffff; // TODO: Get this light value from the mesh_storage.
c.glUniform3fv(itemUniforms.ambientLight, 1, @ptrCast(&@max(
ambientLight*@as(Vec3f, @splat(@as(f32, @floatFromInt(light >> 24))/255)),
Vec3f{light >> 16 & 255, light >> 8 & 255, light & 255}/@as(Vec3f, @splat(255))
Expand Down
37 changes: 0 additions & 37 deletions src/items.zig
Original file line number Diff line number Diff line change
Expand Up @@ -141,43 +141,6 @@ pub const BaseItem = struct {
fn getTooltip(self: BaseItem) []const u8 {
return self.name;
}
// TODO: Check if/how this is needed:
// protected Item(int stackSize) {
// id = Resource.EMPTY;
// this.stackSize = stackSize;
// material = null;
// }
//
// public void update() {}
//
// /**
// * Returns true if this item should be consumed on use. May be accessed by non-player entities.
// * @param user
// * @return whether this item is consumed upon use.
// */
// public boolean onUse(Entity user) {
// return false;
// }
// From Consumable.java:
// @Override
// public boolean onUse(Entity user) {
// if((user.hunger >= user.maxHunger - Math.min(user.maxHunger*0.1, 0.5) && foodValue > 0) || (user.hunger == 0 && foodValue < 0)) return false;
// user.hunger = Math.min(user.maxHunger, user.hunger+foodValue);
// return true;
// }
// public static Item load(JsonObject json, CurrentWorldRegistries registries) {
// Item item = registries.itemRegistry.getByID(json.getString("item", "null"));
// if(item == null) {
// // Check if it is a tool:
// JsonObject tool = json.getObject("tool");
// if(tool != null) {
// item = new Tool(tool, registries);
// } else {
// // item not existant in this version of the game. Can't do much so ignore it.
// }
// }
// return item;
// }
};

///Generates the texture of a Tool using the material information.
Expand Down
Loading

0 comments on commit e2459d1

Please sign in to comment.