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 cd9f12f37..bb33a4b5c 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelLoader.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/BlockModelLoader.java @@ -39,15 +39,17 @@ public class BlockModelLoader { blockDescriptionMap = new HashMap<>(); HashMap> tints = new HashMap<>(); HashMap> textures = new HashMap<>(); + HashMap> ignoredTextures = new HashMap<>(); try { String folderPath = Config.homeDir + "assets/mapping/blockModels/"; for (File file : new File(folderPath).listFiles()) { JsonObject json = readJsonFromFile(file.getAbsolutePath()); String mod = file.getName().substring(0, file.getName().lastIndexOf('.')); tints.put(mod, readTints(json)); + ignoredTextures.put(mod, readIgnored(json)); textures.put(mod, loadModels(json.get("blocks").getAsJsonObject(), mod)); } - textureLoader = new TextureLoader(textures, tints); + textureLoader = new TextureLoader(textures, tints, ignoredTextures); applyTextures(); } catch (IOException e) { e.printStackTrace(); @@ -55,6 +57,17 @@ public class BlockModelLoader { Log.info("finished loading all blocks"); } + private HashSet readIgnored(JsonObject json) { + if (!json.has("ignored_textures")) { + return new HashSet<>(); + } + HashSet result = new HashSet<>(); + for (JsonElement texture : json.get("ignored_textures").getAsJsonArray()) { + result.add(texture.getAsString()); + } + return result; + } + private void applyTextures() { for (Map.Entry> mod : blockDescriptionMap.entrySet()) { for (Map.Entry block : mod.getValue().entrySet()) { diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/DrawDescription.java b/src/main/java/de/bixilon/minosoft/render/blockModels/DrawDescription.java deleted file mode 100644 index 552e007a5..000000000 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/DrawDescription.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Codename Minosoft - * 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. - * - * 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.blockModels; - -import com.google.gson.JsonObject; -import de.bixilon.minosoft.render.MainWindow; -import de.bixilon.minosoft.render.fullFace.FaceOrientation; -import javafx.util.Pair; - -import java.util.*; - -public class DrawDescription { - private final FaceOrientation[] sideOrientations = new FaceOrientation[]{ - FaceOrientation.EAST, - FaceOrientation.WEST, - FaceOrientation.SOUTH, - FaceOrientation.NORTH - }; - private final FaceOrientation[] endOrientations = new FaceOrientation[]{ - FaceOrientation.UP, - FaceOrientation.DOWN - }; - - - Map> faces; - boolean full = false; // is the block a completely filled block? - - public DrawDescription(JsonObject json, String mod) { - if (!(json.has("parent") && json.has("textures"))) return; - - faces = new HashMap<>(); - - JsonObject textures = json.getAsJsonObject("textures"); - - for (String texture : textures.keySet()) { - String textureUse = textures.getAsJsonObject(texture).toString(); - - Pair texturePair; - - try { - texturePair = MainWindow.getRenderer().getModelLoader().getTextureLoader().getTexture(mod, texture); - } catch (Exception e) { - continue; - } - - List faceOrientations = new ArrayList<>(); - - switch (textureUse) { - case "all": - faceOrientations.addAll(Arrays.asList(FaceOrientation.values())); - case "side": - faceOrientations.addAll(Arrays.asList(sideOrientations)); - case "end": - faceOrientations.addAll(Arrays.asList(endOrientations)); - case "top": - faceOrientations.add(FaceOrientation.UP); - case "bottom": - faceOrientations.add(FaceOrientation.DOWN); - } - - for (FaceOrientation faceOrientation : faceOrientations) { - faces.put(faceOrientation, texturePair); - } - } - full = true; - } - - public boolean isFull() { - return full; - } - - public Pair getTexture(FaceOrientation orientation) { - if (!faces.containsKey(orientation)) - throw new IllegalArgumentException("face " + orientation + " not covered by: " + this); - - return faces.get(orientation); - } - - @Override - public String toString() { - return String.format("%s full: %s", faces.toString(), full); - } -} \ No newline at end of file diff --git a/src/main/java/de/bixilon/minosoft/render/blockModels/SubBlock.java b/src/main/java/de/bixilon/minosoft/render/blockModels/SubBlock.java index 258aef11b..2a198975e 100644 --- a/src/main/java/de/bixilon/minosoft/render/blockModels/SubBlock.java +++ b/src/main/java/de/bixilon/minosoft/render/blockModels/SubBlock.java @@ -75,6 +75,9 @@ public class SubBlock { public void applyTextures(String mod, TextureLoader loader) { for (Map.Entry entry : textures.entrySet()) { Pair texture = loader.getTexture(mod, entry.getValue()); + if (texture == null) { + continue; + } textureCoordinates.put(entry.getKey(), texture); } // clean up @@ -87,7 +90,6 @@ public class SubBlock { } catch (Exception e) { uv.put(orientation, new InFaceUV()); } - String textureName = getRealTextureName(faceJson.get("texture").getAsString(), variables); textures.put(orientation, textureName); cullFaceTextures.put(orientation, faceJson.has("cullface")); 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 473903a92..f81937510 100644 --- a/src/main/java/de/bixilon/minosoft/render/movement/PlayerController.java +++ b/src/main/java/de/bixilon/minosoft/render/movement/PlayerController.java @@ -41,6 +41,9 @@ public class PlayerController { } public void loop(float deltaTime) { + if (!MainWindow.getConnection().getPlayer().isSpawnConfirmed()) { + return; + } oldPos = playerPos.copy(); GameMode gameMode = MainWindow.getConnection().getPlayer().getGameMode(); 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 7c5ead2bb..a036f090d 100644 --- a/src/main/java/de/bixilon/minosoft/render/texture/TextureLoader.java +++ b/src/main/java/de/bixilon/minosoft/render/texture/TextureLoader.java @@ -34,16 +34,19 @@ import static org.lwjgl.opengl.GL30.glGenerateMipmap; public class TextureLoader { private final int TEXTURE_PACK_RES = 16; private final HashMap> textureCoordinates; + private final HashMap> ignored; int textureID; float step; int totalTextures = 0; HashMap> images; - public TextureLoader(HashMap> textures, HashMap> tints) { + public TextureLoader(HashMap> textures, HashMap> tints, + HashMap> ignored_textures) { textureCoordinates = new HashMap<>(); images = new HashMap<>(); + this.ignored = ignored_textures; for (String mod : textures.keySet()) { - loadTextures(mod, textures.get(mod), tints.get(mod)); + loadTextures(mod, textures.get(mod), tints.get(mod), ignored_textures.get(mod)); } combineTextures(); try { @@ -71,9 +74,12 @@ public class TextureLoader { } } - private void loadTextures(String mod, HashSet textureNames, HashMap tint) { + private void loadTextures(String mod, HashSet textureNames, HashMap tint, HashSet ignored) { HashMap modTextureMap = new HashMap<>(); for (String textureName : textureNames) { + if (ignored != null && ignored.contains(textureName)) { + continue; + } String path = Config.homeDir + "assets/" + mod + "/textures/" + textureName + ".png"; try { BufferedImage image = ImageIO.read(new File(path)); @@ -143,6 +149,10 @@ public class TextureLoader { public Pair getTexture(String mod, String textureName) { // returns the start and end u-coordinate of a specific texture to access it + if (ignored.get(mod) != null && ignored.get(mod).contains(textureName)) { + return null; + } + HashMap modMap = textureCoordinates.get(mod); if (modMap == null) { System.out.println("no mod " + mod + " loaded"); diff --git a/src/main/resources/assets/mapping/blockModels/minecraft.json b/src/main/resources/assets/mapping/blockModels/minecraft.json index 94878bdee..2ae88b2b4 100644 --- a/src/main/resources/assets/mapping/blockModels/minecraft.json +++ b/src/main/resources/assets/mapping/blockModels/minecraft.json @@ -116,5 +116,8 @@ 1, 0 ] - } + }, + "ignored_textures": [ + "block/grass_block_side_overlay" + ] } \ No newline at end of file