Common and version specific shader packages #10

Merged
embeddedt merged 24 commits from mitchej123/celeritas:common-shaders-and-enhancements into stonecutter 2025-03-31 19:52:28 -04:00
46 changed files with 374 additions and 198 deletions
Showing only changes of commit d2c0e11ed9 - Show all commits

No files matched your search

@@ -4,7 +4,7 @@ import net.irisshaders.iris.texture.mipmap.ChannelMipmapGenerator;
import net.irisshaders.iris.texture.mipmap.CustomMipmapGenerator; import net.irisshaders.iris.texture.mipmap.CustomMipmapGenerator;
import net.irisshaders.iris.texture.mipmap.DiscreteBlendFunction; import net.irisshaders.iris.texture.mipmap.DiscreteBlendFunction;
import net.irisshaders.iris.texture.mipmap.LinearBlendFunction; import net.irisshaders.iris.texture.mipmap.LinearBlendFunction;
import net.irisshaders.iris.texture.pbr.PBRType; import net.irisshaders.iris.texture.prb.PBRType;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Objects; import java.util.Objects;
@@ -2,8 +2,8 @@ package net.irisshaders.iris.texture.format;
import net.irisshaders.iris.gl.IrisRenderSystem; import net.irisshaders.iris.gl.IrisRenderSystem;
import net.irisshaders.iris.texture.mipmap.CustomMipmapGenerator; import net.irisshaders.iris.texture.mipmap.CustomMipmapGenerator;
import net.irisshaders.iris.texture.pbr.PBRType; import net.irisshaders.iris.texture.prb.PBRType;
embeddedt marked this conversation as resolved Outdated
Outdated
Review

Um..

Um..
import net.minecraft.client.renderer.texture.AbstractTexture; import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -44,7 +44,7 @@ public interface TextureFormat {
*/ */
boolean canInterpolateValues(PBRType pbrType); boolean canInterpolateValues(PBRType pbrType);
default void setupTextureParameters(PBRType pbrType, AbstractTexture texture) { default void setupTextureParameters(PBRType pbrType, MCAbstractTexture texture) {
if (!canInterpolateValues(pbrType)) { if (!canInterpolateValues(pbrType)) {
int minFilter = IrisRenderSystem.getTexParameteri(texture.getId(), GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER); int minFilter = IrisRenderSystem.getTexParameteri(texture.getId(), GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER);
// Non-mipped filters begin at 0x2600 whereas mipped filters begin at 0x2700, // Non-mipped filters begin at 0x2600 whereas mipped filters begin at 0x2700,
@@ -1,10 +1,8 @@
package net.irisshaders.iris.texture.format; package net.irisshaders.iris.texture.format;
import net.irisshaders.iris.Iris; import org.embeddedt.embeddium.compat.mc.IResource;
import net.minecraft.resources.ResourceLocation; import org.embeddedt.embeddium.compat.mc.IResourceLocation;
import net.minecraft.server.packs.resources.Resource; import org.embeddedt.embeddium.compat.mc.IResourceProvider;
import net.minecraft.server.packs.resources.ResourceManager;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@@ -14,8 +12,11 @@ import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.Properties; import java.util.Properties;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class TextureFormatLoader { public class TextureFormatLoader {
public static final ResourceLocation LOCATION = ResourceLocationUtil.make("optifine/texture.properties"); public static final IResourceLocation LOCATION = MINECRAFT_SHIM.makeResourceLocation("optifine/texture.properties");
private static TextureFormat format; private static TextureFormat format;
@@ -24,7 +25,7 @@ public class TextureFormatLoader {
return format; return format;
} }
public static void reload(ResourceManager resourceManager) { public static void reload(IResourceProvider resourceManager) {
TextureFormat newFormat = loadFormat(resourceManager); TextureFormat newFormat = loadFormat(resourceManager);
boolean didFormatChange = !Objects.equals(format, newFormat); boolean didFormatChange = !Objects.equals(format, newFormat);
format = newFormat; format = newFormat;
@@ -34,8 +35,8 @@ public class TextureFormatLoader {
} }
@Nullable @Nullable
private static TextureFormat loadFormat(ResourceManager resourceManager) { private static TextureFormat loadFormat(IResourceProvider resourceManager) {
Optional<Resource> resource = resourceManager.getResource(LOCATION); Optional<IResource> resource = resourceManager.getResource((IResourceLocation)(Object)LOCATION);
if (resource.isPresent()) { if (resource.isPresent()) {
try (InputStream stream = resource.get().open()) { try (InputStream stream = resource.get().open()) {
Properties properties = new Properties(); Properties properties = new Properties();
@@ -55,14 +56,14 @@ public class TextureFormatLoader {
} }
return factory.createFormat(name, version); return factory.createFormat(name, version);
} else { } else {
Iris.logger.warn("Invalid texture format '" + name + "' in file '" + LOCATION + "'"); IRIS_LOGGER.warn("Invalid texture format '" + name + "' in file '" + LOCATION + "'");
} }
} }
} }
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// //
} catch (Exception e) { } catch (Exception e) {
Iris.logger.error("Failed to load texture format from file '" + LOCATION + "'", e); IRIS_LOGGER.error("Failed to load texture format from file '" + LOCATION + "'", e);
} }
} }
return null; return null;
@@ -70,7 +71,7 @@ public class TextureFormatLoader {
private static void onFormatChange() { private static void onFormatChange() {
try { try {
Iris.reload(); MINECRAFT_SHIM.reloadIris();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -1,20 +1,22 @@
package net.irisshaders.iris.texture.mipmap; package net.irisshaders.iris.texture.mipmap;
import com.mojang.blaze3d.platform.NativeImage; import org.embeddedt.embeddium.compat.mc.MCNativeImage;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public abstract class AbstractMipmapGenerator implements CustomMipmapGenerator { public abstract class AbstractMipmapGenerator implements CustomMipmapGenerator {
@Override @Override
public NativeImage[] generateMipLevels(NativeImage[] image, int mipLevel) { public MCNativeImage[] generateMipLevels(MCNativeImage[] image, int mipLevel) {
if (mipLevel + 1 <= image.length) { if (mipLevel + 1 <= image.length) {
return image; return image;
} }
NativeImage[] newImages = new NativeImage[mipLevel + 1]; MCNativeImage[] newImages = MINECRAFT_SHIM.createNativeImageArray(mipLevel + 1);
if (mipLevel > 0) { if (mipLevel > 0) {
for (int level = 1; level <= mipLevel; ++level) { for (int level = 1; level <= mipLevel; ++level) {
NativeImage prevMipmap = level == 1 ? image[0] : newImages[level - 1]; MCNativeImage prevMipmap = level == 1 ? image[0] : newImages[level - 1];
NativeImage mipmap = new NativeImage(prevMipmap.getWidth() >> 1, prevMipmap.getHeight() >> 1, false); MCNativeImage mipmap = MINECRAFT_SHIM.createNativeImage(prevMipmap.getWidth() >> 1, prevMipmap.getHeight() >> 1, false);
int width = mipmap.getWidth(); int width = mipmap.getWidth();
int height = mipmap.getHeight(); int height = mipmap.getHeight();
for (int x = 0; x < width; ++x) { for (int x = 0; x < width; ++x) {
@@ -1,6 +1,6 @@
package net.irisshaders.iris.texture.mipmap; package net.irisshaders.iris.texture.mipmap;
import net.minecraft.util.FastColor; import static org.embeddedt.embeddium.compat.mc.ABGR32Service.ABGR32;
public class ChannelMipmapGenerator extends AbstractMipmapGenerator { public class ChannelMipmapGenerator extends AbstractMipmapGenerator {
protected final BlendFunction redFunc; protected final BlendFunction redFunc;
@@ -17,30 +17,30 @@ public class ChannelMipmapGenerator extends AbstractMipmapGenerator {
@Override @Override
public int blend(int c0, int c1, int c2, int c3) { public int blend(int c0, int c1, int c2, int c3) {
return FastColor.ABGR32.color( return ABGR32.color(
alphaFunc.blend( alphaFunc.blend(
FastColor.ABGR32.alpha(c0), ABGR32.alpha(c0),
FastColor.ABGR32.alpha(c1), ABGR32.alpha(c1),
FastColor.ABGR32.alpha(c2), ABGR32.alpha(c2),
FastColor.ABGR32.alpha(c3) ABGR32.alpha(c3)
), ),
blueFunc.blend( blueFunc.blend(
FastColor.ABGR32.blue(c0), ABGR32.blue(c0),
FastColor.ABGR32.blue(c1), ABGR32.blue(c1),
FastColor.ABGR32.blue(c2), ABGR32.blue(c2),
FastColor.ABGR32.blue(c3) ABGR32.blue(c3)
), ),
greenFunc.blend( greenFunc.blend(
FastColor.ABGR32.green(c0), ABGR32.green(c0),
FastColor.ABGR32.green(c1), ABGR32.green(c1),
FastColor.ABGR32.green(c2), ABGR32.green(c2),
FastColor.ABGR32.green(c3) ABGR32.green(c3)
), ),
redFunc.blend( redFunc.blend(
FastColor.ABGR32.red(c0), ABGR32.red(c0),
FastColor.ABGR32.red(c1), ABGR32.red(c1),
FastColor.ABGR32.red(c2), ABGR32.red(c2),
FastColor.ABGR32.red(c3) ABGR32.red(c3)
) )
); );
} }
@@ -1,10 +1,10 @@
package net.irisshaders.iris.texture.mipmap; package net.irisshaders.iris.texture.mipmap;
import com.mojang.blaze3d.platform.NativeImage; import org.embeddedt.embeddium.compat.mc.MCNativeImage;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public interface CustomMipmapGenerator { public interface CustomMipmapGenerator {
NativeImage[] generateMipLevels(NativeImage[] image, int mipLevel); MCNativeImage[] generateMipLevels(MCNativeImage[] image, int mipLevel);
interface Provider { interface Provider {
@Nullable @Nullable
@@ -1,4 +1,4 @@
package net.irisshaders.iris.texture.pbr; package net.irisshaders.iris.texture.prb;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -0,0 +1,17 @@
package org.embeddedt.embeddium.compat.mc;
import java.util.ServiceLoader;
public interface ABGR32Service {
embeddedt marked this conversation as resolved Outdated
Outdated
Review

As mentioned in an earlier comment, this is redundant, we have some common color utilities already.

As mentioned in an earlier comment, this is redundant, we have some common color utilities already.
ABGR32Service ABGR32 = ServiceLoader.load(ABGR32Service.class).findFirst().orElseThrow();
int alpha(int packedColor);
int red(int packedColor);
int green(int packedColor);
int blue(int packedColor);
int transparent(int packedColor);
int opaque(int packedColor);
int color(int alpha, int red, int green, int blue);
int color(int alpha, int packedColor);
}
@@ -0,0 +1,8 @@
package org.embeddedt.embeddium.compat.mc;
import java.io.IOException;
import java.io.InputStream;
public interface IResource {
InputStream open() throws IOException;
}
@@ -0,0 +1,4 @@
package org.embeddedt.embeddium.compat.mc;
public interface IResourceLocation {
}
@@ -0,0 +1,7 @@
package org.embeddedt.embeddium.compat.mc;
import java.util.Optional;
public interface IResourceProvider {
Optional<IResource> getResource(IResourceLocation location);
}
@@ -0,0 +1,8 @@
package org.embeddedt.embeddium.compat.mc;
public interface MCAbstractTexture {
int getId();
int releaseId();
void bind();
void close();
}
@@ -0,0 +1,9 @@
package org.embeddedt.embeddium.compat.mc;
public interface MCNativeImage {
int getWidth();
int getHeight();
void setPixelRGBA(int x, int y, int color);
int getPixelRGBA(int x, int y);
long getPointer();
}
@@ -4,6 +4,7 @@ import org.joml.Matrix4f;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector4f; import org.joml.Vector4f;
import java.io.IOException;
import java.util.ServiceLoader; import java.util.ServiceLoader;
/** /**
@@ -73,4 +74,13 @@ public interface MinecraftVersionShimService {
boolean isFirstPersonCamera(); boolean isFirstPersonCamera();
boolean isSpectator(); boolean isSpectator();
Vector3d getEyePosition(); Vector3d getEyePosition();
MCNativeImage createNativeImage(int width, int height, boolean useCalloc);
MCNativeImage[] createNativeImageArray(int size);
IResourceLocation makeResourceLocation(String namespace, String path);
IResourceLocation makeResourceLocation(String str);
// TODO(mitchej123): Does this belong here?
void reloadIris() throws IOException;
} }
@@ -3,21 +3,22 @@ package org.embeddedt.embeddium.api.options.structure;
import org.embeddedt.embeddium.api.options.OptionIdentifier; import org.embeddedt.embeddium.api.options.OptionIdentifier;
import org.embeddedt.embeddium.impl.Celeritas; import org.embeddedt.embeddium.impl.Celeritas;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public final class StandardOptions { public final class StandardOptions {
public static class Group { public static class Group {
public static final ResourceLocation RENDERING = ResourceLocationUtil.make("minecraft", "rendering"); public static final ResourceLocation RENDERING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "rendering");
public static final ResourceLocation WINDOW = ResourceLocationUtil.make("minecraft", "window"); public static final ResourceLocation WINDOW = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "window");
public static final ResourceLocation INDICATORS = ResourceLocationUtil.make("minecraft", "indicators"); public static final ResourceLocation INDICATORS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "indicators");
public static final ResourceLocation GRAPHICS = ResourceLocationUtil.make("minecraft", "graphics"); public static final ResourceLocation GRAPHICS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "graphics");
public static final ResourceLocation MIPMAPS = ResourceLocationUtil.make("minecraft", "mipmaps"); public static final ResourceLocation MIPMAPS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "mipmaps");
public static final ResourceLocation DETAILS = ResourceLocationUtil.make("minecraft", "details"); public static final ResourceLocation DETAILS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "details");
public static final ResourceLocation CHUNK_UPDATES = ResourceLocationUtil.make(Celeritas.MODID, "chunk_updates"); public static final ResourceLocation CHUNK_UPDATES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "chunk_updates");
public static final ResourceLocation RENDERING_CULLING = ResourceLocationUtil.make(Celeritas.MODID, "rendering_culling"); public static final ResourceLocation RENDERING_CULLING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "rendering_culling");
public static final ResourceLocation CPU_SAVING = ResourceLocationUtil.make(Celeritas.MODID, "cpu_saving"); public static final ResourceLocation CPU_SAVING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "cpu_saving");
public static final ResourceLocation SORTING = ResourceLocationUtil.make(Celeritas.MODID, "sorting"); public static final ResourceLocation SORTING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "sorting");
public static final ResourceLocation LIGHTING = ResourceLocationUtil.make(Celeritas.MODID, "lighting"); public static final ResourceLocation LIGHTING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "lighting");
} }
public static class Pages { public static class Pages {
@@ -29,44 +30,44 @@ public final class StandardOptions {
} }
public static class Option { public static class Option {
public static final ResourceLocation RENDER_DISTANCE = ResourceLocationUtil.make("minecraft", "render_distance"); public static final ResourceLocation RENDER_DISTANCE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "render_distance");
public static final ResourceLocation SIMULATION_DISTANCE = ResourceLocationUtil.make("minecraft", "simulation_distance"); public static final ResourceLocation SIMULATION_DISTANCE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "simulation_distance");
public static final ResourceLocation BRIGHTNESS = ResourceLocationUtil.make("minecraft", "brightness"); public static final ResourceLocation BRIGHTNESS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "brightness");
public static final ResourceLocation GUI_SCALE = ResourceLocationUtil.make("minecraft", "gui_scale"); public static final ResourceLocation GUI_SCALE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "gui_scale");
public static final ResourceLocation FULLSCREEN = ResourceLocationUtil.make("minecraft", "fullscreen"); public static final ResourceLocation FULLSCREEN = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "fullscreen");
public static final ResourceLocation FULLSCREEN_RESOLUTION = ResourceLocationUtil.make("minecraft", "fullscreen_resolution"); public static final ResourceLocation FULLSCREEN_RESOLUTION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "fullscreen_resolution");
public static final ResourceLocation VSYNC = ResourceLocationUtil.make("minecraft", "vsync"); public static final ResourceLocation VSYNC = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "vsync");
public static final ResourceLocation MAX_FRAMERATE = ResourceLocationUtil.make("minecraft", "max_frame_rate"); public static final ResourceLocation MAX_FRAMERATE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "max_frame_rate");
public static final ResourceLocation VIEW_BOBBING = ResourceLocationUtil.make("minecraft", "view_bobbing"); public static final ResourceLocation VIEW_BOBBING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "view_bobbing");
public static final ResourceLocation INACTIVITY_FPS_LIMIT = ResourceLocationUtil.make("minecraft", "inactivity_fps_limit"); public static final ResourceLocation INACTIVITY_FPS_LIMIT = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "inactivity_fps_limit");
public static final ResourceLocation ATTACK_INDICATOR = ResourceLocationUtil.make("minecraft", "attack_indicator"); public static final ResourceLocation ATTACK_INDICATOR = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "attack_indicator");
public static final ResourceLocation AUTOSAVE_INDICATOR = ResourceLocationUtil.make("minecraft", "autosave_indicator"); public static final ResourceLocation AUTOSAVE_INDICATOR = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "autosave_indicator");
public static final ResourceLocation GRAPHICS_MODE = ResourceLocationUtil.make("minecraft", "graphics_mode"); public static final ResourceLocation GRAPHICS_MODE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "graphics_mode");
public static final ResourceLocation CLOUDS = ResourceLocationUtil.make("minecraft", "clouds"); public static final ResourceLocation CLOUDS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "clouds");
public static final ResourceLocation WEATHER = ResourceLocationUtil.make("minecraft", "weather"); public static final ResourceLocation WEATHER = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "weather");
public static final ResourceLocation LEAVES = ResourceLocationUtil.make("minecraft", "leaves"); public static final ResourceLocation LEAVES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "leaves");
public static final ResourceLocation PARTICLES = ResourceLocationUtil.make("minecraft", "particles"); public static final ResourceLocation PARTICLES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "particles");
public static final ResourceLocation SMOOTH_LIGHT = ResourceLocationUtil.make("minecraft", "smooth_lighting"); public static final ResourceLocation SMOOTH_LIGHT = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "smooth_lighting");
public static final ResourceLocation BIOME_BLEND = ResourceLocationUtil.make("minecraft", "biome_blend"); public static final ResourceLocation BIOME_BLEND = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "biome_blend");
public static final ResourceLocation ENTITY_DISTANCE = ResourceLocationUtil.make("minecraft", "entity_distance"); public static final ResourceLocation ENTITY_DISTANCE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "entity_distance");
public static final ResourceLocation ENTITY_SHADOWS = ResourceLocationUtil.make("minecraft", "entity_shadows"); public static final ResourceLocation ENTITY_SHADOWS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "entity_shadows");
public static final ResourceLocation VIGNETTE = ResourceLocationUtil.make("minecraft", "vignette"); public static final ResourceLocation VIGNETTE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "vignette");
public static final ResourceLocation MIPMAP_LEVEL = ResourceLocationUtil.make("minecraft", "mipmap_levels"); public static final ResourceLocation MIPMAP_LEVEL = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "mipmap_levels");
public static final ResourceLocation CHUNK_UPDATE_THREADS = ResourceLocationUtil.make(Celeritas.MODID, "chunk_update_threads"); public static final ResourceLocation CHUNK_UPDATE_THREADS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "chunk_update_threads");
public static final ResourceLocation DEFFER_CHUNK_UPDATES = ResourceLocationUtil.make(Celeritas.MODID, "defer_chunk_updates"); public static final ResourceLocation DEFFER_CHUNK_UPDATES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "defer_chunk_updates");
public static final ResourceLocation BLOCK_FACE_CULLING = ResourceLocationUtil.make(Celeritas.MODID, "block_face_culling"); public static final ResourceLocation BLOCK_FACE_CULLING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "block_face_culling");
public static final ResourceLocation COMPACT_VERTEX_FORMAT = ResourceLocationUtil.make(Celeritas.MODID, "compact_vertex_format"); public static final ResourceLocation COMPACT_VERTEX_FORMAT = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "compact_vertex_format");
public static final ResourceLocation FOG_OCCLUSION = ResourceLocationUtil.make(Celeritas.MODID, "fog_occlusion"); public static final ResourceLocation FOG_OCCLUSION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "fog_occlusion");
public static final ResourceLocation ENTITY_CULLING = ResourceLocationUtil.make(Celeritas.MODID, "entity_culling"); public static final ResourceLocation ENTITY_CULLING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "entity_culling");
public static final ResourceLocation ANIMATE_VISIBLE_TEXTURES = ResourceLocationUtil.make(Celeritas.MODID, "animate_only_visible_textures"); public static final ResourceLocation ANIMATE_VISIBLE_TEXTURES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "animate_only_visible_textures");
public static final ResourceLocation NO_ERROR_CONTEXT = ResourceLocationUtil.make(Celeritas.MODID, "no_error_context"); public static final ResourceLocation NO_ERROR_CONTEXT = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "no_error_context");
public static final ResourceLocation PERSISTENT_MAPPING = ResourceLocationUtil.make(Celeritas.MODID, "persistent_mapping"); public static final ResourceLocation PERSISTENT_MAPPING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "persistent_mapping");
public static final ResourceLocation CPU_FRAMES_AHEAD = ResourceLocationUtil.make(Celeritas.MODID, "cpu_render_ahead_limit"); public static final ResourceLocation CPU_FRAMES_AHEAD = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "cpu_render_ahead_limit");
public static final ResourceLocation TRANSLUCENT_FACE_SORTING = ResourceLocationUtil.make(Celeritas.MODID, "translucent_face_sorting"); public static final ResourceLocation TRANSLUCENT_FACE_SORTING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "translucent_face_sorting");
public static final ResourceLocation USE_QUAD_NORMALS_FOR_LIGHTING = ResourceLocationUtil.make(Celeritas.MODID, "use_quad_normals_for_lighting"); public static final ResourceLocation USE_QUAD_NORMALS_FOR_LIGHTING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "use_quad_normals_for_lighting");
public static final ResourceLocation RENDER_PASS_OPTIMIZATION = ResourceLocationUtil.make(Celeritas.MODID, "render_pass_optimization"); public static final ResourceLocation RENDER_PASS_OPTIMIZATION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "render_pass_optimization");
public static final ResourceLocation RENDER_PASS_CONSOLIDATION = ResourceLocationUtil.make(Celeritas.MODID, "render_pass_consolidation"); public static final ResourceLocation RENDER_PASS_CONSOLIDATION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "render_pass_consolidation");
public static final ResourceLocation USE_FASTER_CLOUDS = ResourceLocationUtil.make(Celeritas.MODID, "use_faster_clouds"); public static final ResourceLocation USE_FASTER_CLOUDS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "use_faster_clouds");
public static final ResourceLocation ASYNC_GRAPH_SEARCH = ResourceLocationUtil.make(Celeritas.MODID, "async_graph_search"); public static final ResourceLocation ASYNC_GRAPH_SEARCH = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "async_graph_search");
} }
} }
@@ -1,21 +1,20 @@
package org.embeddedt.embeddium.impl.gui.frame.tab; package org.embeddedt.embeddium.impl.gui.frame.tab;
//? if >=1.20 //? if >=1.20
import net.minecraft.client.renderer.RenderType;
import org.embeddedt.embeddium.impl.gui.widgets.FlatButtonWidget; import org.embeddedt.embeddium.impl.gui.widgets.FlatButtonWidget;
import org.embeddedt.embeddium.impl.loader.common.ModLogoUtil; import org.embeddedt.embeddium.impl.loader.common.ModLogoUtil;
import org.embeddedt.embeddium.impl.util.ComponentUtil;
import org.embeddedt.embeddium.impl.util.Dim2i; import org.embeddedt.embeddium.impl.util.Dim2i;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
//$ guigfx //$ guigfx
import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import java.util.Objects; import java.util.Objects;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class TabHeaderWidget extends FlatButtonWidget { public class TabHeaderWidget extends FlatButtonWidget {
private static final ResourceLocation FALLBACK_LOCATION = ResourceLocationUtil.make("textures/misc/unknown_pack.png"); private static final ResourceLocation FALLBACK_LOCATION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("textures/misc/unknown_pack.png");
private final ResourceLocation logoTexture; private final ResourceLocation logoTexture;
@@ -12,7 +12,6 @@ import net.minecraftforge.fml.ModList;
//? if neoforge //? if neoforge
/*import net.neoforged.fml.ModList;*/ /*import net.neoforged.fml.ModList;*/
import org.embeddedt.embeddium.impl.Celeritas; import org.embeddedt.embeddium.impl.Celeritas;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -22,6 +21,8 @@ import java.util.HashSet;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class ModLogoUtil { public class ModLogoUtil {
private static final Set<String> erroredLogos = new HashSet<>(); private static final Set<String> erroredLogos = new HashSet<>();
@@ -69,7 +70,7 @@ public class ModLogoUtil {
logo.close(); logo.close();
throw new IOException("Logo for " + modId + " is not square"); throw new IOException("Logo for " + modId + " is not square");
} }
ResourceLocation texture = ResourceLocationUtil.make(Celeritas.MODID, "logo/" + modId); ResourceLocation texture = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "logo/" + modId);
Minecraft.getInstance().getTextureManager().register(texture, new DynamicTexture( Minecraft.getInstance().getTextureManager().register(texture, new DynamicTexture(
//? if >=1.21.5-alpha.25.7.a //? if >=1.21.5-alpha.25.7.a
/*() -> modId + " logo",*/ /*() -> modId + " logo",*/
@@ -5,7 +5,6 @@ import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*; import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.renderer.RenderType;
import org.embeddedt.embeddium.api.util.ColorABGR; import org.embeddedt.embeddium.api.util.ColorABGR;
import org.embeddedt.embeddium.api.util.ColorARGB; import org.embeddedt.embeddium.api.util.ColorARGB;
import org.embeddedt.embeddium.api.util.ColorMixer; import org.embeddedt.embeddium.api.util.ColorMixer;
@@ -19,24 +18,23 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.ResourceProvider; import net.minecraft.server.packs.resources.ResourceProvider;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.embeddedt.embeddium.api.render.clouds.ModifyCloudRenderingEvent; import org.embeddedt.embeddium.api.render.clouds.ModifyCloudRenderingEvent;
import org.embeddedt.embeddium.api.vertex.format.common.LineVertex; import org.embeddedt.embeddium.api.vertex.format.common.LineVertex;
import org.embeddedt.embeddium.impl.render.ShaderModBridge; import org.embeddedt.embeddium.impl.render.ShaderModBridge;
import org.embeddedt.embeddium.impl.render.CeleritasWorldRenderer; import org.embeddedt.embeddium.impl.render.CeleritasWorldRenderer;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Vector3f;
import org.lwjgl.opengl.GL30C; import org.lwjgl.opengl.GL30C;
import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryStack;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class CloudRenderer { public class CloudRenderer {
private static final ResourceLocation CLOUDS_TEXTURE_ID = ResourceLocationUtil.make("textures/environment/clouds.png"); private static final ResourceLocation CLOUDS_TEXTURE_ID = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("textures/environment/clouds.png");
private static final int CLOUD_COLOR_NEG_Y = ColorABGR.pack(0.7F, 0.7F, 0.7F, 1.0f); private static final int CLOUD_COLOR_NEG_Y = ColorABGR.pack(0.7F, 0.7F, 0.7F, 1.0f);
private static final int CLOUD_COLOR_POS_Y = ColorABGR.pack(1.0f, 1.0f, 1.0f, 1.0f); private static final int CLOUD_COLOR_POS_Y = ColorABGR.pack(1.0f, 1.0f, 1.0f, 1.0f);
@@ -1,6 +1,7 @@
package org.embeddedt.embeddium.impl.tags; package org.embeddedt.embeddium.impl.tags;
//? if >=1.18 { //? if >=1.18 {
import net.minecraft.resources.ResourceLocation;
import org.embeddedt.embeddium.impl.Celeritas; import org.embeddedt.embeddium.impl.Celeritas;
//? if >=1.20 { //? if >=1.20 {
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
@@ -8,7 +9,8 @@ import net.minecraft.core.registries.Registries;
/*import net.minecraft.core.Registry;*/ /*import net.minecraft.core.Registry;*/
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluid;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class EmbeddiumTags { public class EmbeddiumTags {
public static final TagKey<Fluid> RENDERS_WITH_VANILLA = TagKey.create( public static final TagKey<Fluid> RENDERS_WITH_VANILLA = TagKey.create(
@@ -16,6 +18,6 @@ public class EmbeddiumTags {
/*Registry.FLUID_REGISTRY, /*Registry.FLUID_REGISTRY,
*///?} else *///?} else
Registries.FLUID, Registries.FLUID,
ResourceLocationUtil.make(Celeritas.MODID, "is_vanilla_rendered_fluid")); (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "is_vanilla_rendered_fluid"));
} }
//?} //?}
@@ -1,23 +0,0 @@
package org.embeddedt.embeddium.impl.util;
import net.minecraft.resources.ResourceLocation;
public class ResourceLocationUtil {
public static ResourceLocation make(String namespace, String path) {
//? if >=1.21
/*return ResourceLocation.fromNamespaceAndPath(namespace, path);*/
//? if <1.21
return new ResourceLocation(namespace, path);
}
public static ResourceLocation make(String str) {
//? if >=1.21 {
/*if(str.contains(":")) {
return ResourceLocation.parse(str);
} else {
return ResourceLocation.withDefaultNamespace(str);
}
*///?} else
return new ResourceLocation(str);
}
}
@@ -1,6 +1,7 @@
package net.irisshaders.iris.gui; package net.irisshaders.iris.gui;
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM; import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -13,7 +14,6 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
/** /**
* Class serving as abstraction and * Class serving as abstraction and
@@ -25,7 +25,7 @@ import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
* some code that will be changed. * some code that will be changed.
*/ */
public final class GuiUtil { public final class GuiUtil {
public static final ResourceLocation IRIS_WIDGETS_TEX = ResourceLocationUtil.make("iris", "textures/gui/widgets.png"); public static final ResourceLocation IRIS_WIDGETS_TEX = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("iris", "textures/gui/widgets.png");
private static final Component ELLIPSIS = Component.literal("..."); private static final Component ELLIPSIS = Component.literal("...");
private GuiUtil() { private GuiUtil() {
@@ -0,0 +1,9 @@
package net.irisshaders.iris.mixin;
import com.mojang.blaze3d.platform.NativeImage;
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(NativeImage.class)
public abstract class MixinNativeImage implements MCNativeImage {
}
@@ -0,0 +1,9 @@
package net.irisshaders.iris.mixin;
import net.minecraft.server.packs.resources.Resource;
import org.embeddedt.embeddium.compat.mc.IResource;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(Resource.class)
public abstract class MixinResource implements IResource {
}
@@ -0,0 +1,9 @@
package net.irisshaders.iris.mixin;
import net.minecraft.resources.ResourceLocation;
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(ResourceLocation.class)
public abstract class MixinResourceLocation implements IResourceLocation {
}
@@ -0,0 +1,9 @@
package net.irisshaders.iris.mixin;
import net.minecraft.server.packs.resources.ResourceProvider;
import org.embeddedt.embeddium.compat.mc.IResourceProvider;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(ResourceProvider.class)
public interface MixinResourceProvider extends IResourceProvider {
}
@@ -2,6 +2,7 @@ package net.irisshaders.iris.mixin.texture;
import net.irisshaders.iris.texture.TextureTracker; import net.irisshaders.iris.texture.TextureTracker;
import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.AbstractTexture;
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@@ -10,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(AbstractTexture.class) @Mixin(AbstractTexture.class)
public class MixinAbstractTexture { public abstract class MixinAbstractTexture implements MCAbstractTexture {
@Shadow @Shadow
protected int id; protected int id;
@@ -7,6 +7,7 @@ import net.irisshaders.iris.texture.mipmap.CustomMipmapGenerator;
import net.minecraft.client.renderer.texture.MipmapGenerator; import net.minecraft.client.renderer.texture.MipmapGenerator;
import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.SpriteContents;
import net.minecraft.client.renderer.texture.SpriteTicker; import net.minecraft.client.renderer.texture.SpriteTicker;
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
@@ -27,7 +28,7 @@ public class MixinSpriteContents implements SpriteContentsExtension {
CustomMipmapGenerator generator = provider.getMipmapGenerator(); CustomMipmapGenerator generator = provider.getMipmapGenerator();
if (generator != null) { if (generator != null) {
try { try {
return generator.generateMipLevels(nativeImages, mipLevel); return (NativeImage[])(Object)generator.generateMipLevels((MCNativeImage[])(Object)nativeImages, mipLevel);
} catch (Exception e) { } catch (Exception e) {
Iris.logger.error("ERROR MIPMAPPING", e); Iris.logger.error("ERROR MIPMAPPING", e);
} }
@@ -4,6 +4,7 @@ import net.irisshaders.iris.texture.format.TextureFormatLoader;
import net.irisshaders.iris.texture.pbr.PBRTextureManager; import net.irisshaders.iris.texture.pbr.PBRTextureManager;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import org.embeddedt.embeddium.compat.mc.IResourceProvider;
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.Inject;
@@ -17,7 +18,7 @@ import java.util.concurrent.Executor;
public class MixinTextureManager { public class MixinTextureManager {
@Inject(method = { "method_18167", "m_244739_", "lambda$reload$5" }, at = @At("TAIL")) @Inject(method = { "method_18167", "m_244739_", "lambda$reload$5" }, at = @At("TAIL"))
private void iris$onTailReloadLambda(ResourceManager resourceManager, Executor applyExecutor, CompletableFuture<?> future, Void void1, CallbackInfo ci) { private void iris$onTailReloadLambda(ResourceManager resourceManager, Executor applyExecutor, CompletableFuture<?> future, Void void1, CallbackInfo ci) {
TextureFormatLoader.reload(resourceManager); TextureFormatLoader.reload((IResourceProvider) resourceManager);
PBRTextureManager.INSTANCE.clear(); PBRTextureManager.INSTANCE.clear();
} }
@@ -1,17 +1,12 @@
package net.irisshaders.iris.mixin.texture.pbr; package net.irisshaders.iris.mixin.texture.pbr;
import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.Local;
import net.irisshaders.iris.texture.pbr.PBRType; import net.irisshaders.iris.texture.prb.PBRType;
import net.minecraft.client.renderer.texture.atlas.SpriteSource;
import net.minecraft.client.renderer.texture.atlas.sources.DirectoryLister; import net.minecraft.client.renderer.texture.atlas.sources.DirectoryLister;
import net.minecraft.resources.FileToIdConverter;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.ModifyArg;
@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER; import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
@@ -27,7 +28,7 @@ import net.irisshaders.iris.texture.format.TextureFormat;
import net.irisshaders.iris.texture.format.TextureFormatLoader; import net.irisshaders.iris.texture.format.TextureFormatLoader;
import net.irisshaders.iris.texture.pbr.PBRTextureHolder; import net.irisshaders.iris.texture.pbr.PBRTextureHolder;
import net.irisshaders.iris.texture.pbr.PBRTextureManager; import net.irisshaders.iris.texture.pbr.PBRTextureManager;
import net.irisshaders.iris.texture.pbr.PBRType; import net.irisshaders.iris.texture.prb.PBRType;
import net.minecraft.ResourceLocationException; import net.minecraft.ResourceLocationException;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.AbstractTexture;
@@ -35,7 +36,7 @@ import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil; import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
public class CustomTextureManager { public class CustomTextureManager {
private final EnumMap<TextureStage, Object2ObjectMap<String, TextureAccess>> customTextureIdMap = new EnumMap<>(TextureStage.class); private final EnumMap<TextureStage, Object2ObjectMap<String, TextureAccess>> customTextureIdMap = new EnumMap<>(TextureStage.class);
@@ -141,7 +142,7 @@ public class CustomTextureManager {
TextureManager textureManager = Minecraft.getInstance().getTextureManager(); TextureManager textureManager = Minecraft.getInstance().getTextureManager();
if (pbrType == null) { if (pbrType == null) {
ResourceLocation textureLocation = ResourceLocationUtil.make(namespace, location); ResourceLocation textureLocation = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(namespace, location);
// NB: We have to re-query the TextureManager for the texture object every time. This is because the // NB: We have to re-query the TextureManager for the texture object every time. This is because the
// AbstractTexture object could be removed / deleted from the TextureManager on resource reloads, // AbstractTexture object could be removed / deleted from the TextureManager on resource reloads,
@@ -154,7 +155,7 @@ public class CustomTextureManager {
}, TextureType.TEXTURE_2D); }, TextureType.TEXTURE_2D);
} else { } else {
location = location.substring(0, extensionIndex - pbrType.getSuffix().length()) + location.substring(extensionIndex); location = location.substring(0, extensionIndex - pbrType.getSuffix().length()) + location.substring(extensionIndex);
ResourceLocation textureLocation = ResourceLocationUtil.make(namespace, location); ResourceLocation textureLocation = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(namespace, location);
return new TextureWrapper(() -> { return new TextureWrapper(() -> {
AbstractTexture texture = textureManager.getTexture(textureLocation); AbstractTexture texture = textureManager.getTexture(textureLocation);
@@ -162,7 +163,7 @@ public class CustomTextureManager {
if (texture != null) { if (texture != null) {
int id = texture.getId(); int id = texture.getId();
PBRTextureHolder pbrHolder = PBRTextureManager.INSTANCE.getOrLoadHolder(id); PBRTextureHolder pbrHolder = PBRTextureManager.INSTANCE.getOrLoadHolder(id);
AbstractTexture pbrTexture = switch (pbrType) { MCAbstractTexture pbrTexture = switch (pbrType) {
case NORMAL -> pbrHolder.normalTexture(); case NORMAL -> pbrHolder.normalTexture();
case SPECULAR -> pbrHolder.specularTexture(); case SPECULAR -> pbrHolder.specularTexture();
default -> throw new IllegalArgumentException("Unknown PBRType '" + pbrType + "'"); default -> throw new IllegalArgumentException("Unknown PBRType '" + pbrType + "'");
@@ -172,7 +173,7 @@ public class CustomTextureManager {
if (textureFormat != null) { if (textureFormat != null) {
int previousBinding = GlStateManagerAccessor.getTEXTURES()[GlStateManagerAccessor.getActiveTexture()].binding; int previousBinding = GlStateManagerAccessor.getTEXTURES()[GlStateManagerAccessor.getActiveTexture()].binding;
GL_STATE_MANAGER.bindTexture(pbrTexture.getId()); GL_STATE_MANAGER.bindTexture(pbrTexture.getId());
textureFormat.setupTextureParameters(pbrType, pbrTexture); textureFormat.setupTextureParameters(pbrType, (MCAbstractTexture)pbrTexture);
GL_STATE_MANAGER.bindTexture(previousBinding); GL_STATE_MANAGER.bindTexture(previousBinding);
} }
@@ -83,7 +83,7 @@ import net.irisshaders.iris.texture.format.TextureFormat;
import net.irisshaders.iris.texture.format.TextureFormatLoader; import net.irisshaders.iris.texture.format.TextureFormatLoader;
import net.irisshaders.iris.texture.pbr.PBRTextureHolder; import net.irisshaders.iris.texture.pbr.PBRTextureHolder;
import net.irisshaders.iris.texture.pbr.PBRTextureManager; import net.irisshaders.iris.texture.pbr.PBRTextureManager;
import net.irisshaders.iris.texture.pbr.PBRType; import net.irisshaders.iris.texture.prb.PBRType;
import net.irisshaders.iris.uniforms.CapturedRenderingState; import net.irisshaders.iris.uniforms.CapturedRenderingState;
import net.irisshaders.iris.uniforms.CommonUniforms; import net.irisshaders.iris.uniforms.CommonUniforms;
import net.irisshaders.iris.uniforms.FrameUpdateNotifier; import net.irisshaders.iris.uniforms.FrameUpdateNotifier;
@@ -24,7 +24,6 @@ import net.irisshaders.iris.uniforms.CommonUniforms;
import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms; import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms;
import net.irisshaders.iris.uniforms.custom.CustomUniforms; import net.irisshaders.iris.uniforms.custom.CustomUniforms;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -37,6 +36,8 @@ import java.util.function.Supplier;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class SodiumTerrainPipeline { public class SodiumTerrainPipeline {
private static final Supplier<Optional<AlphaTest>> terrainCutoutDefault = () -> Optional.of(AlphaTests.ONE_TENTH_ALPHA); private static final Supplier<Optional<AlphaTest>> terrainCutoutDefault = () -> Optional.of(AlphaTests.ONE_TENTH_ALPHA);
private static final Supplier<Optional<AlphaTest>> translucentDefault = () -> Optional.of(AlphaTest.ALWAYS); private static final Supplier<Optional<AlphaTest>> translucentDefault = () -> Optional.of(AlphaTest.ALWAYS);
@@ -294,7 +295,7 @@ public class SodiumTerrainPipeline {
String namespace = matcher.group("namespace"); String namespace = matcher.group("namespace");
String path = matcher.group("path"); String path = matcher.group("path");
ResourceLocation identifier = ResourceLocationUtil.make(namespace, path); ResourceLocation identifier = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(namespace, path);
return ""; return "";
} }
@@ -7,6 +7,7 @@ import java.util.function.Consumer;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER; import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM; import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
import com.mojang.blaze3d.preprocessor.GlslPreprocessor; import com.mojang.blaze3d.preprocessor.GlslPreprocessor;
import com.mojang.blaze3d.shaders.Program; import com.mojang.blaze3d.shaders.Program;
@@ -36,7 +37,6 @@ import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceProvider; import net.minecraft.server.packs.resources.ResourceProvider;
import org.embeddedt.embeddium.impl.gl.debug.GLDebug; import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.joml.Matrix3f; import org.joml.Matrix3f;
import org.joml.Matrix4f; import org.joml.Matrix4f;
@@ -234,7 +234,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
@Override @Override
public void iris$createExtraShaders(ResourceProvider factory, ResourceLocation name) { public void iris$createExtraShaders(ResourceProvider factory, ResourceLocation name) {
factory.getResource(ResourceLocationUtil.make(name.getNamespace(), name.getPath() + "_geometry.gsh")).ifPresent(geometry -> { factory.getResource((ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(name.getNamespace(), name.getPath() + "_geometry.gsh")).ifPresent(geometry -> {
try { try {
this.geometry = Program.compileShader(IrisProgramTypes.GEOMETRY, name.getPath(), geometry.open(), geometry.sourcePackId(), new GlslPreprocessor() { this.geometry = Program.compileShader(IrisProgramTypes.GEOMETRY, name.getPath(), geometry.open(), geometry.sourcePackId(), new GlslPreprocessor() {
@Nullable @Nullable
@@ -248,7 +248,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
Iris.logger.error("Failed to create shader program", e); Iris.logger.error("Failed to create shader program", e);
} }
}); });
factory.getResource(ResourceLocationUtil.make(name.getNamespace(), name.getPath() + "_tessControl.tcs")).ifPresent(tessControl -> { factory.getResource((ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(name.getNamespace(), name.getPath() + "_tessControl.tcs")).ifPresent(tessControl -> {
try { try {
this.tessControl = Program.compileShader(IrisProgramTypes.TESS_CONTROL, name.getPath(), tessControl.open(), tessControl.sourcePackId(), new GlslPreprocessor() { this.tessControl = Program.compileShader(IrisProgramTypes.TESS_CONTROL, name.getPath(), tessControl.open(), tessControl.sourcePackId(), new GlslPreprocessor() {
@Nullable @Nullable
@@ -262,7 +262,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
Iris.logger.error("Failed to create shader program", e); Iris.logger.error("Failed to create shader program", e);
} }
}); });
factory.getResource(ResourceLocationUtil.make(name.getNamespace(), name.getPath() + "_tessEval.tes")).ifPresent(tessEval -> { factory.getResource((ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(name.getNamespace(), name.getPath() + "_tessEval.tes")).ifPresent(tessEval -> {
try { try {
this.tessEval = Program.compileShader(IrisProgramTypes.TESS_EVAL, name.getPath(), tessEval.open(), tessEval.sourcePackId(), new GlslPreprocessor() { this.tessEval = Program.compileShader(IrisProgramTypes.TESS_EVAL, name.getPath(), tessEval.open(), tessEval.sourcePackId(), new GlslPreprocessor() {
@Nullable @Nullable
@@ -8,8 +8,8 @@ import net.irisshaders.iris.Iris;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
//?} //?}
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.Collections;
@@ -17,6 +17,8 @@ import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public record BlockEntry(NamespacedId id, Map<String, String> propertyPredicates, boolean isTag) { public record BlockEntry(NamespacedId id, Map<String, String> propertyPredicates, boolean isTag) {
/** /**
@@ -106,7 +108,7 @@ public record BlockEntry(NamespacedId id, Map<String, String> propertyPredicates
return Collections.singletonList(this); return Collections.singletonList(this);
} else { } else {
//? if >=1.19.3 { //? if >=1.19.3 {
var tag = TagKey.create(Registries.BLOCK, ResourceLocationUtil.make(id.getNamespace().toLowerCase(Locale.ROOT), id.getName().toLowerCase(Locale.ROOT))); var tag = TagKey.create(Registries.BLOCK, (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(id.getNamespace().toLowerCase(Locale.ROOT), id.getName().toLowerCase(Locale.ROOT)));
var tagOpt = BuiltInRegistries.BLOCK.getTag(tag); var tagOpt = BuiltInRegistries.BLOCK.getTag(tag);
//?} else { //?} else {
/*var tag = TagKey.create(Registry.BLOCK_REGISTRY, ResourceLocationUtil.make(id.getNamespace().toLowerCase(Locale.ROOT), id.getName().toLowerCase(Locale.ROOT))); /*var tag = TagKey.create(Registry.BLOCK_REGISTRY, ResourceLocationUtil.make(id.getNamespace().toLowerCase(Locale.ROOT), id.getName().toLowerCase(Locale.ROOT)));
@@ -14,11 +14,12 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.Property;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class BlockMaterialMapping { public class BlockMaterialMapping {
public static Object2IntMap<BlockState> createBlockStateIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) { public static Object2IntMap<BlockState> createBlockStateIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) {
Object2IntMap<BlockState> blockStateIds = new Object2IntOpenHashMap<>(); Object2IntMap<BlockState> blockStateIds = new Object2IntOpenHashMap<>();
@@ -38,7 +39,7 @@ public class BlockMaterialMapping {
Map<Block, RenderType> blockTypeIds = new Object2ObjectOpenHashMap<>(); Map<Block, RenderType> blockTypeIds = new Object2ObjectOpenHashMap<>();
blockPropertiesMap.forEach((id, blockType) -> { blockPropertiesMap.forEach((id, blockType) -> {
ResourceLocation resourceLocation = ResourceLocationUtil.make(id.getNamespace(), id.getName()); ResourceLocation resourceLocation = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(id.getNamespace(), id.getName());
Block block = BuiltInRegistries.BLOCK.get(resourceLocation); Block block = BuiltInRegistries.BLOCK.get(resourceLocation);
@@ -91,7 +92,7 @@ public class BlockMaterialMapping {
NamespacedId id = entry.id(); NamespacedId id = entry.id();
ResourceLocation resourceLocation; ResourceLocation resourceLocation;
try { try {
resourceLocation = ResourceLocationUtil.make(id.getNamespace(), id.getName()); resourceLocation = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(id.getNamespace(), id.getName());
} catch (Exception exception) { } catch (Exception exception) {
throw new IllegalStateException("Failed to get entry for " + intId, exception); throw new IllegalStateException("Failed to get entry for " + intId, exception);
} }
@@ -6,6 +6,7 @@ import net.irisshaders.iris.mixin.texture.SpriteContentsAnimatedTextureAccessor;
import net.irisshaders.iris.mixin.texture.SpriteContentsFrameInfoAccessor; import net.irisshaders.iris.mixin.texture.SpriteContentsFrameInfoAccessor;
import net.irisshaders.iris.mixin.texture.SpriteContentsTickerAccessor; import net.irisshaders.iris.mixin.texture.SpriteContentsTickerAccessor;
import net.irisshaders.iris.texture.pbr.loader.AtlasPBRLoader.PBRTextureAtlasSprite; import net.irisshaders.iris.texture.pbr.loader.AtlasPBRLoader.PBRTextureAtlasSprite;
import net.irisshaders.iris.texture.prb.PBRType;
import net.irisshaders.iris.texture.util.TextureManipulationUtil; import net.irisshaders.iris.texture.util.TextureManipulationUtil;
import net.minecraft.CrashReport; import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory; import net.minecraft.CrashReportCategory;
@@ -17,7 +18,6 @@ import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@@ -30,6 +30,8 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable { public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
protected final TextureAtlas atlasTexture; protected final TextureAtlas atlasTexture;
protected final PBRType type; protected final PBRType type;
@@ -43,7 +45,7 @@ public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
public PBRAtlasTexture(TextureAtlas atlasTexture, PBRType type) { public PBRAtlasTexture(TextureAtlas atlasTexture, PBRType type) {
this.atlasTexture = atlasTexture; this.atlasTexture = atlasTexture;
this.type = type; this.type = type;
id = ResourceLocationUtil.make(atlasTexture.location().getNamespace(), atlasTexture.location().getPath().replace(".png", "") + type.getSuffix() + ".png"); id = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(atlasTexture.location().getNamespace(), atlasTexture.location().getPath().replace(".png", "") + type.getSuffix() + ".png");
} }
public static void syncAnimation(SpriteContents.Ticker source, SpriteContents.Ticker target) { public static void syncAnimation(SpriteContents.Ticker source, SpriteContents.Ticker target) {
@@ -1,12 +1,12 @@
package net.irisshaders.iris.texture.pbr; package net.irisshaders.iris.texture.pbr;
import net.minecraft.client.renderer.texture.AbstractTexture; import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public interface PBRTextureHolder { public interface PBRTextureHolder {
@NotNull @NotNull
AbstractTexture normalTexture(); MCAbstractTexture normalTexture();
@NotNull @NotNull
AbstractTexture specularTexture(); MCAbstractTexture specularTexture();
} }
@@ -15,10 +15,12 @@ import net.irisshaders.iris.texture.TextureTracker;
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader; import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader;
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader.PBRTextureConsumer; import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader.PBRTextureConsumer;
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoaderRegistry; import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoaderRegistry;
import net.irisshaders.iris.texture.prb.PBRType;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.Dumpable; import net.minecraft.client.renderer.texture.Dumpable;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class PBRTextureManager { public class PBRTextureManager {
@@ -41,13 +43,13 @@ public class PBRTextureManager {
// Not PBRTextureHolderImpl to directly reference fields // Not PBRTextureHolderImpl to directly reference fields
private final PBRTextureHolder defaultHolder = new PBRTextureHolder() { private final PBRTextureHolder defaultHolder = new PBRTextureHolder() {
@Override @Override
public @NotNull AbstractTexture normalTexture() { public @NotNull MCAbstractTexture normalTexture() {
return defaultNormalTexture; return (MCAbstractTexture)defaultNormalTexture;
} }
@Override @Override
public @NotNull AbstractTexture specularTexture() { public @NotNull MCAbstractTexture specularTexture() {
return defaultSpecularTexture; return (MCAbstractTexture)defaultSpecularTexture;
} }
}; };
@@ -62,7 +64,7 @@ public class PBRTextureManager {
} }
} }
private static void closeTexture(AbstractTexture texture) { private static void closeTexture(MCAbstractTexture texture) {
try { try {
texture.close(); texture.close();
} catch (Exception e) { } catch (Exception e) {
@@ -141,8 +143,8 @@ public class PBRTextureManager {
} }
private void dumpHolder(PBRTextureHolder holder, Path path) { private void dumpHolder(PBRTextureHolder holder, Path path) {
AbstractTexture normalTexture = holder.normalTexture(); MCAbstractTexture normalTexture = holder.normalTexture();
AbstractTexture specularTexture = holder.specularTexture(); MCAbstractTexture specularTexture = holder.specularTexture();
if (normalTexture != defaultNormalTexture && normalTexture instanceof PBRDumpable dumpable) { if (normalTexture != defaultNormalTexture && normalTexture instanceof PBRDumpable dumpable) {
dumpTexture(dumpable, dumpable.getDefaultDumpLocation(), path); dumpTexture(dumpable, dumpable.getDefaultDumpLocation(), path);
} }
@@ -167,8 +169,8 @@ public class PBRTextureManager {
} }
private void closeHolder(PBRTextureHolder holder) { private void closeHolder(PBRTextureHolder holder) {
AbstractTexture normalTexture = holder.normalTexture(); MCAbstractTexture normalTexture = holder.normalTexture();
AbstractTexture specularTexture = holder.specularTexture(); MCAbstractTexture specularTexture = holder.specularTexture();
if (normalTexture != defaultNormalTexture) { if (normalTexture != defaultNormalTexture) {
closeTexture(normalTexture); closeTexture(normalTexture);
} }
@@ -177,39 +179,39 @@ public class PBRTextureManager {
} }
} }
private record PBRTextureHolderImpl(AbstractTexture normalTexture, private record PBRTextureHolderImpl(MCAbstractTexture normalTexture,
AbstractTexture specularTexture) implements PBRTextureHolder { MCAbstractTexture specularTexture) implements PBRTextureHolder {
@Override @Override
public @NotNull AbstractTexture normalTexture() { public @NotNull MCAbstractTexture normalTexture() {
return normalTexture; return normalTexture;
} }
@Override @Override
public @NotNull AbstractTexture specularTexture() { public @NotNull MCAbstractTexture specularTexture() {
return specularTexture; return specularTexture;
} }
} }
private class PBRTextureConsumerImpl implements PBRTextureConsumer { private class PBRTextureConsumerImpl implements PBRTextureConsumer {
private AbstractTexture normalTexture; private MCAbstractTexture normalTexture;
private AbstractTexture specularTexture; private MCAbstractTexture specularTexture;
private boolean changed; private boolean changed;
@Override @Override
public void acceptNormalTexture(@NotNull AbstractTexture texture) { public void acceptNormalTexture(@NotNull MCAbstractTexture texture) {
normalTexture = texture; normalTexture = texture;
changed = true; changed = true;
} }
@Override @Override
public void acceptSpecularTexture(@NotNull AbstractTexture texture) { public void acceptSpecularTexture(@NotNull MCAbstractTexture texture) {
specularTexture = texture; specularTexture = texture;
changed = true; changed = true;
} }
public void clear() { public void clear() {
normalTexture = defaultNormalTexture; normalTexture = (MCAbstractTexture)defaultNormalTexture;
specularTexture = defaultSpecularTexture; specularTexture = (MCAbstractTexture)defaultSpecularTexture;
changed = false; changed = false;
} }
@@ -11,7 +11,7 @@ import net.irisshaders.iris.texture.mipmap.CustomMipmapGenerator;
import net.irisshaders.iris.texture.mipmap.LinearBlendFunction; import net.irisshaders.iris.texture.mipmap.LinearBlendFunction;
import net.irisshaders.iris.texture.pbr.PBRAtlasTexture; import net.irisshaders.iris.texture.pbr.PBRAtlasTexture;
import net.irisshaders.iris.texture.pbr.PBRSpriteHolder; import net.irisshaders.iris.texture.pbr.PBRSpriteHolder;
import net.irisshaders.iris.texture.pbr.PBRType; import net.irisshaders.iris.texture.prb.PBRType;
import net.irisshaders.iris.texture.pbr.SpriteContentsExtension; import net.irisshaders.iris.texture.pbr.SpriteContentsExtension;
import net.irisshaders.iris.texture.util.ImageManipulationUtil; import net.irisshaders.iris.texture.util.ImageManipulationUtil;
import net.minecraft.client.renderer.texture.SpriteContents; import net.minecraft.client.renderer.texture.SpriteContents;
@@ -24,13 +24,15 @@ import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.ResourceMetadata; import net.minecraft.server.packs.resources.ResourceMetadata;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil; import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Optional; import java.util.Optional;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> { public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
public static final ChannelMipmapGenerator LINEAR_MIPMAP_GENERATOR = new ChannelMipmapGenerator( public static final ChannelMipmapGenerator LINEAR_MIPMAP_GENERATOR = new ChannelMipmapGenerator(
LinearBlendFunction.INSTANCE, LinearBlendFunction.INSTANCE,
@@ -71,12 +73,12 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
if (normalAtlas != null) { if (normalAtlas != null) {
if (normalAtlas.tryUpload(atlasWidth, atlasHeight, mipLevel)) { if (normalAtlas.tryUpload(atlasWidth, atlasHeight, mipLevel)) {
pbrTextureConsumer.acceptNormalTexture(normalAtlas); pbrTextureConsumer.acceptNormalTexture((MCAbstractTexture) normalAtlas);
} }
} }
if (specularAtlas != null) { if (specularAtlas != null) {
if (specularAtlas.tryUpload(atlasWidth, atlasHeight, mipLevel)) { if (specularAtlas.tryUpload(atlasWidth, atlasHeight, mipLevel)) {
pbrTextureConsumer.acceptSpecularTexture(specularAtlas); pbrTextureConsumer.acceptSpecularTexture((MCAbstractTexture)specularAtlas);
} }
} }
} }
@@ -158,7 +160,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
} }
} }
ResourceLocation pbrSpriteName = ResourceLocationUtil.make(spriteName.getNamespace(), spriteName.getPath() + pbrType.getSuffix()); ResourceLocation pbrSpriteName = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(spriteName.getNamespace(), spriteName.getPath() + pbrType.getSuffix());
PBRSpriteContents pbrSpriteContents = new PBRSpriteContents(pbrSpriteName, new FrameSize(frameWidth, frameHeight), nativeImage, /*? if <1.20.4 {*/ metadataSection /*?} else {*/ /*animationMetadata *//*?}*/, pbrType); PBRSpriteContents pbrSpriteContents = new PBRSpriteContents(pbrSpriteName, new FrameSize(frameWidth, frameHeight), nativeImage, /*? if <1.20.4 {*/ metadataSection /*?} else {*/ /*animationMetadata *//*?}*/, pbrType);
pbrSpriteContents.increaseMipLevel(mipLevel); pbrSpriteContents.increaseMipLevel(mipLevel);
return new PBRTextureAtlasSprite(pbrSpriteName, pbrSpriteContents, atlasWidth, atlasHeight, sprite.getX(), sprite.getY(), sprite); return new PBRTextureAtlasSprite(pbrSpriteName, pbrSpriteContents, atlasWidth, atlasHeight, sprite.getX(), sprite.getY(), sprite);
@@ -168,9 +170,9 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
String path = pbrType.appendSuffix(spriteName.getPath()); String path = pbrType.appendSuffix(spriteName.getPath());
// Temporary fix for CIT Resewn. CIT Resewn has sprites that are not in the textures/ folder, so a custom check must be used here to avoid that assumption. // Temporary fix for CIT Resewn. CIT Resewn has sprites that are not in the textures/ folder, so a custom check must be used here to avoid that assumption.
if (path.startsWith("optifine/cit/")) { if (path.startsWith("optifine/cit/")) {
return ResourceLocationUtil.make(spriteName.getNamespace(), path + ".png"); return (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(spriteName.getNamespace(), path + ".png");
} }
return ResourceLocationUtil.make(spriteName.getNamespace(), "textures/" + path + ".png"); return (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(spriteName.getNamespace(), "textures/" + path + ".png");
} }
protected static class PBRSpriteContents extends SpriteContents implements CustomMipmapGenerator.Provider { protected static class PBRSpriteContents extends SpriteContents implements CustomMipmapGenerator.Provider {
@@ -2,6 +2,7 @@ package net.irisshaders.iris.texture.pbr.loader;
import net.minecraft.client.renderer.texture.AbstractTexture; import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public interface PBRTextureLoader<T extends AbstractTexture> { public interface PBRTextureLoader<T extends AbstractTexture> {
@@ -15,8 +16,8 @@ public interface PBRTextureLoader<T extends AbstractTexture> {
void load(T texture, ResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer); void load(T texture, ResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer);
interface PBRTextureConsumer { interface PBRTextureConsumer {
void acceptNormalTexture(@NotNull AbstractTexture texture); void acceptNormalTexture(@NotNull MCAbstractTexture texture);
void acceptSpecularTexture(@NotNull AbstractTexture texture); void acceptSpecularTexture(@NotNull MCAbstractTexture texture);
} }
} }
@@ -1,11 +1,11 @@
package net.irisshaders.iris.texture.pbr.loader; package net.irisshaders.iris.texture.pbr.loader;
import net.irisshaders.iris.mixin.texture.SimpleTextureAccessor; import net.irisshaders.iris.mixin.texture.SimpleTextureAccessor;
import net.irisshaders.iris.texture.pbr.PBRType; import net.irisshaders.iris.texture.prb.PBRType;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.SimpleTexture; import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.IOException; import java.io.IOException;
@@ -15,8 +15,8 @@ public class SimplePBRLoader implements PBRTextureLoader<SimpleTexture> {
public void load(SimpleTexture texture, ResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) { public void load(SimpleTexture texture, ResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
ResourceLocation location = ((SimpleTextureAccessor) texture).getLocation(); ResourceLocation location = ((SimpleTextureAccessor) texture).getLocation();
AbstractTexture normalTexture = createPBRTexture(location, resourceManager, PBRType.NORMAL); MCAbstractTexture normalTexture = createPBRTexture(location, resourceManager, PBRType.NORMAL);
AbstractTexture specularTexture = createPBRTexture(location, resourceManager, PBRType.SPECULAR); MCAbstractTexture specularTexture = createPBRTexture(location, resourceManager, PBRType.SPECULAR);
if (normalTexture != null) { if (normalTexture != null) {
pbrTextureConsumer.acceptNormalTexture(normalTexture); pbrTextureConsumer.acceptNormalTexture(normalTexture);
@@ -27,7 +27,7 @@ public class SimplePBRLoader implements PBRTextureLoader<SimpleTexture> {
} }
@Nullable @Nullable
protected AbstractTexture createPBRTexture(ResourceLocation imageLocation, ResourceManager resourceManager, PBRType pbrType) { protected MCAbstractTexture createPBRTexture(ResourceLocation imageLocation, ResourceManager resourceManager, PBRType pbrType) {
ResourceLocation pbrImageLocation = imageLocation.withPath(pbrType::appendSuffix); ResourceLocation pbrImageLocation = imageLocation.withPath(pbrType::appendSuffix);
SimpleTexture pbrTexture = new SimpleTexture(pbrImageLocation); SimpleTexture pbrTexture = new SimpleTexture(pbrImageLocation);
@@ -37,6 +37,6 @@ public class SimplePBRLoader implements PBRTextureLoader<SimpleTexture> {
return null; return null;
} }
return pbrTexture; return (MCAbstractTexture)pbrTexture;
} }
} }
@@ -0,0 +1,46 @@
package org.embeddedt.embeddium.impl;
import net.minecraft.util.FastColor;
import org.embeddedt.embeddium.compat.mc.ABGR32Service;
public class ABGR32Impl implements ABGR32Service {
@Override
public int alpha(int packedColor) {
return FastColor.ABGR32.alpha(packedColor);
}
@Override
public int red(int packedColor) {
return FastColor.ABGR32.red(packedColor);
}
@Override
public int green(int packedColor) {
return FastColor.ABGR32.green(packedColor);
}
@Override
public int blue(int packedColor) {
return FastColor.ABGR32.blue(packedColor);
}
@Override
public int transparent(int packedColor) {
return FastColor.ABGR32.transparent(packedColor);
}
@Override
public int opaque(int packedColor) {
return FastColor.ABGR32.opaque(packedColor);
}
@Override
public int color(int alpha, int red, int green, int blue) {
return FastColor.ABGR32.color(alpha, red, green, blue);
}
@Override
public int color(int alpha, int packedColor) {
return FastColor.ABGR32.color(alpha, packedColor);
}
}
@@ -1,6 +1,7 @@
package org.embeddedt.embeddium.impl; package org.embeddedt.embeddium.impl;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.math.Axis; import com.mojang.math.Axis;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.Iris;
import net.irisshaders.iris.helpers.JomlConversions; import net.irisshaders.iris.helpers.JomlConversions;
@@ -9,10 +10,13 @@ import net.irisshaders.iris.uniforms.CameraUniforms;
import net.irisshaders.iris.uniforms.CapturedRenderingState; import net.irisshaders.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LightningBolt; import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.GameType; import net.minecraft.world.level.GameType;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.embeddedt.embeddium.compat.mc.IResourceLocation;
import org.embeddedt.embeddium.compat.mc.MCNativeImage;
import org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService; import org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices; import org.embeddedt.embeddium.impl.loader.common.EarlyLoaderServices;
@@ -21,10 +25,12 @@ import org.joml.Matrix4f;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector4f; import org.joml.Vector4f;
import java.io.IOException;
import java.util.Objects; import java.util.Objects;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
public class MinecraftModernVersionShimImpl implements MinecraftVersionShimService { public class MinecraftModernVersionShimImpl implements MinecraftVersionShimService {
@Override @Override
public boolean getSmartCull() { public boolean getSmartCull() {
return Minecraft.getInstance().smartCull; return Minecraft.getInstance().smartCull;
@@ -293,5 +299,39 @@ public class MinecraftModernVersionShimImpl implements MinecraftVersionShimServi
Vec3 pos = Minecraft.getInstance().getCameraEntity().getEyePosition(CapturedRenderingState.INSTANCE.getTickDelta()); Vec3 pos = Minecraft.getInstance().getCameraEntity().getEyePosition(CapturedRenderingState.INSTANCE.getTickDelta());
return new Vector3d(pos.x, pos.y, pos.z); return new Vector3d(pos.x, pos.y, pos.z);
} }
@Override
public MCNativeImage createNativeImage(int width, int height, boolean useCalloc) {
return (MCNativeImage)(Object) new NativeImage(width, height, useCalloc);
}
@Override
public MCNativeImage[] createNativeImageArray(int size) {
return (MCNativeImage[])(Object[])new NativeImage[size];
}
public IResourceLocation makeResourceLocation(String namespace, String path) {
//? if >=1.21
/*return (IResourceLocation)(Object) ResourceLocation.fromNamespaceAndPath(namespace, path);*/
//? if <1.21
return (IResourceLocation)(Object) new ResourceLocation(namespace, path);
}
public IResourceLocation makeResourceLocation(String str) {
//? if >=1.21 {
/*if(str.contains(":")) {
return (IResourceLocation)(Object) ResourceLocation.parse(str);
} else {
return (IResourceLocation)(Object) ResourceLocation.withDefaultNamespace(str);
}
*///?} else
return (IResourceLocation)(Object)new ResourceLocation(str);
}
@Override
public void reloadIris() throws IOException {
Iris.reload();
}
} }