Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 055794b

Browse files
authored
Merge pull request #49 from shedaniel/feature/i_am_smart
add ClientRegistry#registerEntityShader feature and move GameOptions …
2 parents 2f18cbf + ea6759b commit 055794b

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.patchworkmc.mixin.registries;
2+
3+
import javax.annotation.Nullable;
4+
5+
import com.mojang.blaze3d.platform.GLX;
6+
import net.minecraftforge.fml.client.registry.ClientRegistry;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.Shadow;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
12+
13+
import net.minecraft.client.gl.ShaderEffect;
14+
import net.minecraft.client.render.GameRenderer;
15+
import net.minecraft.entity.Entity;
16+
import net.minecraft.entity.mob.CreeperEntity;
17+
import net.minecraft.entity.mob.EndermanEntity;
18+
import net.minecraft.entity.mob.SpiderEntity;
19+
import net.minecraft.util.Identifier;
20+
21+
@Mixin(GameRenderer.class)
22+
public abstract class MixinGameRenderer {
23+
@Shadow
24+
protected abstract void loadShader(Identifier identifier);
25+
26+
@Shadow
27+
private ShaderEffect shader;
28+
29+
@Inject(method = "onCameraEntitySet", at = @At("RETURN"))
30+
private void onCameraEntitySet(@Nullable Entity entity, CallbackInfo ci) {
31+
if (GLX.usePostProcess) {
32+
if (shader == null && entity != null && !(entity instanceof CreeperEntity) && !(entity instanceof SpiderEntity) && !(entity instanceof EndermanEntity)) {
33+
Identifier shader = ClientRegistry.getEntityShader(entity.getClass());
34+
35+
if (shader != null) {
36+
loadShader(shader);
37+
}
38+
}
39+
}
40+
}
41+
}

patchwork-registries/src/main/resources/patchwork-registries.mixins.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"MixinEntityType",
1818
"MixinFeature",
1919
"MixinFluid",
20-
"MixinGameOptions",
2120
"MixinItem",
2221
"MixinMemoryModuleType",
2322
"MixinPaintingMotive",
@@ -34,6 +33,10 @@
3433
"MixinSurfaceBuilder",
3534
"MixinVillagerProfession"
3635
],
36+
"client": [
37+
"MixinGameOptions",
38+
"MixinGameRenderer"
39+
],
3740
"injectors": {
3841
"defaultRequire": 1
3942
}

0 commit comments

Comments
 (0)