From 0bbfb60d0cab015a7e83c7a8abcf2eb2ead19495 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Tue, 12 Oct 2021 12:52:02 -0700 Subject: [PATCH] Compat work - No more net.minecraftforge.common.util usages - Replace forge lazy with flywheel lazy - Replace forge NonNullSupplier with flywheel NonNullSupplier - texture2D -> texture --- .../flywheel/backend/struct/BasicStructType.java | 3 +-- .../java/com/jozufozu/flywheel/core/FullscreenQuad.java | 3 +-- .../java/com/jozufozu/flywheel/core/model/ModelUtil.java | 2 +- src/main/java/com/jozufozu/flywheel/util/Lazy.java | 2 -- .../java/com/jozufozu/flywheel/util/NonNullSupplier.java | 9 +++++++++ .../flywheel/flywheel/shaders/context/crumbling.glsl | 4 ++-- .../assets/flywheel/flywheel/shaders/context/world.glsl | 4 ++-- 7 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/jozufozu/flywheel/util/NonNullSupplier.java diff --git a/src/main/java/com/jozufozu/flywheel/backend/struct/BasicStructType.java b/src/main/java/com/jozufozu/flywheel/backend/struct/BasicStructType.java index 0562804aa..eaa9eaa3d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/struct/BasicStructType.java +++ b/src/main/java/com/jozufozu/flywheel/backend/struct/BasicStructType.java @@ -3,8 +3,7 @@ package com.jozufozu.flywheel.backend.struct; import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; - -import net.minecraftforge.common.util.NonNullSupplier; +import com.jozufozu.flywheel.util.NonNullSupplier; public class BasicStructType implements StructType { diff --git a/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java b/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java index ea78c2982..19245df4f 100644 --- a/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java +++ b/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java @@ -7,8 +7,7 @@ import com.jozufozu.flywheel.backend.gl.GlVertexArray; import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; import com.jozufozu.flywheel.backend.gl.buffer.MappedGlBuffer; - -import net.minecraftforge.common.util.Lazy; +import com.jozufozu.flywheel.util.Lazy; public class FullscreenQuad { diff --git a/src/main/java/com/jozufozu/flywheel/core/model/ModelUtil.java b/src/main/java/com/jozufozu/flywheel/core/model/ModelUtil.java index bd35ed0d2..824706512 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/ModelUtil.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/ModelUtil.java @@ -6,6 +6,7 @@ import static org.lwjgl.opengl.GL11.GL_QUADS; import java.util.Collection; import java.util.Random; +import com.jozufozu.flywheel.util.Lazy; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.world.level.block.RenderShape; @@ -23,7 +24,6 @@ import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.model.data.EmptyModelData; -import net.minecraftforge.common.util.Lazy; public class ModelUtil { private static final Lazy MODEL_RENDERER = Lazy.of(() -> new ModelBlockRenderer(Minecraft.getInstance().getBlockColors())); diff --git a/src/main/java/com/jozufozu/flywheel/util/Lazy.java b/src/main/java/com/jozufozu/flywheel/util/Lazy.java index 6bcbd9d23..a50c84361 100644 --- a/src/main/java/com/jozufozu/flywheel/util/Lazy.java +++ b/src/main/java/com/jozufozu/flywheel/util/Lazy.java @@ -4,8 +4,6 @@ import java.util.function.Consumer; import javax.annotation.Nonnull; -import net.minecraftforge.common.util.NonNullSupplier; - public class Lazy { private final NonNullSupplier supplier; diff --git a/src/main/java/com/jozufozu/flywheel/util/NonNullSupplier.java b/src/main/java/com/jozufozu/flywheel/util/NonNullSupplier.java new file mode 100644 index 000000000..e54ebcdc2 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/util/NonNullSupplier.java @@ -0,0 +1,9 @@ +package com.jozufozu.flywheel.util; + +import javax.annotation.Nonnull; + +@FunctionalInterface +public interface NonNullSupplier { + + @Nonnull T get(); +} diff --git a/src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling.glsl index 1535dc2ed..d55e86289 100644 --- a/src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling.glsl +++ b/src/main/resources/assets/flywheel/flywheel/shaders/context/crumbling.glsl @@ -29,8 +29,8 @@ void FLWFinalizeWorldPos(inout vec4 worldPos) { out vec4 fragColor; vec4 FLWBlockTexture(vec2 texCoords) { - vec4 cr = texture2D(uCrumbling, texCoords * uTextureScale); - float diffuseAlpha = texture2D(uBlockAtlas, texCoords).a; + vec4 cr = texture(uCrumbling, texCoords * uTextureScale); + float diffuseAlpha = texture(uBlockAtlas, texCoords).a; cr.a = cr.a * diffuseAlpha; return cr; } diff --git a/src/main/resources/assets/flywheel/flywheel/shaders/context/world.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/context/world.glsl index 9da66a38c..f6f94ebf2 100644 --- a/src/main/resources/assets/flywheel/flywheel/shaders/context/world.glsl +++ b/src/main/resources/assets/flywheel/flywheel/shaders/context/world.glsl @@ -37,7 +37,7 @@ void FLWFinalizeWorldPos(inout vec4 worldPos) { out vec4 fragColor; vec4 FLWBlockTexture(vec2 texCoords) { - return texture2D(uBlockAtlas, texCoords); + return texture(uBlockAtlas, texCoords); } void FLWFinalizeColor(vec4 color) { @@ -59,6 +59,6 @@ void FLWFinalizeColor(vec4 color) { } vec4 FLWLight(vec2 lightCoords) { - return texture2D(uLightMap, shiftLight(lightCoords)); + return texture(uLightMap, shiftLight(lightCoords)); } #endif