Fix path preview rendering in 1.15
This commit is contained in:
@@ -3,15 +3,31 @@ package com.replaymod.core.events;
|
|||||||
|
|
||||||
import de.johni0702.minecraft.gui.utils.Event;
|
import de.johni0702.minecraft.gui.utils.Event;
|
||||||
|
|
||||||
|
//#if MC>=11500
|
||||||
|
//$$ import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
//#endif
|
||||||
|
|
||||||
public interface PostRenderWorldCallback {
|
public interface PostRenderWorldCallback {
|
||||||
Event<PostRenderWorldCallback> EVENT = Event.create((listeners) ->
|
Event<PostRenderWorldCallback> EVENT = Event.create((listeners) ->
|
||||||
|
//#if MC>=11500
|
||||||
|
//$$ (MatrixStack matrixStack) -> {
|
||||||
|
//#else
|
||||||
() -> {
|
() -> {
|
||||||
|
//#endif
|
||||||
for (PostRenderWorldCallback listener : listeners) {
|
for (PostRenderWorldCallback listener : listeners) {
|
||||||
listener.postRenderWorld();
|
listener.postRenderWorld(
|
||||||
|
//#if MC>=11500
|
||||||
|
//$$ matrixStack
|
||||||
|
//#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
void postRenderWorld();
|
void postRenderWorld(
|
||||||
|
//#if MC>=11500
|
||||||
|
//$$ MatrixStack matrixStack
|
||||||
|
//#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
|
|||||||
@@ -30,7 +30,11 @@ public class MixinGameRenderer {
|
|||||||
//$$ MatrixStack matrixStack,
|
//$$ MatrixStack matrixStack,
|
||||||
//#endif
|
//#endif
|
||||||
CallbackInfo ci) {
|
CallbackInfo ci) {
|
||||||
PostRenderWorldCallback.EVENT.invoker().postRenderWorld();
|
PostRenderWorldCallback.EVENT.invoker().postRenderWorld(
|
||||||
|
//#if MC>=11500
|
||||||
|
//$$ matrixStack
|
||||||
|
//#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "renderHand", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "renderHand", at = @At("HEAD"), cancellable = true)
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
import org.apache.commons.lang3.tuple.Triple;
|
import org.apache.commons.lang3.tuple.Triple;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
//#if MC>=11500
|
||||||
|
//$$ import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
//$$ import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#if FABRIC>=1
|
//#if FABRIC>=1
|
||||||
import com.replaymod.core.events.PostRenderWorldCallback;
|
import com.replaymod.core.events.PostRenderWorldCallback;
|
||||||
//#else
|
//#else
|
||||||
@@ -55,7 +60,11 @@ public class PathPreviewRenderer extends EventRegistrations {
|
|||||||
|
|
||||||
//#if FABRIC>=1
|
//#if FABRIC>=1
|
||||||
{ on(PostRenderWorldCallback.EVENT, this::renderCameraPath); }
|
{ on(PostRenderWorldCallback.EVENT, this::renderCameraPath); }
|
||||||
|
//#if MC>=11500
|
||||||
|
//$$ private void renderCameraPath(MatrixStack matrixStack) {
|
||||||
|
//#else
|
||||||
private void renderCameraPath() {
|
private void renderCameraPath() {
|
||||||
|
//#endif
|
||||||
//#else
|
//#else
|
||||||
//$$ @SubscribeEvent
|
//$$ @SubscribeEvent
|
||||||
//$$ public void renderCameraPath(RenderWorldLastEvent event) {
|
//$$ public void renderCameraPath(RenderWorldLastEvent event) {
|
||||||
@@ -80,18 +89,27 @@ public class PathPreviewRenderer extends EventRegistrations {
|
|||||||
int renderDistance = mc.options.viewDistance * 16;
|
int renderDistance = mc.options.viewDistance * 16;
|
||||||
int renderDistanceSquared = renderDistance * renderDistance;
|
int renderDistanceSquared = renderDistance * renderDistance;
|
||||||
|
|
||||||
//#if MC>=10800
|
Triple<Double, Double, Double> viewPos = Triple.of(
|
||||||
|
Entity_getX(view),
|
||||||
|
//#if MC>=10800 && MC<11500
|
||||||
// Eye height is subtracted to make path appear higher (at eye height) than it actually is (at foot height)
|
// Eye height is subtracted to make path appear higher (at eye height) than it actually is (at foot height)
|
||||||
Triple<Double, Double, Double> viewPos = Triple.of(Entity_getX(view), Entity_getY(view) - view.getStandingEyeHeight(), Entity_getZ(view));
|
Entity_getY(view) - view.getStandingEyeHeight(),
|
||||||
//#else
|
//#else
|
||||||
//$$ Triple<Double, Double, Double> viewPos = Triple.of(view.posX, view.posY, view.posZ);
|
//$$ Entity_getY(view),
|
||||||
//#endif
|
//#endif
|
||||||
|
Entity_getZ(view)
|
||||||
|
);
|
||||||
|
|
||||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||||
|
GL11.glPushMatrix();
|
||||||
try {
|
try {
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
//#if MC>=11500
|
||||||
|
//$$ RenderSystem.multMatrix(matrixStack.peek().getModel());
|
||||||
|
//#endif
|
||||||
|
|
||||||
for (PathSegment segment : path.getSegments()) {
|
for (PathSegment segment : path.getSegments()) {
|
||||||
Interpolator interpolator = segment.getInterpolator();
|
Interpolator interpolator = segment.getInterpolator();
|
||||||
Keyframe start = segment.getStartKeyframe();
|
Keyframe start = segment.getStartKeyframe();
|
||||||
@@ -180,6 +198,7 @@ public class PathPreviewRenderer extends EventRegistrations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
GL11.glPopMatrix();
|
||||||
GlStateManager.popAttributes();
|
GlStateManager.popAttributes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user