Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
fix resource loading (fixes colormaps)
Browse files Browse the repository at this point in the history
  • Loading branch information
mist475 committed Dec 17, 2023
1 parent db709c2 commit b5d69ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
4 changes: 0 additions & 4 deletions src/main/java/com/prupe/mcpatcher/mal/biome/ColorMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenSwamp;

import com.prupe.mcpatcher.Config;
import com.prupe.mcpatcher.MCLogger;
Expand Down Expand Up @@ -225,9 +224,6 @@ public String toString() {
public final int getColorMultiplier(IBlockAccess blockAccess, int i, int j, int k) {
// TODO: implement this neatly
BiomeGenBase base = BiomeAPI.getBiomeGenAt(blockAccess, i, j, k);
if (base instanceof BiomeGenSwamp || base.biomeID == BiomeGenBase.roofedForest.biomeID) {
return base.getBiomeGrassColor(i, j, k);
}

computeXY(base, i, j, k, xy);
return getRGB(xy[0], xy[1]);
Expand Down
30 changes: 8 additions & 22 deletions src/main/java/com/prupe/mcpatcher/mal/resource/TexturePackAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand All @@ -28,6 +29,8 @@
import net.minecraft.client.resources.SimpleReloadableResourceManager;
import net.minecraft.util.ResourceLocation;

import org.apache.commons.io.IOUtils;

import com.prupe.mcpatcher.MCLogger;
import com.prupe.mcpatcher.MCPatcherUtils;

Expand Down Expand Up @@ -115,30 +118,13 @@ public static boolean hasCustomResource(ResourceLocation resource) {
InputStream jar = null;
InputStream pack = null;
try {
String path = ASSETS + resource.getResourceDomain() + "/" + resource.getResourcePath();
pack = getInputStream(resource);
if (pack == null) {
jar = Minecraft.getMinecraft().mcDefaultResourcePack.getInputStream(resource);

if (pack == null || jar == null) {
return false;
}
jar = Minecraft.class.getResourceAsStream(path);
if (jar == null) {
return true;
}
byte[] buffer1 = new byte[4096];
byte[] buffer2 = new byte[4096];
int read1;
int read2;
while ((read1 = pack.read(buffer1)) > 0) {
read2 = jar.read(buffer2);
if (read1 != read2) {
return true;
}
for (int i = 0; i < read1; i++) {
if (buffer1[i] != buffer2[i]) {
return true;
}
}
}
return !Arrays.equals(IOUtils.toByteArray(jar), IOUtils.toByteArray(pack));
} catch (IOException e) {
e.printStackTrace();
} finally {
Expand Down Expand Up @@ -338,7 +324,7 @@ public static void flushUnusedTextures() {
unloadTexture(resource);
}
}
};
}

private static IResourceManager getResourceManager() {
return Minecraft.getMinecraft()
Expand Down

0 comments on commit b5d69ad

Please sign in to comment.