Skip to content

Commit

Permalink
entity_flame special ID
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Jul 11, 2023
1 parent bbf4685 commit a008317
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public class MixinEntityRenderDispatcher {
"renderBlockShadow(Lcom/mojang/blaze3d/vertex/PoseStack$Pose;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;DDDFF)V";

@Unique
private static final NamespacedId id = new NamespacedId("minecraft", "entity_shadow");
private static final NamespacedId shadowId = new NamespacedId("minecraft", "entity_shadow");

@Unique
private static final NamespacedId flameId = new NamespacedId("minecraft", "entity_flame");

@Unique
private static int cachedId;
Expand All @@ -45,7 +48,7 @@ public class MixinEntityRenderDispatcher {
}

cachedId = CapturedRenderingState.INSTANCE.getCurrentRenderedEntity();
CapturedRenderingState.INSTANCE.setCurrentEntity(entityIds.getInt(id));
CapturedRenderingState.INSTANCE.setCurrentEntity(entityIds.getInt(shadowId));
}
}

Expand All @@ -55,6 +58,24 @@ private static void restoreShadow(PoseStack pPoseStack0, MultiBufferSource pMult
cachedId = 0;
}

@Inject(method = "renderFlame", at = @At("HEAD"))
private void iris$setFlameId(PoseStack pEntityRenderDispatcher0, MultiBufferSource pMultiBufferSource1, Entity pEntity2, CallbackInfo ci) {
Object2IntFunction<NamespacedId> entityIds = BlockRenderingSettings.INSTANCE.getEntityIds();

if (entityIds == null) {
return;
}

cachedId = CapturedRenderingState.INSTANCE.getCurrentRenderedEntity();
CapturedRenderingState.INSTANCE.setCurrentEntity(entityIds.getInt(flameId));
}

@Inject(method = "renderFlame", at = @At("RETURN"))
private void restoreFlameId(PoseStack pEntityRenderDispatcher0, MultiBufferSource pMultiBufferSource1, Entity pEntity2, CallbackInfo ci) {
CapturedRenderingState.INSTANCE.setCurrentEntity(cachedId);
cachedId = 0;
}

// The underlying method called by renderShadow.
@Inject(method = RENDER_BLOCK_SHADOW, at = @At("HEAD"), cancellable = true)
private static void renderBlockShadow(PoseStack.Pose pose, VertexConsumer vc, LevelReader level, BlockPos pos,
Expand Down

0 comments on commit a008317

Please sign in to comment.