diff --git a/src/main/java/de/bixilon/minosoft/render/GameWindow.java b/src/main/java/de/bixilon/minosoft/render/GameWindow.java index dc67bed52..5e4391447 100644 --- a/src/main/java/de/bixilon/minosoft/render/GameWindow.java +++ b/src/main/java/de/bixilon/minosoft/render/GameWindow.java @@ -30,7 +30,7 @@ public class GameWindow { private static Connection connection; private static PlayerController playerController; - static boolean running = false; + private static boolean running = false; public static boolean paused = false; public static void prepare() { diff --git a/src/main/java/de/bixilon/minosoft/render/OpenGLWindow.java b/src/main/java/de/bixilon/minosoft/render/OpenGLWindow.java index bc36bbb10..027a0ad92 100644 --- a/src/main/java/de/bixilon/minosoft/render/OpenGLWindow.java +++ b/src/main/java/de/bixilon/minosoft/render/OpenGLWindow.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -28,7 +28,7 @@ import static org.lwjgl.system.MemoryUtil.NULL; public class OpenGLWindow { private final boolean fullscreen; - long window; + private long window; private int width, height; private double mouseX; private double mouseY; diff --git a/src/main/java/de/bixilon/minosoft/render/WorldRenderer.java b/src/main/java/de/bixilon/minosoft/render/WorldRenderer.java index ccef97626..5e93a3494 100644 --- a/src/main/java/de/bixilon/minosoft/render/WorldRenderer.java +++ b/src/main/java/de/bixilon/minosoft/render/WorldRenderer.java @@ -32,7 +32,7 @@ public class WorldRenderer { private BlockModelLoader modelLoader; private LinkedBlockingQueue> queuedChunks; - Thread chunkLoadThread; + private Thread chunkLoadThread; public WorldRenderer() { faces = new HashMap<>(); diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/BlockConfiguration.java b/src/main/java/de/bixilon/minosoft/render/blockModels/BlockConfiguration.java index 553043827..2aeb386ea 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/BlockConfiguration.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/BlockConfiguration.java @@ -23,9 +23,8 @@ import java.util.HashMap; import java.util.HashSet; public class BlockConfiguration { - BlockRotations rotation; - HashSet blockProperties; - + private BlockRotations rotation; + private HashSet blockProperties; public BlockConfiguration(JsonObject json) { if (json.has("facing")) { diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelInterface.java b/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelInterface.java index 68895c5a4..00c45029b 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelInterface.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelInterface.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelLoader.java b/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelLoader.java index 1838cb015..eba3dfd5a 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelLoader.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelLoader.java @@ -33,7 +33,7 @@ import static de.bixilon.minosoft.util.Util.readJsonAsset; public class BlockModelLoader { private final HashMap> blockDescriptionMap; - TextureLoader textureLoader; + private TextureLoader textureLoader; public BlockModelLoader() { blockDescriptionMap = new HashMap<>(); diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/Face/Axis.java b/src/main/java/de/bixilon/minosoft/render/blockModels/Face/Axis.java index e9e094f1b..59265e311 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/Face/Axis.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/Face/Axis.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/Face/Face.java b/src/main/java/de/bixilon/minosoft/render/blockModels/Face/Face.java index 8eb2c09d5..8ff04535c 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/Face/Face.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/Face/Face.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -18,9 +18,9 @@ import de.bixilon.minosoft.render.blockModels.subBlocks.SubBlockPosition; import de.bixilon.minosoft.render.texture.InFaceUV; public class Face { - final SubBlockPosition[] positions; - int rotation; - InFaceUV uv; + private final SubBlockPosition[] positions; + private int rotation; + private InFaceUV uv; public Face(float texture, InFaceUV uv, SubBlockPosition[] facePositions) { this(texture, uv, facePositions, 0); diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/Face/FaceOrientation.java b/src/main/java/de/bixilon/minosoft/render/blockModels/Face/FaceOrientation.java index 3b9f7b3e9..8e987c115 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/Face/FaceOrientation.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/Face/FaceOrientation.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/Face/RenderConstants.java b/src/main/java/de/bixilon/minosoft/render/blockModels/Face/RenderConstants.java index ece0e77c7..2bc5ae502 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/Face/RenderConstants.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/Face/RenderConstants.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/BlockModel.java b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/BlockModel.java index 46852e834..7162013ee 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/BlockModel.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/BlockModel.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Lukas Eisenhauer + * Copyright (C) 2020 Moritz Zwerger * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -13,12 +13,9 @@ package de.bixilon.minosoft.render.blockModels.specialModels; -import com.google.common.collect.HashBiMap; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import de.bixilon.minosoft.Config; import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Block; -import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.BlockRotations; import de.bixilon.minosoft.logging.Log; import de.bixilon.minosoft.render.blockModels.BlockConfiguration; import de.bixilon.minosoft.render.blockModels.BlockConfigurationTrue; @@ -28,16 +25,13 @@ import de.bixilon.minosoft.render.blockModels.Face.FaceOrientation; import de.bixilon.minosoft.render.blockModels.subBlocks.SubBlock; import de.bixilon.minosoft.render.texture.TextureLoader; -import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import static de.bixilon.minosoft.util.Util.readJsonFromFile; - public class BlockModel implements BlockModelInterface { - HashMap> blockConfigurationStates; - boolean isFull; + private final HashMap> blockConfigurationStates; + private final boolean isFull; public BlockModel(JsonObject block, String mod) { blockConfigurationStates = new HashMap<>(); @@ -57,10 +51,6 @@ public class BlockModel implements BlockModelInterface { isFull = true; } - public BlockModel() { - } - - public static HashSet prepareBlockState(HashSet subBlocks, HashMap adjacentBlocks, Block block) { HashSet result = new HashSet<>(); diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/CropModel.java b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/CropModel.java index 932b922d9..00cb35c4a 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/CropModel.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/CropModel.java @@ -29,7 +29,7 @@ import java.util.HashSet; import static de.bixilon.minosoft.render.blockModels.specialModels.BlockModel.*; public class CropModel implements BlockModelInterface { - HashMap> modelMap; + private final HashMap> modelMap; public CropModel(JsonObject block, String mod) { int stages = block.get("stages").getAsInt(); diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/DoorModel.java b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/DoorModel.java index a086fc15c..9d49ba2ec 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/DoorModel.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/DoorModel.java @@ -30,11 +30,11 @@ import java.util.HashSet; import static de.bixilon.minosoft.render.blockModels.specialModels.BlockModel.*; public class DoorModel implements BlockModelInterface { - HashSet bottom; - HashSet bottom_hinge; + private final HashSet bottom; + private final HashSet bottom_hinge; - HashSet top; - HashSet top_hinge; + private final HashSet top; + private final HashSet top_hinge; public DoorModel(JsonObject block, String mod) { bottom = BlockModelInterface.load(mod, block.get("bottom").getAsString()); diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/FireModel.java b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/FireModel.java index 295091d0e..d338a636d 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/FireModel.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/FireModel.java @@ -27,10 +27,9 @@ import java.util.HashMap; import java.util.HashSet; public class FireModel implements BlockModelInterface { - HashSet floor; - HashSet side; - HashSet up; - + private final HashSet floor; + private final HashSet side; + private final HashSet up; public FireModel(JsonObject block, String mod) { floor = BlockModelInterface.load(mod, block.get("floor").getAsString()); diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/StairsModel.java b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/StairsModel.java index 199ec63b8..90fd807e0 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/StairsModel.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/specialModels/StairsModel.java @@ -27,9 +27,9 @@ import java.util.HashMap; import java.util.HashSet; public class StairsModel implements BlockModelInterface { - HashSet straight; - HashSet inner; - HashSet outer; + private final HashSet straight; + private final HashSet inner; + private final HashSet outer; public StairsModel(JsonObject block, String mod) { straight = BlockModelInterface.load(mod, block.get("straight").getAsString()); diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/Cuboid.java b/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/Cuboid.java index 21883e051..61e9edffd 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/Cuboid.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/Cuboid.java @@ -32,7 +32,7 @@ public class Cuboid { FaceOrientation.NORTH, new int[]{5, 4, 0, 1} ); - HashMap facePositionMap; + private final HashMap facePositionMap; public Cuboid(SubBlockPosition from, SubBlockPosition to, SubBlockRotation rotation) { SubBlockPosition[] positions = new SubBlockPosition[8]; diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlock.java b/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlock.java index 09afff263..86bb7b570 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlock.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlock.java @@ -25,16 +25,16 @@ import java.util.HashSet; import java.util.Map; public class SubBlock { - SubBlockRotation rotation; + private SubBlockRotation rotation; - HashMap textureCoordinates; - HashMap textures; - HashMap textureRotations; - HashMap cullFaceTextures; + private final HashMap textureCoordinates; + private final HashMap textures; + private final HashMap textureRotations; + private final HashMap cullFaceTextures; - HashMap uv; + private final HashMap uv; - Cuboid cuboid; + private final Cuboid cuboid; private final boolean isFull; diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlockPosition.java b/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlockPosition.java index ac3bae546..5673a9568 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlockPosition.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlockPosition.java @@ -22,20 +22,22 @@ import static de.bixilon.minosoft.render.blockModels.Face.RenderConstants.blockR import static org.lwjgl.opengl.GL11.glVertex3f; public class SubBlockPosition { - float x, y, z; + public float x; + public float y; + public float z; - public static final SubBlockPosition middlePos = new SubBlockPosition(8, 8, 8); + private static final SubBlockPosition middlePos = new SubBlockPosition(8, 8, 8); - public static final SubBlockRotation westRotator = new SubBlockRotation(middlePos, Axis.Y, 90); - public static final SubBlockRotation eastRotator = new SubBlockRotation(middlePos, Axis.Y, 270); - public static final SubBlockRotation southRotator = new SubBlockRotation(middlePos, Axis.Y, 180); + private static final SubBlockRotation westRotator = new SubBlockRotation(middlePos, Axis.Y, 90); + private static final SubBlockRotation eastRotator = new SubBlockRotation(middlePos, Axis.Y, 270); + private static final SubBlockRotation southRotator = new SubBlockRotation(middlePos, Axis.Y, 180); - public static final SubBlockRotation xAxisRotator = new SubBlockRotation(middlePos, Axis.Z, 90); - public static final SubBlockRotation zAxisRotator = new SubBlockRotation(middlePos, Axis.X, 90); + private static final SubBlockRotation xAxisRotator = new SubBlockRotation(middlePos, Axis.Z, 90); + private static final SubBlockRotation zAxisRotator = new SubBlockRotation(middlePos, Axis.X, 90); - public static final SubBlockRotation downRotator = new SubBlockRotation(middlePos, Axis.X, 90); - public static final SubBlockRotation downAltRotator = new SubBlockRotation(middlePos, Axis.X, 180); - public static final SubBlockRotation upRotator = new SubBlockRotation(middlePos, Axis.X, -90); + private static final SubBlockRotation downRotator = new SubBlockRotation(middlePos, Axis.X, 90); + private static final SubBlockRotation downAltRotator = new SubBlockRotation(middlePos, Axis.X, 180); + private static final SubBlockRotation upRotator = new SubBlockRotation(middlePos, Axis.X, -90); public SubBlockPosition(JsonArray json) { diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlockRotation.java b/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlockRotation.java index efd68813e..1e889fcb3 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlockRotation.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/subBlocks/SubBlockRotation.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -21,9 +21,9 @@ import static java.lang.StrictMath.cos; import static java.lang.StrictMath.sin; public class SubBlockRotation { - SubBlockPosition origin; - Axis direction; - float angle; + private final SubBlockPosition origin; + private Axis direction; + private final float angle; public SubBlockRotation(SubBlockPosition origin, Axis direction, float angle) { this.origin = origin; @@ -35,15 +35,9 @@ public class SubBlockRotation { origin = new SubBlockPosition(rotation.get("origin").getAsJsonArray()); String axis = rotation.get("axis").getAsString(); switch (axis) { - case "x": - direction = Axis.X; - break; - case "y": - direction = Axis.Y; - break; - case "z": - direction = Axis.Z; - break; + case "x" -> direction = Axis.X; + case "y" -> direction = Axis.Y; + case "z" -> direction = Axis.Z; } angle = rotation.get("angle").getAsFloat(); } @@ -63,21 +57,21 @@ public class SubBlockRotation { SubBlockPosition transformed = SubBlockPosition.subtract(position, origin); Pair rotated; switch (direction) { - case X: + case X -> { rotated = rotate(transformed.y, transformed.z, angle); transformed.y = rotated.getKey(); transformed.z = rotated.getValue(); - break; - case Y: + } + case Y -> { rotated = rotate(transformed.x, transformed.z, angle); transformed.x = rotated.getKey(); transformed.z = rotated.getValue(); - break; - case Z: + } + case Z -> { rotated = rotate(transformed.x, transformed.y, angle); transformed.x = rotated.getKey(); transformed.y = rotated.getValue(); - break; + } } return SubBlockPosition.add(transformed, origin); } diff --git a/src/main/java/de/bixilon/minosoft/render/movement/CameraMovement.java b/src/main/java/de/bixilon/minosoft/render/movement/CameraMovement.java index 4651462cb..d9fd6ebf9 100644 --- a/src/main/java/de/bixilon/minosoft/render/movement/CameraMovement.java +++ b/src/main/java/de/bixilon/minosoft/render/movement/CameraMovement.java @@ -21,7 +21,8 @@ import static java.lang.StrictMath.*; import static org.lwjgl.opengl.GL11.glRotatef; public class CameraMovement { - Vec3 cameraFront = new Vec3(0.0f, 0.0f, -1.0f); + private static final float sensitivity = 0.1f; + private Vec3 cameraFront = new Vec3(0.0f, 0.0f, -1.0f); private boolean firstMouse = false; private float lastX; @@ -30,11 +31,11 @@ public class CameraMovement { private float pitch; public void mouseCallback(long l, double xPos, double yPos) { + // variable l is unused but always given by openGL so it is needed in the method signature if (GameWindow.paused) { return; } - // variable l is unused but always given by openGL so we need it in the method signature if (firstMouse) { lastX = (float) xPos; lastY = (float) yPos; @@ -46,18 +47,18 @@ public class CameraMovement { lastX = (float) xPos; lastY = (float) yPos; - float sensitivity = 0.1f; // change this value to your liking xoffset *= sensitivity; yoffset *= sensitivity; yaw += xoffset; pitch += yoffset; - // make sure that pitch does not get out of bounds - if (pitch > 89.0f) + if (pitch > 89.0f) { pitch = 89.0f; - if (pitch < -89.0f) + } + if (pitch < -89.0f) { pitch = -89.0f; + } Vec3 front = new Vec3(); front.x = (float) -(sin(toRadians(yaw)) * cos(toRadians(pitch))); diff --git a/src/main/java/de/bixilon/minosoft/render/movement/CollisionHandler.java b/src/main/java/de/bixilon/minosoft/render/movement/CollisionHandler.java index ba2f3a3e8..3196030d7 100644 --- a/src/main/java/de/bixilon/minosoft/render/movement/CollisionHandler.java +++ b/src/main/java/de/bixilon/minosoft/render/movement/CollisionHandler.java @@ -23,9 +23,9 @@ import static de.bixilon.minosoft.render.utility.AdditionalMath.betterRound; import static de.bixilon.minosoft.render.utility.AdditionalMath.valuesBetween; public class CollisionHandler { - World world; - PlayerController controller; - BlockModelLoader modelLoader; + private final World world; + private final PlayerController controller; + private final BlockModelLoader modelLoader; public CollisionHandler(PlayerController controller) { world = GameWindow.getConnection().getPlayer().getWorld(); @@ -35,7 +35,7 @@ public class CollisionHandler { public void handleCollisions() { if (isPositionValid(controller.playerPos)) { - // we aren't collided with anything so the player Position does not have to be adjusted + // the player currently isn't colliding with with anything so the player Position does not have to be adjusted return; } xAxisCollision(); @@ -73,7 +73,7 @@ public class CollisionHandler { controller.playerVelocity.y = 0; if (deltaY < 0) { - controller.onGround = true; + controller.setOnGround(true); } } diff --git a/src/main/java/de/bixilon/minosoft/render/movement/PlayerController.java b/src/main/java/de/bixilon/minosoft/render/movement/PlayerController.java index 4e55b5384..c84f2cfc6 100644 --- a/src/main/java/de/bixilon/minosoft/render/movement/PlayerController.java +++ b/src/main/java/de/bixilon/minosoft/render/movement/PlayerController.java @@ -22,14 +22,15 @@ import static de.bixilon.minosoft.render.utility.Vec3.mul; import static org.lwjgl.opengl.GL11.glTranslatef; public class PlayerController { - private final float playerHeight = 1.8f; - private final float playerWidth = 0.25f; + private static final float playerHeight = 1.8f; + private static final float playerWidth = 0.25f; + private static final float gravity = 13; + CameraMovement cameraMovement; PlayerMovement playerMovement; Vec3 playerPos = new Vec3(); // the feet position of the player Vec3 playerVelocity = new Vec3(); - float gravity = 9.81f; - boolean onGround; + private boolean onGround; private boolean enableGravity; private CollisionHandler collisionHandler; public Vec3 oldPos; @@ -121,4 +122,8 @@ public class PlayerController { public float getPlayerHeight() { return playerHeight; } + + public void setOnGround(boolean onGround) { + this.onGround = onGround; + } } diff --git a/src/main/java/de/bixilon/minosoft/render/movement/PlayerMovement.java b/src/main/java/de/bixilon/minosoft/render/movement/PlayerMovement.java index 785b84fce..b5b4a80bf 100644 --- a/src/main/java/de/bixilon/minosoft/render/movement/PlayerMovement.java +++ b/src/main/java/de/bixilon/minosoft/render/movement/PlayerMovement.java @@ -11,10 +11,6 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -/* - * A simple camera controller to fly around the scene - */ - package de.bixilon.minosoft.render.movement; import de.bixilon.minosoft.render.GameWindow; @@ -25,20 +21,19 @@ import static de.bixilon.minosoft.render.utility.Vec3.mul; import static org.lwjgl.glfw.GLFW.*; public class PlayerMovement { + private static final float FLY_SPEED = 0.1f; + private static final Vec3 CAMERA_UP = new Vec3(0f, 1f, 0f); + private final long window; - Vec3 cameraFront; - Vec3 cameraUp = new Vec3(0f, 1f, 0f); - - float flySpeed = 0.1f; - - Vec3 playerPos; + private Vec3 cameraFront; + private Vec3 playerPos; public PlayerMovement(long window) { this.window = window; } private void processInput(float deltaTime) { - float cameraSpeed = flySpeed / deltaTime; + float cameraSpeed = FLY_SPEED / deltaTime; if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) { playerPos.add(mul(cameraFront, -cameraSpeed * deltaTime)); @@ -47,10 +42,10 @@ public class PlayerMovement { playerPos.add(mul(cameraFront, cameraSpeed * deltaTime)); } if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) { - playerPos.add(mul(cross(cameraUp, cameraFront), -cameraSpeed * deltaTime)); + playerPos.add(mul(cross(CAMERA_UP, cameraFront), -cameraSpeed * deltaTime)); } if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) { - playerPos.add(mul(cross(cameraUp, cameraFront), cameraSpeed * deltaTime)); + playerPos.add(mul(cross(CAMERA_UP, cameraFront), cameraSpeed * deltaTime)); } if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) { diff --git a/src/main/java/de/bixilon/minosoft/render/texture/InFaceUV.java b/src/main/java/de/bixilon/minosoft/render/texture/InFaceUV.java index b122ad7fb..89b88ecc5 100644 --- a/src/main/java/de/bixilon/minosoft/render/texture/InFaceUV.java +++ b/src/main/java/de/bixilon/minosoft/render/texture/InFaceUV.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -20,7 +20,7 @@ import static de.bixilon.minosoft.render.blockModels.Face.RenderConstants.textur import static org.lwjgl.opengl.GL11.glTexCoord2f; public class InFaceUV { - public int u1, v1, u2, v2; + public final int u1, v1, u2, v2; public float realU1, realV1, realU2, realV2; diff --git a/src/main/java/de/bixilon/minosoft/render/texture/TextureLoader.java b/src/main/java/de/bixilon/minosoft/render/texture/TextureLoader.java index e7baf2ce9..62cfd22b7 100644 --- a/src/main/java/de/bixilon/minosoft/render/texture/TextureLoader.java +++ b/src/main/java/de/bixilon/minosoft/render/texture/TextureLoader.java @@ -33,10 +33,10 @@ import static org.lwjgl.opengl.GL30.glGenerateMipmap; public class TextureLoader { private final HashMap> textureCoordinates; - int textureID; - float step; - int totalTextures = 0; - HashMap> images; + private int textureID; + private float step; + private int totalTextures = 0; + private HashMap> images; public TextureLoader(HashMap> textures, HashMap> tints) { textureCoordinates = new HashMap<>(); diff --git a/src/main/java/de/bixilon/minosoft/render/utility/AdditionalMath.java b/src/main/java/de/bixilon/minosoft/render/utility/AdditionalMath.java index daa4a6be1..20d6f5b06 100644 --- a/src/main/java/de/bixilon/minosoft/render/utility/AdditionalMath.java +++ b/src/main/java/de/bixilon/minosoft/render/utility/AdditionalMath.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -39,8 +39,4 @@ public class AdditionalMath { } return (int) x - 1; } - - public static boolean isBetween(double x, double a, double b) { - return x <= a && x >= b || x >= a && x <= b; - } -} +} \ No newline at end of file diff --git a/src/main/java/de/bixilon/minosoft/render/utility/Triplet.java b/src/main/java/de/bixilon/minosoft/render/utility/Triplet.java deleted file mode 100644 index ae6a6710d..000000000 --- a/src/main/java/de/bixilon/minosoft/render/utility/Triplet.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger - * - * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with this program. If not, see . - * - * This software is not affiliated with Mojang AB, the original developer of Minecraft. - */ - -package de.bixilon.minosoft.render.utility; - -public class Triplet { - public T item1; - public T1 item2; - public T2 item3; - - public Triplet(T item1, T1 item2, T2 item3) { - this.item1 = item1; - this.item2 = item2; - this.item3 = item3; - } -} diff --git a/src/main/java/de/bixilon/minosoft/render/utility/Vec3.java b/src/main/java/de/bixilon/minosoft/render/utility/Vec3.java index c2a78a80a..1c1fbc9e1 100644 --- a/src/main/java/de/bixilon/minosoft/render/utility/Vec3.java +++ b/src/main/java/de/bixilon/minosoft/render/utility/Vec3.java @@ -1,6 +1,6 @@ /* * Codename Minosoft - * Copyright (C) 2020 Moritz Zwerger + * Copyright (C) 2020 Lukas Eisenhauer * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. *