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
17 changed files with 109 additions and 79 deletions
Showing only changes of commit ca0c7f63ff - Show all commits

No files matched your search

@@ -3,22 +3,21 @@ package org.embeddedt.embeddium.api.options.structure;
import org.embeddedt.embeddium.api.options.OptionIdentifier;
import org.embeddedt.embeddium.impl.Celeritas;
import net.minecraft.resources.ResourceLocation;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
public final class StandardOptions {
public static class Group {
public static final ResourceLocation RENDERING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "rendering");
public static final ResourceLocation WINDOW = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "window");
public static final ResourceLocation INDICATORS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "indicators");
public static final ResourceLocation GRAPHICS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "graphics");
public static final ResourceLocation MIPMAPS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "mipmaps");
public static final ResourceLocation DETAILS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "details");
public static final ResourceLocation CHUNK_UPDATES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "chunk_updates");
public static final ResourceLocation RENDERING_CULLING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "rendering_culling");
public static final ResourceLocation CPU_SAVING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "cpu_saving");
public static final ResourceLocation SORTING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "sorting");
public static final ResourceLocation LIGHTING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "lighting");
public static final ResourceLocation RENDERING = ResourceLocationUtil.make("minecraft", "rendering");
public static final ResourceLocation WINDOW = ResourceLocationUtil.make("minecraft", "window");
public static final ResourceLocation INDICATORS = ResourceLocationUtil.make("minecraft", "indicators");
public static final ResourceLocation GRAPHICS = ResourceLocationUtil.make("minecraft", "graphics");
public static final ResourceLocation MIPMAPS = ResourceLocationUtil.make("minecraft", "mipmaps");
public static final ResourceLocation DETAILS = ResourceLocationUtil.make("minecraft", "details");
public static final ResourceLocation CHUNK_UPDATES = ResourceLocationUtil.make(Celeritas.MODID, "chunk_updates");
public static final ResourceLocation RENDERING_CULLING = ResourceLocationUtil.make(Celeritas.MODID, "rendering_culling");
public static final ResourceLocation CPU_SAVING = ResourceLocationUtil.make(Celeritas.MODID, "cpu_saving");
public static final ResourceLocation SORTING = ResourceLocationUtil.make(Celeritas.MODID, "sorting");
public static final ResourceLocation LIGHTING = ResourceLocationUtil.make(Celeritas.MODID, "lighting");
}
public static class Pages {
@@ -30,44 +29,44 @@ public final class StandardOptions {
}
public static class Option {
public static final ResourceLocation RENDER_DISTANCE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "render_distance");
public static final ResourceLocation SIMULATION_DISTANCE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "simulation_distance");
public static final ResourceLocation BRIGHTNESS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "brightness");
public static final ResourceLocation GUI_SCALE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "gui_scale");
public static final ResourceLocation FULLSCREEN = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "fullscreen");
public static final ResourceLocation FULLSCREEN_RESOLUTION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "fullscreen_resolution");
public static final ResourceLocation VSYNC = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "vsync");
public static final ResourceLocation MAX_FRAMERATE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "max_frame_rate");
public static final ResourceLocation VIEW_BOBBING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "view_bobbing");
public static final ResourceLocation INACTIVITY_FPS_LIMIT = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "inactivity_fps_limit");
public static final ResourceLocation ATTACK_INDICATOR = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "attack_indicator");
public static final ResourceLocation AUTOSAVE_INDICATOR = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "autosave_indicator");
public static final ResourceLocation GRAPHICS_MODE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "graphics_mode");
public static final ResourceLocation CLOUDS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "clouds");
public static final ResourceLocation WEATHER = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "weather");
public static final ResourceLocation LEAVES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "leaves");
public static final ResourceLocation PARTICLES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "particles");
public static final ResourceLocation SMOOTH_LIGHT = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "smooth_lighting");
public static final ResourceLocation BIOME_BLEND = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "biome_blend");
public static final ResourceLocation ENTITY_DISTANCE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "entity_distance");
public static final ResourceLocation ENTITY_SHADOWS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "entity_shadows");
public static final ResourceLocation VIGNETTE = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "vignette");
public static final ResourceLocation MIPMAP_LEVEL = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("minecraft", "mipmap_levels");
public static final ResourceLocation CHUNK_UPDATE_THREADS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "chunk_update_threads");
public static final ResourceLocation DEFFER_CHUNK_UPDATES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "defer_chunk_updates");
public static final ResourceLocation BLOCK_FACE_CULLING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "block_face_culling");
public static final ResourceLocation COMPACT_VERTEX_FORMAT = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "compact_vertex_format");
public static final ResourceLocation FOG_OCCLUSION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "fog_occlusion");
public static final ResourceLocation ENTITY_CULLING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "entity_culling");
public static final ResourceLocation ANIMATE_VISIBLE_TEXTURES = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "animate_only_visible_textures");
public static final ResourceLocation NO_ERROR_CONTEXT = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "no_error_context");
public static final ResourceLocation PERSISTENT_MAPPING = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "persistent_mapping");
public static final ResourceLocation CPU_FRAMES_AHEAD = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "cpu_render_ahead_limit");
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 = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "use_quad_normals_for_lighting");
public static final ResourceLocation RENDER_PASS_OPTIMIZATION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "render_pass_optimization");
public static final ResourceLocation RENDER_PASS_CONSOLIDATION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "render_pass_consolidation");
public static final ResourceLocation USE_FASTER_CLOUDS = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "use_faster_clouds");
public static final ResourceLocation ASYNC_GRAPH_SEARCH = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "async_graph_search");
public static final ResourceLocation RENDER_DISTANCE = ResourceLocationUtil.make("minecraft", "render_distance");
public static final ResourceLocation SIMULATION_DISTANCE = ResourceLocationUtil.make("minecraft", "simulation_distance");
public static final ResourceLocation BRIGHTNESS = ResourceLocationUtil.make("minecraft", "brightness");
public static final ResourceLocation GUI_SCALE = ResourceLocationUtil.make("minecraft", "gui_scale");
public static final ResourceLocation FULLSCREEN = ResourceLocationUtil.make("minecraft", "fullscreen");
public static final ResourceLocation FULLSCREEN_RESOLUTION = ResourceLocationUtil.make("minecraft", "fullscreen_resolution");
public static final ResourceLocation VSYNC = ResourceLocationUtil.make("minecraft", "vsync");
public static final ResourceLocation MAX_FRAMERATE = ResourceLocationUtil.make("minecraft", "max_frame_rate");
public static final ResourceLocation VIEW_BOBBING = ResourceLocationUtil.make("minecraft", "view_bobbing");
public static final ResourceLocation INACTIVITY_FPS_LIMIT = ResourceLocationUtil.make("minecraft", "inactivity_fps_limit");
public static final ResourceLocation ATTACK_INDICATOR = ResourceLocationUtil.make("minecraft", "attack_indicator");
public static final ResourceLocation AUTOSAVE_INDICATOR = ResourceLocationUtil.make("minecraft", "autosave_indicator");
public static final ResourceLocation GRAPHICS_MODE = ResourceLocationUtil.make("minecraft", "graphics_mode");
public static final ResourceLocation CLOUDS = ResourceLocationUtil.make("minecraft", "clouds");
public static final ResourceLocation WEATHER = ResourceLocationUtil.make("minecraft", "weather");
public static final ResourceLocation LEAVES = ResourceLocationUtil.make("minecraft", "leaves");
public static final ResourceLocation PARTICLES = ResourceLocationUtil.make("minecraft", "particles");
public static final ResourceLocation SMOOTH_LIGHT = ResourceLocationUtil.make("minecraft", "smooth_lighting");
public static final ResourceLocation BIOME_BLEND = ResourceLocationUtil.make("minecraft", "biome_blend");
public static final ResourceLocation ENTITY_DISTANCE = ResourceLocationUtil.make("minecraft", "entity_distance");
public static final ResourceLocation ENTITY_SHADOWS = ResourceLocationUtil.make("minecraft", "entity_shadows");
public static final ResourceLocation VIGNETTE = ResourceLocationUtil.make("minecraft", "vignette");
public static final ResourceLocation MIPMAP_LEVEL = ResourceLocationUtil.make("minecraft", "mipmap_levels");
public static final ResourceLocation CHUNK_UPDATE_THREADS = ResourceLocationUtil.make(Celeritas.MODID, "chunk_update_threads");
public static final ResourceLocation DEFFER_CHUNK_UPDATES = ResourceLocationUtil.make(Celeritas.MODID, "defer_chunk_updates");
public static final ResourceLocation BLOCK_FACE_CULLING = ResourceLocationUtil.make(Celeritas.MODID, "block_face_culling");
public static final ResourceLocation COMPACT_VERTEX_FORMAT = ResourceLocationUtil.make(Celeritas.MODID, "compact_vertex_format");
public static final ResourceLocation FOG_OCCLUSION = ResourceLocationUtil.make(Celeritas.MODID, "fog_occlusion");
public static final ResourceLocation ENTITY_CULLING = ResourceLocationUtil.make(Celeritas.MODID, "entity_culling");
public static final ResourceLocation ANIMATE_VISIBLE_TEXTURES = ResourceLocationUtil.make(Celeritas.MODID, "animate_only_visible_textures");
public static final ResourceLocation NO_ERROR_CONTEXT = ResourceLocationUtil.make(Celeritas.MODID, "no_error_context");
public static final ResourceLocation PERSISTENT_MAPPING = ResourceLocationUtil.make(Celeritas.MODID, "persistent_mapping");
public static final ResourceLocation CPU_FRAMES_AHEAD = ResourceLocationUtil.make(Celeritas.MODID, "cpu_render_ahead_limit");
public static final ResourceLocation TRANSLUCENT_FACE_SORTING = ResourceLocationUtil.make(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 RENDER_PASS_OPTIMIZATION = ResourceLocationUtil.make(Celeritas.MODID, "render_pass_optimization");
public static final ResourceLocation RENDER_PASS_CONSOLIDATION = ResourceLocationUtil.make(Celeritas.MODID, "render_pass_consolidation");
public static final ResourceLocation USE_FASTER_CLOUDS = ResourceLocationUtil.make(Celeritas.MODID, "use_faster_clouds");
public static final ResourceLocation ASYNC_GRAPH_SEARCH = ResourceLocationUtil.make(Celeritas.MODID, "async_graph_search");
}
}
@@ -8,13 +8,12 @@ import net.minecraft.client.Minecraft;
//$ guigfx
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import java.util.Objects;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class TabHeaderWidget extends FlatButtonWidget {
private static final ResourceLocation FALLBACK_LOCATION = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("textures/misc/unknown_pack.png");
private static final ResourceLocation FALLBACK_LOCATION = ResourceLocationUtil.make("textures/misc/unknown_pack.png");
private final ResourceLocation logoTexture;
@@ -12,6 +12,7 @@ import net.minecraftforge.fml.ModList;
//? if neoforge
/*import net.neoforged.fml.ModList;*/
import org.embeddedt.embeddium.impl.Celeritas;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import java.io.IOException;
import java.io.InputStream;
@@ -21,8 +22,6 @@ import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class ModLogoUtil {
private static final Set<String> erroredLogos = new HashSet<>();
@@ -70,7 +69,7 @@ public class ModLogoUtil {
logo.close();
throw new IOException("Logo for " + modId + " is not square");
}
ResourceLocation texture = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "logo/" + modId);
ResourceLocation texture = ResourceLocationUtil.make(Celeritas.MODID, "logo/" + modId);
Minecraft.getInstance().getTextureManager().register(texture, new DynamicTexture(
//? if >=1.21.5-alpha.25.7.a
/*() -> modId + " logo",*/
@@ -5,6 +5,7 @@ import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.renderer.RenderType;
import org.embeddedt.embeddium.api.util.ColorABGR;
import org.embeddedt.embeddium.api.util.ColorARGB;
import org.embeddedt.embeddium.api.util.ColorMixer;
@@ -23,6 +24,7 @@ import org.embeddedt.embeddium.api.render.clouds.ModifyCloudRenderingEvent;
import org.embeddedt.embeddium.api.vertex.format.common.LineVertex;
import org.embeddedt.embeddium.impl.render.ShaderModBridge;
import org.embeddedt.embeddium.impl.render.CeleritasWorldRenderer;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import org.lwjgl.opengl.GL30C;
@@ -34,7 +36,7 @@ import java.io.InputStream;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class CloudRenderer {
private static final ResourceLocation CLOUDS_TEXTURE_ID = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("textures/environment/clouds.png");
private static final ResourceLocation CLOUDS_TEXTURE_ID = ResourceLocationUtil.make("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_POS_Y = ColorABGR.pack(1.0f, 1.0f, 1.0f, 1.0f);
@@ -1,7 +1,6 @@
package org.embeddedt.embeddium.impl.tags;
//? if >=1.18 {
import net.minecraft.resources.ResourceLocation;
import org.embeddedt.embeddium.impl.Celeritas;
//? if >=1.20 {
import net.minecraft.core.registries.Registries;
@@ -9,6 +8,7 @@ import net.minecraft.core.registries.Registries;
/*import net.minecraft.core.Registry;*/
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.material.Fluid;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
@@ -18,6 +18,6 @@ public class EmbeddiumTags {
/*Registry.FLUID_REGISTRY,
*///?} else
Registries.FLUID,
(ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(Celeritas.MODID, "is_vanilla_rendered_fluid"));
ResourceLocationUtil.make(Celeritas.MODID, "is_vanilla_rendered_fluid"));
}
//?}
@@ -0,0 +1,23 @@
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);
}
}
@@ -14,6 +14,7 @@ import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
/**
* Class serving as abstraction and
@@ -25,7 +26,7 @@ import net.minecraft.sounds.SoundEvents;
* some code that will be changed.
*/
public final class GuiUtil {
public static final ResourceLocation IRIS_WIDGETS_TEX = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation("iris", "textures/gui/widgets.png");
public static final ResourceLocation IRIS_WIDGETS_TEX = ResourceLocationUtil.make("iris", "textures/gui/widgets.png");
private static final Component ELLIPSIS = Component.literal("...");
private GuiUtil() {
@@ -32,6 +32,7 @@ import java.io.InputStream;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -1,5 +1,6 @@
package net.irisshaders.iris.pathways;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.irisshaders.iris.IrisConstants;
import net.irisshaders.iris.versionutils.ModelTranslucencyHelper;
@@ -7,7 +7,6 @@ import java.util.List;
import java.util.Optional;
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.Object2ObjectMaps;
@@ -37,6 +36,7 @@ import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.resources.ResourceLocation;
import org.apache.commons.io.FilenameUtils;
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
public class CustomTextureManager {
private final EnumMap<TextureStage, Object2ObjectMap<String, TextureAccess>> customTextureIdMap = new EnumMap<>(TextureStage.class);
@@ -142,7 +142,7 @@ public class CustomTextureManager {
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
if (pbrType == null) {
ResourceLocation textureLocation = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(namespace, location);
ResourceLocation textureLocation = ResourceLocationUtil.make(namespace, location);
// 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,
@@ -155,7 +155,7 @@ public class CustomTextureManager {
}, TextureType.TEXTURE_2D);
} else {
location = location.substring(0, extensionIndex - pbrType.getSuffix().length()) + location.substring(extensionIndex);
ResourceLocation textureLocation = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(namespace, location);
ResourceLocation textureLocation = ResourceLocationUtil.make(namespace, location);
return new TextureWrapper(() -> {
AbstractTexture texture = textureManager.getTexture(textureLocation);
@@ -24,6 +24,7 @@ import net.irisshaders.iris.uniforms.CommonUniforms;
import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms;
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
import net.minecraft.resources.ResourceLocation;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import java.util.ArrayList;
import java.util.Collections;
@@ -295,7 +296,7 @@ public class SodiumTerrainPipeline {
String namespace = matcher.group("namespace");
String path = matcher.group("path");
ResourceLocation identifier = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(namespace, path);
ResourceLocation identifier = ResourceLocationUtil.make(namespace, path);
return "";
}
@@ -37,6 +37,7 @@ import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceProvider;
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
@@ -234,7 +235,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
@Override
public void iris$createExtraShaders(ResourceProvider factory, ResourceLocation name) {
factory.getResource((ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(name.getNamespace(), name.getPath() + "_geometry.gsh")).ifPresent(geometry -> {
factory.getResource(ResourceLocationUtil.make(name.getNamespace(), name.getPath() + "_geometry.gsh")).ifPresent(geometry -> {
try {
this.geometry = Program.compileShader(IrisProgramTypes.GEOMETRY, name.getPath(), geometry.open(), geometry.sourcePackId(), new GlslPreprocessor() {
@Nullable
@@ -248,7 +249,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
Iris.logger.error("Failed to create shader program", e);
}
});
factory.getResource((ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(name.getNamespace(), name.getPath() + "_tessControl.tcs")).ifPresent(tessControl -> {
factory.getResource(ResourceLocationUtil.make(name.getNamespace(), name.getPath() + "_tessControl.tcs")).ifPresent(tessControl -> {
try {
this.tessControl = Program.compileShader(IrisProgramTypes.TESS_CONTROL, name.getPath(), tessControl.open(), tessControl.sourcePackId(), new GlslPreprocessor() {
@Nullable
@@ -262,7 +263,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
Iris.logger.error("Failed to create shader program", e);
}
});
factory.getResource((ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(name.getNamespace(), name.getPath() + "_tessEval.tes")).ifPresent(tessEval -> {
factory.getResource(ResourceLocationUtil.make(name.getNamespace(), name.getPath() + "_tessEval.tes")).ifPresent(tessEval -> {
try {
this.tessEval = Program.compileShader(IrisProgramTypes.TESS_EVAL, name.getPath(), tessEval.open(), tessEval.sourcePackId(), new GlslPreprocessor() {
@Nullable
@@ -35,6 +35,7 @@ import net.minecraft.server.packs.repository.PackSource;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceProvider;
import org.apache.commons.io.IOUtils;
import org.embeddedt.embeddium.impl.util.ComponentUtil;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -236,7 +237,7 @@ public class ShaderCreator {
private static PackResources fabricateResourcePack() {
//? if >=1.20.6 {
/*return new PathPackResources(new PackLocationInfo("<iris shaderpack shaders>", Component.literal("iris"), PackSource.BUILT_IN, Optional.of(new KnownPack("iris", "shader", "1.0"))), PlatformUtil.getConfigDir());
/*return new PathPackResources(new PackLocationInfo("<iris shaderpack shaders>", ComponentUtil.literal("iris"), PackSource.BUILT_IN, Optional.of(new KnownPack("iris", "shader", "1.0"))), PLATFORM_UTIL.getConfigDir());
*///?} else
return new PathPackResources("<iris shaderpack shaders>", PLATFORM_UTIL.getConfigDir(), true);
}
@@ -10,6 +10,7 @@ import net.minecraft.core.registries.Registries;
//?}
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
@@ -108,7 +109,7 @@ public record BlockEntry(NamespacedId id, Map<String, String> propertyPredicates
return Collections.singletonList(this);
} else {
//? if >=1.19.3 {
var tag = TagKey.create(Registries.BLOCK, (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(id.getNamespace().toLowerCase(Locale.ROOT), id.getName().toLowerCase(Locale.ROOT)));
var tag = TagKey.create(Registries.BLOCK, ResourceLocationUtil.make(id.getNamespace().toLowerCase(Locale.ROOT), id.getName().toLowerCase(Locale.ROOT)));
var tagOpt = BuiltInRegistries.BLOCK.getTag(tag);
//?} else {
/*var tag = TagKey.create(Registry.BLOCK_REGISTRY, ResourceLocationUtil.make(id.getNamespace().toLowerCase(Locale.ROOT), id.getName().toLowerCase(Locale.ROOT)));
@@ -14,12 +14,11 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.Property;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import java.lang.reflect.Method;
import java.util.*;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class BlockMaterialMapping {
public static Object2IntMap<BlockState> createBlockStateIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) {
Object2IntMap<BlockState> blockStateIds = new Object2IntOpenHashMap<>();
@@ -39,7 +38,7 @@ public class BlockMaterialMapping {
Map<Block, RenderType> blockTypeIds = new Object2ObjectOpenHashMap<>();
blockPropertiesMap.forEach((id, blockType) -> {
ResourceLocation resourceLocation = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(id.getNamespace(), id.getName());
ResourceLocation resourceLocation = ResourceLocationUtil.make(id.getNamespace(), id.getName());
Block block = BuiltInRegistries.BLOCK.get(resourceLocation);
@@ -92,7 +91,7 @@ public class BlockMaterialMapping {
NamespacedId id = entry.id();
ResourceLocation resourceLocation;
try {
resourceLocation = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(id.getNamespace(), id.getName());
resourceLocation = ResourceLocationUtil.make(id.getNamespace(), id.getName());
} catch (Exception exception) {
throw new IllegalStateException("Failed to get entry for " + intId, exception);
}
@@ -17,6 +17,7 @@ import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedWriter;
@@ -44,7 +45,7 @@ public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
public PBRAtlasTexture(TextureAtlas atlasTexture, PBRType type) {
this.atlasTexture = atlasTexture;
this.type = type;
id = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(atlasTexture.location().getNamespace(), atlasTexture.location().getPath().replace(".png", "") + type.getSuffix() + ".png");
id = ResourceLocationUtil.make(atlasTexture.location().getNamespace(), atlasTexture.location().getPath().replace(".png", "") + type.getSuffix() + ".png");
}
public static void syncAnimation(SpriteContents.Ticker source, SpriteContents.Ticker target) {
@@ -25,6 +25,7 @@ import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.ResourceMetadata;
import net.minecraft.util.Mth;
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
@@ -160,7 +161,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
}
}
ResourceLocation pbrSpriteName = (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(spriteName.getNamespace(), spriteName.getPath() + pbrType.getSuffix());
ResourceLocation pbrSpriteName = ResourceLocationUtil.make(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.increaseMipLevel(mipLevel);
return new PBRTextureAtlasSprite(pbrSpriteName, pbrSpriteContents, atlasWidth, atlasHeight, sprite.getX(), sprite.getY(), sprite);
@@ -170,9 +171,9 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
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.
if (path.startsWith("optifine/cit/")) {
return (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(spriteName.getNamespace(), path + ".png");
return ResourceLocationUtil.make(spriteName.getNamespace(), path + ".png");
}
return (ResourceLocation)MINECRAFT_SHIM.makeResourceLocation(spriteName.getNamespace(), "textures/" + path + ".png");
return ResourceLocationUtil.make(spriteName.getNamespace(), "textures/" + path + ".png");
}
protected static class PBRSpriteContents extends SpriteContents implements CustomMipmapGenerator.Provider {