Skip to content

Commit

Permalink
Merge branch 'refs/heads/1.20.6' into 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jun 29, 2024
2 parents 7ce6e84 + e71b44a commit 1a27d33
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
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;getViewYRot(F)F"))
private void setNameTagId(T entity, Component component, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, float f, 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, float f, CallbackInfo ci) {
if (lastId != -100) {
CapturedRenderingState.INSTANCE.setCurrentEntity(lastId);
lastId = -100 ;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,9 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It
}

private static void handleBooleanValue(String key, String value, BooleanConsumer handler) {
if ("true".equals(value)) {
if ("true".equals(value) || "1".equals(value)) {
handler.accept(true);
} else if ("false".equals(value)) {
} else if ("false".equals(value) || "0".equals(value)) {
handler.accept(false);
} else {
Iris.logger.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false");
Expand All @@ -613,9 +613,9 @@ private static void handleBooleanDirective(String key, String value, String expe
return;
}

if ("true".equals(value)) {
if ("true".equals(value) || "1".equals(value)) {
handler.accept(OptionalBoolean.TRUE);
} else if ("false".equals(value)) {
} else if ("false".equals(value) || "0".equals(value)) {
handler.accept(OptionalBoolean.FALSE);
} else {
Iris.logger.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false");
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/mixins.iris.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"entity_render_context.MixinElytraLayer",
"entity_render_context.MixinEnderDragonRenderer",
"entity_render_context.MixinEntityRenderDispatcher",
"entity_render_context.MixinEntityRenderer",
"entity_render_context.MixinHorseArmorLayer",
"entity_render_context.MixinHumanoidArmorLayer",
"entity_render_context.MixinItemRenderer",
Expand Down

0 comments on commit 1a27d33

Please sign in to comment.