Move mixin to ModelLoader

This commit is contained in:
Shadowfacts 2018-12-22 12:59:13 -05:00
parent f03001699b
commit 9dc046491f
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
3 changed files with 34 additions and 30 deletions

View File

@ -1,28 +0,0 @@
package net.shadowfacts.simplemultipart.mixin.client;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.util.Identifier;
import net.shadowfacts.simplemultipart.client.MultipartContainerBakedModel;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.Map;
/**
* @author shadowfacts
*/
@Mixin(BakedModelManager.class)
public class MixinBakedModelManager {
@Redirect(method = "onResourceReload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/ModelLoader;getBakedModelMap()Ljava/util/Map;"))
public Map<Identifier, BakedModel> getBakedModelMap(ModelLoader loader) {
Map<Identifier, BakedModel> map = loader.getBakedModelMap();
map.put(new ModelIdentifier("simplemultipart:container#"), new MultipartContainerBakedModel());
return map;
}
}

View File

@ -0,0 +1,32 @@
package net.shadowfacts.simplemultipart.mixin.client;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import net.shadowfacts.simplemultipart.client.MultipartContainerBakedModel;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Map;
/**
* @author shadowfacts
*/
@Mixin(ModelLoader.class)
public class MixinModelLoader {
@Shadow
private Map<Identifier, BakedModel> bakedModels;
@Inject(method = "<init>", at = @At("RETURN"))
public void addMultipartModel(ResourceManager manager, SpriteAtlasTexture texture, CallbackInfo info) {
bakedModels.put(new ModelIdentifier("simplemultipart:container#"), new MultipartContainerBakedModel());
}
}

View File

@ -3,8 +3,8 @@
"package": "net.shadowfacts.simplemultipart.mixin.client", "package": "net.shadowfacts.simplemultipart.mixin.client",
"compatibilityLevel": "JAVA_8", "compatibilityLevel": "JAVA_8",
"mixins": [ "mixins": [
"MixinBakedModelManager", "MixinBlockRenderManager",
"MixinBlockRenderManager" "MixinModelLoader"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1