Skip to content

Commit ad6b9a0

Browse files
committed
Add dynamic textures support for Chisel
1 parent 69782b8 commit ad6b9a0

6 files changed

Lines changed: 60 additions & 6 deletions

File tree

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ repositories {
2020
maven { url "http://repo.spongepowered.org/maven" }
2121
maven { url "http://chickenbones.net/maven/" }
2222
maven { url "http://www.dimdev.org/maven" }
23+
maven { url "http://maven.tterrag.com/" }
2324
ivy {
2425
url "https://google.com/404"
2526
ivyPattern("https://google.com/404") // Workaround for https://github.com/gradle/gradle/issues/4107
@@ -45,6 +46,7 @@ dependencies {
4546
compileOnly "2511:625:Avaritia-1.12-3.2.0.13-universal@jar"
4647
compileOnly "codechicken:CodeChickenLib:1.12.2-3.1.9.344:deobf"
4748
compileOnly "2482:584:CustomMainMenu-MC1.12.2-2.0.8@jar"
49+
compileOnly "team.chisel.ctm:CTM:MC1.12-0.2.3.12"
4850
}
4951

5052
def travisBuildNumber = System.getenv("TRAVIS_BUILD_NUMBER")

src/main/java/org/dimdev/vanillafix/dynamicresources/DynamicTextureMap.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,19 @@ public void loadTextureAtlas(IResourceManager resourceManager) {
4646
}
4747

4848
public void init() {
49-
initMissingImage();
5049
deleteGlTexture();
51-
5250
int maximumTextureSize = Minecraft.getGLMaximumTextureSize();
5351

5452
stitcher = new DynamicStitcher(maximumTextureSize, maximumTextureSize, 0, mipmapLevels);
55-
56-
mapUploadedSprites.clear();
5753
listAnimatedSprites.clear();
5854

55+
initMissingImage();
5956
missingImage.generateMipmaps(mipmapLevels);
60-
61-
LOGGER.info("Created {}x{} '{}' atlas", stitcher.getImageWidth(), stitcher.getImageHeight(), basePath);
57+
spritesNeedingUpload.add(missingImage);
58+
stitcher.addSprite(missingImage);
6259

6360
TextureUtil.allocateTextureImpl(getGlTextureId(), mipmapLevels, stitcher.getImageWidth(), stitcher.getImageHeight());
61+
LOGGER.info("Created {}x{} '{}' atlas", stitcher.getImageWidth(), stitcher.getImageHeight(), basePath);
6462

6563
ForgeHooksClient.onTextureStitchedPre(this);
6664
ForgeHooksClient.onTextureStitchedPost(this);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.dimdev.vanillafix.dynamicresources.modsupport.mixins.client;
2+
3+
import net.minecraft.client.Minecraft;
4+
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.Overwrite;
7+
import org.spongepowered.asm.mixin.Pseudo;
8+
import org.spongepowered.asm.mixin.Shadow;
9+
import team.chisel.client.TextureStitcher;
10+
11+
@Pseudo
12+
@Mixin(TextureStitcher.MagicStitchingSprite.class)
13+
@SuppressWarnings("deprecation")
14+
public abstract class MixinMagicStitchingSprite extends TextureAtlasSprite {
15+
@Shadow abstract void postStitch();
16+
@Shadow private TextureAtlasSprite parent;
17+
18+
@Overwrite(remap = false)
19+
public MixinMagicStitchingSprite(String spriteName) {
20+
super(spriteName);
21+
parent = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(spriteName);
22+
postStitch();
23+
}
24+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.dimdev.vanillafix.dynamicresources.modsupport.mixins.client;
2+
3+
import net.minecraftforge.client.model.ICustomModelLoader;
4+
import org.dimdev.vanillafix.dynamicresources.model.VanillaLoader;
5+
import org.spongepowered.asm.mixin.*;
6+
import team.chisel.ctm.client.model.parsing.ModelParserV1;
7+
8+
@Pseudo
9+
@Mixin(ModelParserV1.class)
10+
public class MixinModelParserV1 {
11+
@SuppressWarnings("unused") @Shadow(remap = false) @Mutable @Final private static ICustomModelLoader VANILLA_LOADER = VanillaLoader.INSTANCE;
12+
}

src/main/java/org/dimdev/vanillafix/modsupport/mixins/MixinLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private void beforeConstructingMods(List<String> injectedModContainers, Callback
4242

4343
// Add and reload mixin configs
4444
if (VanillaFixLoadingPlugin.config.textureFixes) Mixins.addConfiguration("mixins.vanillafix.textures.modsupport.json");
45+
if (VanillaFixLoadingPlugin.config.dynamicResources) Mixins.addConfiguration("mixins.vanillafix.dynamicresources.modsupport.json");
4546
Proxy mixinProxy = (Proxy) Launch.classLoader.getTransformers().stream().filter(transformer -> transformer instanceof Proxy).findFirst().get();
4647
try {
4748
Field transformerField = Proxy.class.getDeclaredField("transformer");
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"package": "org.dimdev.vanillafix.dynamicresources.modsupport.mixins",
3+
"required": true,
4+
"refmap": "mixins.vanillafix.refmap.json",
5+
"target": "@env(DEFAULT)",
6+
"minVersion": "0.6",
7+
"plugin": "org.dimdev.vanillafix.ModCompatibilityMixinPlugin",
8+
"compatibilityLevel": "JAVA_8",
9+
"mixins": [],
10+
"client": [
11+
"client.MixinModelParserV1",
12+
"client.MixinMagicStitchingSprite"
13+
],
14+
"injectors": {
15+
"maxShiftBy": 10
16+
}
17+
}

0 commit comments

Comments
 (0)