Skip to content

Commit

Permalink
Add end beam ID
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Apr 29, 2024
1 parent 6aa4b2d commit 04cdb32
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package net.irisshaders.iris.mixin.entity_render_context;

import com.mojang.blaze3d.vertex.PoseStack;
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
import net.irisshaders.iris.uniforms.CapturedRenderingState;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EnderDragonRenderer;
import net.minecraft.client.renderer.entity.layers.CapeLayer;
import net.minecraft.client.resources.PlayerSkin;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(EnderDragonRenderer.class)
public class MixinEnderDragonRenderer {
private static final NamespacedId END_BEAM = new NamespacedId("minecraft", "end_crystal_beam");
private static int previousE;

@Inject(method = "renderCrystalBeams", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V"))
private static void changeId(float f, float g, float h, float i, int j, PoseStack poseStack, MultiBufferSource multiBufferSource, int k, CallbackInfo ci) {
if (WorldRenderingSettings.INSTANCE.getEntityIds() == null) return;

previousE = CapturedRenderingState.INSTANCE.getCurrentRenderedEntity();
CapturedRenderingState.INSTANCE.setCurrentEntity(WorldRenderingSettings.INSTANCE.getEntityIds().applyAsInt(END_BEAM));
}

@Inject(method = "renderCrystalBeams", at = @At(value = "RETURN"))
private static void changeId2(CallbackInfo ci) {
if (previousE != 0) {
CapturedRenderingState.INSTANCE.setCurrentEntity(previousE);
previousE = 0;
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.iris.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"entity_render_context.MixinBlockEntityRenderDispatcher",
"entity_render_context.MixinCapeLayer",
"entity_render_context.MixinElytraLayer",
"entity_render_context.MixinEnderDragonRenderer",
"entity_render_context.MixinEntityRenderDispatcher",
"entity_render_context.MixinHorseArmorLayer",
"entity_render_context.MixinHumanoidArmorLayer",
Expand Down

0 comments on commit 04cdb32

Please sign in to comment.