From c6dc0b03fcdf4ab092d66f955bc33eb120157b4b Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 4 Dec 2021 10:11:19 -0800 Subject: [PATCH] Tile parsing fixes - Tweak how matchTiles is parsed - Clean up resolveTiles - Rename some methods - Update buildscript, Gradle, and build dependencies --- build.gradle | 16 ++-------- gradle.properties | 10 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../client/properties/BaseCTMProperties.java | 32 +++++++++---------- .../client/resource/CTMLoadingContainer.java | 2 +- .../client/resource/CTMPropertiesLoader.java | 6 ++-- .../client/util/PropertiesParsingHelper.java | 2 +- 7 files changed, 28 insertions(+), 42 deletions(-) diff --git a/build.gradle b/build.gradle index 49fbd15..4272b56 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ dependencies { } modCompileOnly 'maven.modrinth:sodium:mc1.17.1-0.3.3' - modCompileOnly 'io.vram:canvas-fabric-mc117-1.17:1.0.2195' + modCompileOnly 'io.vram:canvas-fabric-mc117:1.0.2219' } String getExtraBuildMetadata() { @@ -65,12 +65,6 @@ processResources { } tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding 'UTF-8' - // Minecraft 1.17 (21w19a) upwards uses Java 16. it.options.release.set(16) } @@ -92,13 +86,7 @@ jar { publishing { publications { mavenJava(MavenPublication) { - // add all the jars that should be included when publishing to maven - artifact(remapJar) { - builtBy remapJar - } - artifact(sourcesJar) { - builtBy remapSourcesJar - } + from components.java } } diff --git a/gradle.properties b/gradle.properties index 3d270aa..df1f26d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,17 @@ -# Done to increase the memory available to gradle. +# Done to increase the memory available to Gradle. org.gradle.jvmargs = -Xmx1G # Fabric Properties loom_version = 0.10-SNAPSHOT minecraft_version = 1.17.1 - yarn_mappings = 1.17.1+build.64 - loader_version = 0.12.5 + yarn_mappings = 1.17.1+build.65 + loader_version = 0.12.8 # Mod Properties - mod_version = 1.0.2 + mod_version = 1.0.3 mod_minecraft_version = 1.17 maven_group = me.pepperbell archives_base_name = continuity # Dependencies - fabric_version = 0.43.0+1.17 + fabric_version = 0.44.0+1.17 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..84d1f85 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/me/pepperbell/continuity/client/properties/BaseCTMProperties.java b/src/main/java/me/pepperbell/continuity/client/properties/BaseCTMProperties.java index 9430f43..a09c88b 100644 --- a/src/main/java/me/pepperbell/continuity/client/properties/BaseCTMProperties.java +++ b/src/main/java/me/pepperbell/continuity/client/properties/BaseCTMProperties.java @@ -109,7 +109,7 @@ public boolean affectsBlockState(BlockState state) { @Override public Set getTextureDependencies() { if (textureDependencies == null) { - processTiles(); + resolveTiles(); } return textureDependencies; } @@ -551,32 +551,30 @@ protected boolean isValid() { return valid; } - protected void processTiles() { + protected void resolveTiles() { textureDependencies = new ObjectOpenHashSet<>(); spriteIds = new ObjectArrayList<>(); ResourceManager resourceManager = MinecraftClient.getInstance().getResourceManager(); for (Identifier tile : tiles) { - SpriteIdentifier spriteId = null; + SpriteIdentifier spriteId; if (tile.equals(SPECIAL_SKIP_ID)) { spriteId = SPECIAL_SKIP_SPRITE_ID; } else if (tile.equals(SPECIAL_DEFAULT_ID)) { spriteId = SPECIAL_DEFAULT_SPRITE_ID; - } - if (spriteId == null) { - Identifier newTile; - if (tile.getPath().startsWith("textures/")) { - String newPath = tile.getPath().substring(9); - if (newPath.endsWith(".png")) { - newPath = newPath.substring(0, newPath.length() - 4); + } else { + String namespace = tile.getNamespace(); + String path = tile.getPath(); + if (path.startsWith("textures/")) { + path = path.substring(9); + if (path.endsWith(".png")) { + path = path.substring(0, path.length() - 4); } - newTile = new Identifier(tile.getNamespace(), newPath); } else { - String newPath = getRedirectPath(tile.getPath()); - Identifier newId = new Identifier(tile.getNamespace(), "textures/" + newPath + ".png"); - ResourceRedirectHelper.addRedirect(resourceManager, newId, tile); - newTile = new Identifier(tile.getNamespace(), newPath); + path = getRedirectPath(path); + Identifier redirectId = new Identifier(namespace, "textures/" + path + ".png"); + ResourceRedirectHelper.addRedirect(resourceManager, redirectId, tile); } - spriteId = TextureUtil.toSpriteId(newTile); + spriteId = TextureUtil.toSpriteId(new Identifier(namespace, path)); textureDependencies.add(spriteId); } spriteIds.add(spriteId); @@ -629,7 +627,7 @@ public Predicate getBlockEntityNamePredicate() { public List getSpriteIds() { if (spriteIds == null) { - processTiles(); + resolveTiles(); } return spriteIds; } diff --git a/src/main/java/me/pepperbell/continuity/client/resource/CTMLoadingContainer.java b/src/main/java/me/pepperbell/continuity/client/resource/CTMLoadingContainer.java index ab9214d..ba3d259 100644 --- a/src/main/java/me/pepperbell/continuity/client/resource/CTMLoadingContainer.java +++ b/src/main/java/me/pepperbell/continuity/client/resource/CTMLoadingContainer.java @@ -42,7 +42,7 @@ public void addMultipassDependent(CTMLoadingContainer dependent) { multipassDependents.add(dependent); } - public void calculateRecursiveMultipassDependents(Set> traversedContainers) { + public void resolveRecursiveMultipassDependents(Set> traversedContainers) { if (multipassDependents != null) { recursiveMultipassDependents = new ObjectOpenHashSet<>(); addDependentsRecursively(this, traversedContainers); diff --git a/src/main/java/me/pepperbell/continuity/client/resource/CTMPropertiesLoader.java b/src/main/java/me/pepperbell/continuity/client/resource/CTMPropertiesLoader.java index 8466e11..5d8459c 100644 --- a/src/main/java/me/pepperbell/continuity/client/resource/CTMPropertiesLoader.java +++ b/src/main/java/me/pepperbell/continuity/client/resource/CTMPropertiesLoader.java @@ -50,7 +50,7 @@ public static void loadAll(ResourceManager resourceManager) { packPriority++; } InvalidIdentifierHandler.disableInvalidPaths(); - calculateMultipassDependents(); + resolveMultipassDependents(); } private static void loadAll(ResourcePack pack, int packPriority) { @@ -95,7 +95,7 @@ private static void load(CTMLoader loader, Properti } } - private static void calculateMultipassDependents() { + private static void resolveMultipassDependents() { Object2ObjectOpenHashMap> texture2ContainerMap = new Object2ObjectOpenHashMap<>(); Object2ObjectOpenHashMap>> texture2ContainerListMap = new Object2ObjectOpenHashMap<>(); @@ -158,7 +158,7 @@ private static void calculateMultipassDependents() { Set> traversedContainers = new ObjectOpenHashSet<>(); for (int i = 0; i < amount; i++) { CTMLoadingContainer container = ALL.get(i); - container.calculateRecursiveMultipassDependents(traversedContainers); + container.resolveRecursiveMultipassDependents(traversedContainers); } } diff --git a/src/main/java/me/pepperbell/continuity/client/util/PropertiesParsingHelper.java b/src/main/java/me/pepperbell/continuity/client/util/PropertiesParsingHelper.java index 916adbf..5fb60a9 100644 --- a/src/main/java/me/pepperbell/continuity/client/util/PropertiesParsingHelper.java +++ b/src/main/java/me/pepperbell/continuity/client/util/PropertiesParsingHelper.java @@ -62,7 +62,7 @@ public static ImmutableSet parseMatchTiles(Properties properties, St } if (path.startsWith("textures/")) { path = path.substring(9); - } else { + } else if (path.startsWith("optifine/")) { path = BaseCTMProperties.getRedirectPath(path + ".png"); } try {