Skip to content

Commit

Permalink
Tile parsing fixes
Browse files Browse the repository at this point in the history
- Tweak how matchTiles is parsed
- Clean up resolveTiles
- Rename some methods
- Update buildscript, Gradle, and build dependencies
  • Loading branch information
PepperCode1 committed Dec 4, 2021
1 parent 8f786db commit c6dc0b0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 42 deletions.
16 changes: 2 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
}
Expand All @@ -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
}
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public boolean affectsBlockState(BlockState state) {
@Override
public Set<SpriteIdentifier> getTextureDependencies() {
if (textureDependencies == null) {
processTiles();
resolveTiles();
}
return textureDependencies;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -629,7 +627,7 @@ public Predicate<String> getBlockEntityNamePredicate() {

public List<SpriteIdentifier> getSpriteIds() {
if (spriteIds == null) {
processTiles();
resolveTiles();
}
return spriteIds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void addMultipassDependent(CTMLoadingContainer<?> dependent) {
multipassDependents.add(dependent);
}

public void calculateRecursiveMultipassDependents(Set<CTMLoadingContainer<?>> traversedContainers) {
public void resolveRecursiveMultipassDependents(Set<CTMLoadingContainer<?>> traversedContainers) {
if (multipassDependents != null) {
recursiveMultipassDependents = new ObjectOpenHashSet<>();
addDependentsRecursively(this, traversedContainers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void loadAll(ResourceManager resourceManager) {
packPriority++;
}
InvalidIdentifierHandler.disableInvalidPaths();
calculateMultipassDependents();
resolveMultipassDependents();
}

private static void loadAll(ResourcePack pack, int packPriority) {
Expand Down Expand Up @@ -95,7 +95,7 @@ private static <T extends CTMProperties> void load(CTMLoader<T> loader, Properti
}
}

private static void calculateMultipassDependents() {
private static void resolveMultipassDependents() {
Object2ObjectOpenHashMap<Identifier, CTMLoadingContainer<?>> texture2ContainerMap = new Object2ObjectOpenHashMap<>();
Object2ObjectOpenHashMap<Identifier, List<CTMLoadingContainer<?>>> texture2ContainerListMap = new Object2ObjectOpenHashMap<>();

Expand Down Expand Up @@ -158,7 +158,7 @@ private static void calculateMultipassDependents() {
Set<CTMLoadingContainer<?>> traversedContainers = new ObjectOpenHashSet<>();
for (int i = 0; i < amount; i++) {
CTMLoadingContainer<?> container = ALL.get(i);
container.calculateRecursiveMultipassDependents(traversedContainers);
container.resolveRecursiveMultipassDependents(traversedContainers);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static ImmutableSet<Identifier> parseMatchTiles(Properties properties, St
}
if (path.startsWith("textures/")) {
path = path.substring(9);
} else {
} else if (path.startsWith("optifine/")) {
path = BaseCTMProperties.getRedirectPath(path + ".png");
}
try {
Expand Down

0 comments on commit c6dc0b0

Please sign in to comment.