Skip to content

Commit

Permalink
Rename some classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebear94 committed Nov 11, 2023
1 parent c2b7aa6 commit fd68dc1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import net.minecraft.resource.ResourceFactory;
import net.minecraft.util.Identifier;

public final class FabricShaderProgram extends Shader {
public FabricShaderProgram(ResourceFactory factory, Identifier name, VertexFormat format) throws IOException {
public final class FabricShader extends Shader {
public FabricShader(ResourceFactory factory, Identifier name, VertexFormat format) throws IOException {
super(factory, name.toString(), format);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import net.minecraft.resource.ResourceManager;

import net.fabricmc.fabric.api.client.rendering.v1.CoreShaderRegistrationCallback;
import net.fabricmc.fabric.impl.client.rendering.FabricShaderProgram;
import net.fabricmc.fabric.impl.client.rendering.FabricShader;

/**
* Implements custom core shader registration (CoreShaderRegistrationCallback).
Expand All @@ -48,7 +48,7 @@ abstract class GameRendererMixin {
)
private void registerShaders(ResourceManager factory, CallbackInfo info, List<?> shaderStages, List<Pair<Shader, Consumer<Shader>>> programs) throws IOException {
CoreShaderRegistrationCallback.RegistrationContext context = (id, vertexFormat, loadCallback) -> {
Shader program = new FabricShaderProgram(factory, id, vertexFormat);
Shader program = new FabricShader(factory, id, vertexFormat);
programs.add(Pair.of(program, loadCallback));
};
CoreShaderRegistrationCallback.EVENT.invoker().registerShaders(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

import net.minecraft.util.Identifier;

import net.fabricmc.fabric.impl.client.rendering.FabricShaderProgram;
import net.fabricmc.fabric.impl.client.rendering.FabricShader;

/**
* Lets modded shaders {@code #moj_import} shaders from any namespace with the
* {@code <>} syntax.
*/
@Mixin(targets = "net.minecraft.client.render.Shader$1")
abstract class ShaderProgramImportProcessorMixin {
abstract class ShaderImportProcessorMixin {
@Unique
private String capturedImport;

Expand All @@ -44,7 +44,7 @@ private void captureImport(boolean inline, String name, CallbackInfoReturnable<S
@ModifyVariable(method = "loadImport", at = @At("STORE"), ordinal = 0, argsOnly = true)
private String modifyImportId(String id, boolean inline) {
if (!inline && capturedImport.contains(String.valueOf(Identifier.NAMESPACE_SEPARATOR))) {
return FabricShaderProgram.rewriteAsId(id, capturedImport);
return FabricShader.rewriteAsId(id, capturedImport);
}

return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@
import net.minecraft.resource.ResourceFactory;
import net.minecraft.util.Identifier;

import net.fabricmc.fabric.impl.client.rendering.FabricShaderProgram;
import net.fabricmc.fabric.impl.client.rendering.FabricShader;

@Mixin(Shader.class)
abstract class ShaderProgramMixin {
abstract class ShaderMixin {
@Shadow
@Final
private String name;

// Allow loading FabricShaderPrograms from arbitrary namespaces.
@ModifyArg(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;<init>(Ljava/lang/String;)V"), allow = 1)
private String modifyProgramId(String id) {
if ((Object) this instanceof FabricShaderProgram) {
return FabricShaderProgram.rewriteAsId(id, name);
if ((Object) this instanceof FabricShader) {
return FabricShader.rewriteAsId(id, name);
}

return id;
Expand All @@ -50,7 +50,7 @@ private String modifyProgramId(String id) {
@ModifyVariable(method = "loadProgram", at = @At("STORE"), ordinal = 1)
private static String modifyStageId(String id, ResourceFactory factory, Program.Type type, String name) {
if (name.contains(String.valueOf(Identifier.NAMESPACE_SEPARATOR))) {
return FabricShaderProgram.rewriteAsId(id, name);
return FabricShader.rewriteAsId(id, name);
}

return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"ScreenMixin",
"DimensionEffectsAccessor",
"shader.GameRendererMixin",
"shader.ShaderProgramImportProcessorMixin",
"shader.ShaderProgramMixin"
"shader.ShaderImportProcessorMixin",
"shader.ShaderMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit fd68dc1

Please sign in to comment.