Compat with Canvas emissive shaders, fixes
This commit is contained in:
parent
bcc3b076c2
commit
b05f5a728f
15 changed files with 210 additions and 6 deletions
|
@ -0,0 +1,59 @@
|
|||
package ru.bclib.mixin.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.resources.FallbackResourceManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimpleResource;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.api.ModIntegrationAPI;
|
||||
import ru.bclib.client.render.EmissiveTextureInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(SimpleReloadableResourceManager.class)
|
||||
public class SimpleReloadableResourceManagerMixin {
|
||||
@Final
|
||||
@Shadow
|
||||
private Map<String, FallbackResourceManager> namespacedPacks;
|
||||
|
||||
private Resource bclib_alphaEmissionMaterial;
|
||||
|
||||
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
|
||||
private void bclib_getResource(ResourceLocation resourceLocation, CallbackInfoReturnable<Resource> info) throws IOException {
|
||||
if (!ModIntegrationAPI.hasCanvas()) {
|
||||
return;
|
||||
}
|
||||
if (!resourceLocation.getPath().startsWith("materialmaps")) {
|
||||
return;
|
||||
}
|
||||
if (!resourceLocation.getPath().contains("/block/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = resourceLocation.getPath().replace("materialmaps/block/", "").replace(".json", "");
|
||||
ResourceLocation blockID = new ResourceLocation(resourceLocation.getNamespace(), name);
|
||||
|
||||
if (!EmissiveTextureInfo.isEmissiveBlock(blockID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceManager resourceManager = this.namespacedPacks.get(resourceLocation.getNamespace());
|
||||
if (resourceManager != null) {
|
||||
resourceLocation = BCLib.makeID("materialmaps/block/alpha_emission.json");
|
||||
info.setReturnValue(resourceManager.getResource(resourceLocation));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue