Skip to content

Commit

Permalink
Fix blueprint rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightenom committed Aug 29, 2024
1 parent 0d1afb7 commit 81b4369
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/main/java/com/ldtteam/structurize/client/BlueprintHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.ldtteam.structurize.storage.rendering.types.BlueprintPreviewData;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.client.event.RenderLevelStageEvent;

import java.util.List;
Expand Down Expand Up @@ -70,6 +71,20 @@ public static BlueprintHandler getInstance()
* @param ctx rendering event
*/
public void draw(final BlueprintPreviewData previewData, final BlockPos pos, final RenderLevelStageEvent ctx)
{
final Vec3 viewPosition = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
ctx.getPoseStack().pushPose();
ctx.getPoseStack().translate(viewPosition.x(), viewPosition.y(), viewPosition.z());

internalBackportDraw(previewData, pos, ctx);

ctx.getPoseStack().popPose();
}

/**
* DO NOT USE IN MCOL
*/
public void internalBackportDraw(final BlueprintPreviewData previewData, final BlockPos pos, final RenderLevelStageEvent ctx)
{
if (previewData == null || previewData.getBlueprint() == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private static void renderBlueprints(final RenderLevelStageEvent event,
final BlockPos pos = previewData.getPos();
final Vec3 realRenderRootVecd = Vec3.atLowerCornerOf(pos.subtract(blueprint.getPrimaryBlockOffset())).subtract(viewPosition);

BlueprintHandler.getInstance().draw(previewData, pos, event);
BlueprintHandler.getInstance().internalBackportDraw(previewData, pos, event);

matrixStack.pushPose();
matrixStack.translate(realRenderRootVecd.x(), realRenderRootVecd.y(), realRenderRootVecd.z());
Expand Down

0 comments on commit 81b4369

Please sign in to comment.