mirror of
https://github.com/Motschen/Blur.git
synced 2025-12-16 03:35:10 +01:00
Update to 1.14.4
This commit is contained in:
37
build.gradle
37
build.gradle
@@ -1,18 +1,12 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
maven { url = 'http://maven.modmuss50.me' }
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.fabricmc:fabric-loom:0.1.0-SNAPSHOT'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.matthewprenger.cursegradle' version '1.0.9'
|
id 'java'
|
||||||
|
id 'maven-publish'
|
||||||
|
id 'idea'
|
||||||
|
id 'eclipse'
|
||||||
|
id 'com.matthewprenger.cursegradle' version '1.0.9'
|
||||||
|
id 'fabric-loom' version '0.2.4-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'fabric-loom'
|
|
||||||
|
|
||||||
boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equals('false');
|
boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equals('false');
|
||||||
ext.buildnumber = System.getenv().BUILD_NUMBER ?: 'custom';
|
ext.buildnumber = System.getenv().BUILD_NUMBER ?: 'custom';
|
||||||
|
|
||||||
@@ -28,13 +22,26 @@ minecraft {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||||
mappings "net.fabricmc:yarn:${minecraft_version}.${mappings_version}"
|
mappings "net.fabricmc:yarn:${mappings_version}"
|
||||||
modCompile "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
modCompile "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||||
modCompile "net.fabricmc:fabric:${fabric_version}"
|
modCompile "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||||
|
|
||||||
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
implementation 'com.google.code.findbugs:jsr305:3.0.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", mod_version
|
||||||
|
|
||||||
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
|
include "fabric.mod.json"
|
||||||
|
expand "version": mod_version
|
||||||
|
}
|
||||||
|
|
||||||
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
|
exclude "fabric.mod.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
import org.apache.tools.ant.filters.ReplaceTokens
|
import org.apache.tools.ant.filters.ReplaceTokens
|
||||||
import groovy.json.JsonSlurper
|
import groovy.json.JsonSlurper
|
||||||
|
|
||||||
@@ -62,7 +69,7 @@ task createResourcePacks {
|
|||||||
|
|
||||||
from ('pack_icons') {
|
from ('pack_icons') {
|
||||||
include "${pack_id}.png"
|
include "${pack_id}.png"
|
||||||
rename '.+', 'pack.png'
|
rename '.+', 'icon.png'
|
||||||
}
|
}
|
||||||
|
|
||||||
baseName = "Blur " + pack_name
|
baseName = "Blur " + pack_name
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
minecraft_version=18w50a
|
minecraft_version=1.14.4
|
||||||
|
|
||||||
mod_version=1.0.4
|
mod_version=1.0.5
|
||||||
|
|
||||||
fabric_loader_version=0.2.0.65
|
fabric_loader_version=0.4.8+build.157
|
||||||
fabric_version=0.1.1.47
|
fabric_version=0.3.0+build.200
|
||||||
mappings_version=2
|
mappings_version=1.14.4+build.2
|
||||||
|
|
||||||
project_id=268324
|
project_id=268324
|
||||||
release_type=release
|
release_type=release
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Wed Aug 20 15:17:58 CDT 2014
|
#Sun Nov 11 14:39:10 PST 2018
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
|
||||||
|
|||||||
12
settings.gradle
Normal file
12
settings.gradle
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
maven {
|
||||||
|
name = 'Fabric'
|
||||||
|
url = 'https://maven.fabricmc.net/'
|
||||||
|
}
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "blur"
|
||||||
@@ -1,5 +1,27 @@
|
|||||||
package com.tterrag.blur;
|
package com.tterrag.blur;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.tterrag.blur.mixin.MixinGameRenderer;
|
||||||
|
import com.tterrag.blur.util.ReflectionHelper;
|
||||||
|
import com.tterrag.blur.util.ShaderResourcePack;
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.gl.GlUniform;
|
||||||
|
import net.minecraft.client.gl.PostProcessShader;
|
||||||
|
import net.minecraft.client.gl.ShaderEffect;
|
||||||
|
import net.minecraft.client.gui.screen.ChatScreen;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.client.render.GameRenderer;
|
||||||
|
import net.minecraft.client.resource.ClientResourcePackContainer;
|
||||||
|
import net.minecraft.client.texture.NativeImage;
|
||||||
|
import net.minecraft.resource.*;
|
||||||
|
import net.minecraft.resource.ResourcePackContainer.Factory;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -11,45 +33,14 @@ import java.nio.file.StandardOpenOption;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
public class Blur implements ClientModInitializer {
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.tterrag.blur.mixin.MixinWorldRenderer;
|
|
||||||
import com.tterrag.blur.util.ReflectionHelper;
|
|
||||||
import com.tterrag.blur.util.ShaderResourcePack;
|
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
|
||||||
import net.minecraft.class_279;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.client.gl.GlUniform;
|
|
||||||
import net.minecraft.client.gl.Shader;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
import net.minecraft.client.gui.ingame.ChatGui;
|
|
||||||
import net.minecraft.client.render.WorldRenderer;
|
|
||||||
import net.minecraft.client.resource.ClientResourcePackContainer;
|
|
||||||
import net.minecraft.client.texture.NativeImage;
|
|
||||||
import net.minecraft.resource.ReloadableResourceManager;
|
|
||||||
import net.minecraft.resource.ResourcePackCompatibility;
|
|
||||||
import net.minecraft.resource.ResourcePackContainer;
|
|
||||||
import net.minecraft.resource.ResourcePackContainer.Factory;
|
|
||||||
import net.minecraft.resource.ResourcePackContainer.SortingDirection;
|
|
||||||
import net.minecraft.resource.ResourcePackContainerManager;
|
|
||||||
import net.minecraft.resource.ResourcePackCreator;
|
|
||||||
import net.minecraft.text.StringTextComponent;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
public class Blur implements ModInitializer {
|
|
||||||
|
|
||||||
public static final String MODID = "blur";
|
public static final String MODID = "blur";
|
||||||
public static final String MOD_NAME = "Blur";
|
public static final String MOD_NAME = "Blur";
|
||||||
public static final String VERSION = "@VERSION@";
|
public static final String VERSION = "@VERSION@";
|
||||||
|
|
||||||
static class ConfigJson {
|
static class ConfigJson {
|
||||||
String[] blurExclusions = new String[] { ChatGui.class.getName() };
|
String[] blurExclusions = new String[]{ChatScreen.class.getName()};
|
||||||
int fadeTimeMillis = 200;
|
int fadeTimeMillis = 200;
|
||||||
int radius = 8;
|
int radius = 8;
|
||||||
String gradientStartColor = "75000000";
|
String gradientStartColor = "75000000";
|
||||||
@@ -61,10 +52,9 @@ public class Blur implements ModInitializer {
|
|||||||
|
|
||||||
public ConfigJson configs = new ConfigJson();
|
public ConfigJson configs = new ConfigJson();
|
||||||
public int colorFirst, colorSecond;
|
public int colorFirst, colorSecond;
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private ShaderResourcePack dummyPack = new ShaderResourcePack();
|
private ShaderResourcePack dummyPack = new ShaderResourcePack();
|
||||||
|
|
||||||
public static Blur instance;
|
public static Blur instance;
|
||||||
|
|
||||||
public Blur() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
|
public Blur() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
|
||||||
@@ -75,13 +65,13 @@ public class Blur implements ModInitializer {
|
|||||||
public <T extends ResourcePackContainer> void registerContainer(Map<String, T> var1, Factory<T> factory) {
|
public <T extends ResourcePackContainer> void registerContainer(Map<String, T> var1, Factory<T> factory) {
|
||||||
NativeImage img = null;
|
NativeImage img = null;
|
||||||
try {
|
try {
|
||||||
img = NativeImage.fromInputStream(dummyPack.openRoot("pack.png"));
|
img = NativeImage.read(dummyPack.openRoot("icon.png"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LogManager.getLogger().error("Could not load blur's pack.png", e);
|
LogManager.getLogger().error("Could not load blur's icon.png", e);
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
T var3 = (T) new ClientResourcePackContainer("blur", true, () -> dummyPack, new StringTextComponent(dummyPack.getName()), new StringTextComponent("Default shaders for Blur"),
|
T var3 = (T) new ClientResourcePackContainer("blur", true, () -> dummyPack, new LiteralText(dummyPack.getName()), new LiteralText("Default shaders for Blur"),
|
||||||
ResourcePackCompatibility.COMPATIBLE, SortingDirection.BOTTOM, true, img);
|
ResourcePackCompatibility.COMPATIBLE, ResourcePackContainer.InsertionPosition.BOTTOM, true, img);
|
||||||
if (var3 != null) {
|
if (var3 != null) {
|
||||||
var1.put("blur", var3);
|
var1.put("blur", var3);
|
||||||
}
|
}
|
||||||
@@ -90,9 +80,9 @@ public class Blur implements ModInitializer {
|
|||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitializeClient() {
|
||||||
Path config = MinecraftClient.getInstance().runDirectory.toPath().resolve(Paths.get("config", "blur.cfg"));
|
Path config = MinecraftClient.getInstance().runDirectory.toPath().resolve(Paths.get("config", "blur.cfg"));
|
||||||
File configFile = config.toFile();
|
File configFile = config.toFile();
|
||||||
try {
|
try {
|
||||||
@@ -110,43 +100,43 @@ public class Blur implements ModInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerReloadListeners(ReloadableResourceManager manager) {
|
public void registerReloadListeners(ReloadableResourceManager manager) {
|
||||||
manager.addListener(dummyPack);
|
manager.addPack(dummyPack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGuiChange(Gui newGui) {
|
public void onScreenChange(Screen newGui) {
|
||||||
if (_listShaders == null) {
|
if (_listShaders == null) {
|
||||||
_listShaders = ReflectionHelper.getField(class_279.class, "field_1497");
|
_listShaders = ReflectionHelper.getField(ShaderEffect.class, "field_1497", "passes");
|
||||||
}
|
}
|
||||||
if (MinecraftClient.getInstance().world != null) {
|
if (MinecraftClient.getInstance().world != null) {
|
||||||
WorldRenderer er = MinecraftClient.getInstance().worldRenderer;
|
GameRenderer er = MinecraftClient.getInstance().gameRenderer;
|
||||||
boolean excluded = newGui == null || ArrayUtils.contains(configs.blurExclusions, newGui.getClass().getName());
|
boolean excluded = newGui == null || ArrayUtils.contains(configs.blurExclusions, newGui.getClass().getName());
|
||||||
if (!er.method_3175() && !excluded) {
|
if (!er.isShaderEnabled() && !excluded) {
|
||||||
((MixinWorldRenderer)er).invokeLoadShader(new Identifier("shaders/post/fade_in_blur.json"));
|
((MixinGameRenderer) er).invokeLoadShader(new Identifier("shaders/post/fade_in_blur.json"));
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
} else if (er.method_3175() && excluded) {
|
} else if (er.isShaderEnabled() && excluded) {
|
||||||
er.method_3207();
|
er.disableShader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRadius() {
|
public int getRadius() {
|
||||||
return configs.radius;
|
return configs.radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getProgress() {
|
private float getProgress() {
|
||||||
return Math.min((System.currentTimeMillis() - start) / (float) configs.fadeTimeMillis, 1);
|
return Math.min((System.currentTimeMillis() - start) / (float) configs.fadeTimeMillis, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPostRenderTick() {
|
public void onPostRenderTick() {
|
||||||
if (MinecraftClient.getInstance().currentGui != null && MinecraftClient.getInstance().worldRenderer.method_3175()) {
|
if (MinecraftClient.getInstance().currentScreen != null && MinecraftClient.getInstance().gameRenderer.isShaderEnabled()) {
|
||||||
class_279 sg = MinecraftClient.getInstance().worldRenderer.method_3183();
|
ShaderEffect sg = MinecraftClient.getInstance().gameRenderer.getShader();
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Shader> shaders = (List<Shader>) _listShaders.get(sg);
|
List<PostProcessShader> shaders = (List<PostProcessShader>) _listShaders.get(sg);
|
||||||
for (Shader s : shaders) {
|
for (PostProcessShader s : shaders) {
|
||||||
GlUniform su = s.method_1295().getUniformByName("Progress");
|
GlUniform su = s.getProgram().getUniformByName("Progress");
|
||||||
if (su != null) {
|
if (su != null) {
|
||||||
su.method_1251(getProgress());
|
su.set(getProgress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
@@ -154,7 +144,7 @@ public class Blur implements ModInitializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBackgroundColor(boolean second) {
|
public int getBackgroundColor(boolean second) {
|
||||||
int color = second ? colorSecond : colorFirst;
|
int color = second ? colorSecond : colorFirst;
|
||||||
int a = color >>> 24;
|
int a = color >>> 24;
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package com.tterrag.blur.mixin;
|
package com.tterrag.blur.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.render.GameRenderer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
import net.minecraft.client.render.WorldRenderer;
|
import net.minecraft.client.render.WorldRenderer;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
@Mixin(WorldRenderer.class)
|
@Mixin(GameRenderer.class)
|
||||||
public interface MixinWorldRenderer {
|
public interface MixinGameRenderer {
|
||||||
|
|
||||||
@Invoker
|
@Invoker
|
||||||
void invokeLoadShader(Identifier loc);
|
void invokeLoadShader(Identifier loc);
|
||||||
|
|
||||||
@@ -1,42 +1,40 @@
|
|||||||
package com.tterrag.blur.mixin;
|
package com.tterrag.blur.mixin;
|
||||||
|
|
||||||
|
import com.tterrag.blur.Blur;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
import net.minecraft.resource.ReloadableResourceManager;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At.Shift;
|
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import com.tterrag.blur.Blur;
|
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
import net.minecraft.resource.ReloadableResourceManager;
|
|
||||||
|
|
||||||
@Mixin(MinecraftClient.class)
|
@Mixin(MinecraftClient.class)
|
||||||
public class MixinMinecraftClient {
|
public class MixinMinecraftClient {
|
||||||
|
|
||||||
@Inject(method = "openGui(Lnet/minecraft/client/gui/Gui;)V",
|
@Inject(method = "openScreen",
|
||||||
at = @At(value = "FIELD",
|
at = @At(value = "FIELD",
|
||||||
target = "Lnet/minecraft/client/MinecraftClient;currentGui:Lnet/minecraft/client/gui/Gui;",
|
target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
|
||||||
opcode = Opcodes.PUTFIELD))
|
opcode = Opcodes.PUTFIELD))
|
||||||
public void onGuiOpen(Gui newGui, CallbackInfo info) {
|
public void onScreenOpen(Screen newScreen, CallbackInfo info) {
|
||||||
Blur.instance.onGuiChange(newGui);
|
Blur.instance.onScreenChange(newScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "method_1523(Z)V",
|
@Inject(method = "render",
|
||||||
at = @At(value = "INVOKE",
|
at = @At(value = "INVOKE",
|
||||||
target = "net/minecraft/client/toast/ToastManager.draw()V"),
|
target = "net/minecraft/client/toast/ToastManager.draw()V"),
|
||||||
require = 1)
|
require = 1)
|
||||||
public void onPostRenderTick(CallbackInfo info) {
|
public void onPostRenderTick(CallbackInfo info) {
|
||||||
Blur.instance.onPostRenderTick();
|
Blur.instance.onPostRenderTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "init()V",
|
@Inject(method = "init()V",
|
||||||
at = @At(value = "FIELD",
|
at = @At(value = "FIELD",
|
||||||
target = "Lnet/minecraft/client/MinecraftClient;resourceManager:Lnet/minecraft/resource/ReloadableResourceManager;",
|
target = "Lnet/minecraft/client/MinecraftClient;resourceManager:Lnet/minecraft/resource/ReloadableResourceManager;",
|
||||||
opcode = Opcodes.PUTFIELD,
|
opcode = Opcodes.PUTFIELD,
|
||||||
shift = Shift.AFTER))
|
shift = Shift.AFTER))
|
||||||
public void onResourceManagerAssign(CallbackInfo info) {
|
public void onResourceManagerAssign(CallbackInfo info) {
|
||||||
Blur.instance.registerReloadListeners((ReloadableResourceManager) MinecraftClient.getInstance().getResourceManager());
|
Blur.instance.registerReloadListeners((ReloadableResourceManager) MinecraftClient.getInstance().getResourceManager());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,23 @@
|
|||||||
package com.tterrag.blur.mixin;
|
package com.tterrag.blur.mixin;
|
||||||
|
|
||||||
|
import com.tterrag.blur.Blur;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.Constant;
|
import org.spongepowered.asm.mixin.injection.Constant;
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||||
|
|
||||||
import com.tterrag.blur.Blur;
|
@Mixin(Screen.class)
|
||||||
|
public class MixinScreen {
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
|
|
||||||
@Mixin(Gui.class)
|
|
||||||
public class MixinGui {
|
|
||||||
|
|
||||||
@ModifyConstant(
|
@ModifyConstant(
|
||||||
method = "drawBackground(I)V",
|
method = "renderBackground(I)V",
|
||||||
constant = @Constant(intValue = -1072689136))
|
constant = @Constant(intValue = -1072689136))
|
||||||
public int getFirstBackgroundColor(int color) {
|
public int getFirstBackgroundColor(int color) {
|
||||||
return Blur.instance.getBackgroundColor(false);
|
return Blur.instance.getBackgroundColor(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyConstant(
|
@ModifyConstant(
|
||||||
method = "drawBackground(I)V",
|
method = "renderBackground(I)V",
|
||||||
constant = @Constant(intValue = -804253680))
|
constant = @Constant(intValue = -804253680))
|
||||||
public int getSecondBackgroundColor(int color) {
|
public int getSecondBackgroundColor(int color) {
|
||||||
return Blur.instance.getBackgroundColor(true);
|
return Blur.instance.getBackgroundColor(true);
|
||||||
@@ -1,40 +1,37 @@
|
|||||||
package com.tterrag.blur.util;
|
package com.tterrag.blur.util;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.tterrag.blur.Blur;
|
import com.tterrag.blur.Blur;
|
||||||
|
|
||||||
import net.minecraft.resource.ResourceManager;
|
import net.minecraft.resource.ResourceManager;
|
||||||
import net.minecraft.resource.ResourcePack;
|
import net.minecraft.resource.ResourcePack;
|
||||||
import net.minecraft.resource.ResourceReloadListener;
|
import net.minecraft.resource.ResourceReloadListener;
|
||||||
import net.minecraft.resource.ResourceType;
|
import net.minecraft.resource.ResourceType;
|
||||||
import net.minecraft.resource.metadata.PackResourceMetadata;
|
import net.minecraft.resource.metadata.PackResourceMetadata;
|
||||||
import net.minecraft.resource.metadata.ResourceMetadataReader;
|
import net.minecraft.resource.metadata.ResourceMetadataReader;
|
||||||
import net.minecraft.text.StringTextComponent;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.profiler.Profiler;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class ShaderResourcePack implements ResourcePack, ResourceReloadListener {
|
public class ShaderResourcePack implements ResourcePack, ResourceReloadListener {
|
||||||
|
|
||||||
protected boolean validPath(Identifier location) {
|
protected boolean validPath(Identifier location) {
|
||||||
return location.getNamespace().equals("minecraft") && location.getPath().startsWith("shaders/");
|
return location.getNamespace().equals("minecraft") && location.getPath().startsWith("shaders/");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<Identifier, String> loadedData = new HashMap<>();
|
private final Map<Identifier, String> loadedData = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream open(ResourceType type, Identifier location) throws IOException {
|
public InputStream open(ResourceType type, Identifier location) throws IOException {
|
||||||
if (type == ResourceType.ASSETS && validPath(location)) {
|
if (type == ResourceType.CLIENT_RESOURCES && validPath(location)) {
|
||||||
String s = loadedData.computeIfAbsent(location, loc -> {
|
String s = loadedData.computeIfAbsent(location, loc -> {
|
||||||
InputStream in = Blur.class.getResourceAsStream("/" + location.getPath());
|
InputStream in = Blur.class.getResourceAsStream("/" + location.getPath());
|
||||||
StringBuilder data = new StringBuilder();
|
StringBuilder data = new StringBuilder();
|
||||||
@@ -56,7 +53,7 @@ public class ShaderResourcePack implements ResourcePack, ResourceReloadListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(ResourceType type, Identifier location) {
|
public boolean contains(ResourceType type, Identifier location) {
|
||||||
return type == ResourceType.ASSETS && validPath(location) && Blur.class.getResource("/" + location.getPath()) != null;
|
return type == ResourceType.CLIENT_RESOURCES && validPath(location) && Blur.class.getResource("/" + location.getPath()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -64,11 +61,11 @@ public class ShaderResourcePack implements ResourcePack, ResourceReloadListener
|
|||||||
return ImmutableSet.of("minecraft");
|
return ImmutableSet.of("minecraft");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "null" })
|
@SuppressWarnings({"unchecked", "null"})
|
||||||
@Override
|
@Override
|
||||||
public <T> T parseMetadata(ResourceMetadataReader<T> var1) throws IOException {
|
public <T> T parseMetadata(ResourceMetadataReader<T> var1) throws IOException {
|
||||||
if ("pack".equals(var1.getKey())) {
|
if ("pack".equals(var1.getKey())) {
|
||||||
return (T) new PackResourceMetadata(new StringTextComponent("Blur's default shaders"), 4);
|
return (T) new PackResourceMetadata(new LiteralText("Blur's default shaders"), 4);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -77,14 +74,15 @@ public class ShaderResourcePack implements ResourcePack, ResourceReloadListener
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return "Blur Shaders";
|
return "Blur Shaders";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResourceReload(ResourceManager resourceManager) {
|
public CompletableFuture<Void> reload(Synchronizer var1, ResourceManager var2, Profiler var3, Profiler var4, Executor var5, Executor var6) {
|
||||||
loadedData.clear();
|
return new CompletableFuture<>().thenRun(loadedData::clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {}
|
public void close() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream openRoot(String var1) throws IOException {
|
public InputStream openRoot(String var1) throws IOException {
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 182 KiB |
@@ -1 +0,0 @@
|
|||||||
blur.config.title=Blur Config
|
|
||||||
3
src/main/resources/assets/blur/lang/en_us.json
Normal file
3
src/main/resources/assets/blur/lang/en_us.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"blur.config.title": "Blur Config"
|
||||||
|
}
|
||||||
@@ -1,10 +1,28 @@
|
|||||||
{
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
"id": "blur",
|
"id": "blur",
|
||||||
"name": "Blur",
|
"name": "Blur",
|
||||||
"version": "1.0.0",
|
"version": "$version",
|
||||||
"side": "client",
|
"environment": "client",
|
||||||
"initializer": "com.tterrag.blur.Blur",
|
"license": "MIT",
|
||||||
"mixins": {
|
"icon": "assets/blur/icon.png",
|
||||||
"client": "blur.client.json"
|
"entrypoints": {
|
||||||
|
"client": [
|
||||||
|
"com.tterrag.blur.Blur"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"contact": {
|
||||||
|
"homepage": "https://minecraft.curseforge.com/projects/blur",
|
||||||
|
"issues": "https://github.com/tterrag1098/Blur/issues"
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
"tterrag1098"
|
||||||
|
],
|
||||||
|
"description": "Modifies the background behind Minecraft GUIs to have a blur effect",
|
||||||
|
"mixins": [
|
||||||
|
"mixins.blur.json"
|
||||||
|
],
|
||||||
|
"custom": {
|
||||||
|
"modmenu:clientsideOnly": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"package": "com.tterrag.blur.mixin",
|
"package": "com.tterrag.blur.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"mixins": [
|
"client": [
|
||||||
"MixinGui",
|
"MixinScreen",
|
||||||
"MixinMinecraftClient",
|
"MixinMinecraftClient",
|
||||||
"MixinWorldRenderer"
|
"MixinGameRenderer"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
Reference in New Issue
Block a user