-
-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/1.20.3' into 1.20.6
- Loading branch information
Showing
3 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/net/irisshaders/iris/mixin/entity_render_context/MixinEntityRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package net.irisshaders.iris.mixin.entity_render_context; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import it.unimi.dsi.fastutil.objects.Object2IntFunction; | ||
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId; | ||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings; | ||
import net.irisshaders.iris.uniforms.CapturedRenderingState; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.entity.EntityRenderer; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.Entity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(EntityRenderer.class) | ||
public class MixinEntityRenderer<T extends Entity> { | ||
@Unique | ||
private static final NamespacedId NAME_TAG_ID = new NamespacedId("minecraft", "name_tag"); | ||
|
||
@Unique | ||
private int lastId = -100; | ||
|
||
@Inject(method = "renderNameTag", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getNameTagOffsetY()F")) | ||
private void setNameTagId(T entity, Component component, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { | ||
Object2IntFunction<NamespacedId> entityIds = WorldRenderingSettings.INSTANCE.getEntityIds(); | ||
|
||
if (entityIds == null) { | ||
return; | ||
} | ||
|
||
this.lastId = CapturedRenderingState.INSTANCE.getCurrentRenderedEntity(); | ||
|
||
int intId = entityIds.applyAsInt(NAME_TAG_ID); | ||
|
||
CapturedRenderingState.INSTANCE.setCurrentEntity(intId); | ||
} | ||
|
||
@Inject(method = "renderNameTag", at = @At("RETURN")) | ||
private void resetId(T entity, Component component, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { | ||
if (lastId != -100) { | ||
CapturedRenderingState.INSTANCE.setCurrentEntity(lastId); | ||
lastId = -100 ; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters