Fix some render stuff but it's still broken

This commit is contained in:
Brady 2020-01-09 20:09:49 -06:00
parent 36bbe430d4
commit 27cb708d40
No known key found for this signature in database
GPG Key ID: 73A788379A197567
4 changed files with 59 additions and 50 deletions

View File

@ -20,6 +20,7 @@ package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.RenderEvent;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.GameRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@ -30,14 +31,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinGameRenderer {
@Inject(
method = "updateCameraAndRender",
method = "func_228378_a_",
at = @At(
value = "INVOKE_STRING",
target = "Lnet/minecraft/profiler/IProfiler;endStartSection(Ljava/lang/String;)V",
args = {"ldc=hand"}
)
)
private void renderWorldPass(float partialTicks, long finishTimeNano, boolean idfk, CallbackInfo ci) {
private void renderWorldPass(float partialTicks, long finishTimeNano, MatrixStack idfk, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
}

View File

@ -23,19 +23,25 @@ import baritone.api.pathing.goals.GoalBlock;
import baritone.api.pathing.goals.GoalTwoBlocks;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.Helper;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.*;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.event.ClickEvent;
import org.lwjgl.BufferUtils;
import java.awt.*;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.Collections;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
import static org.lwjgl.opengl.GL11.*;
public class GuiClick extends Screen implements Helper {
@ -61,21 +67,21 @@ public class GuiClick extends Screen implements Helper {
public void render(int mouseX, int mouseY, float partialTicks) {
double mx = mc.mouseHelper.getMouseX();
double my = mc.mouseHelper.getMouseY();
//FIXME this entire class
/*my = mc.mainWindow.getHeight() - my;
my *= mc.mainWindow.getFramebufferHeight() / (double) mc.mainWindow.getHeight();
mx *= mc.mainWindow.getFramebufferWidth() / (double) mc.mainWindow.getWidth();
my = mc.func_228018_at_().getHeight() - my;
my *= mc.func_228018_at_().getFramebufferHeight() / (double) mc.func_228018_at_().getHeight();
mx *= mc.func_228018_at_().getFramebufferWidth() / (double) mc.func_228018_at_().getWidth();
Vec3d near = toWorld(mx, my, 0);
Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv
if (near != null && far != null) {
///
Vec3d viewerPos = new Vec3d(PathRenderer.getPositionVec().x(), PathRenderer.getPositionVec().y(), PathRenderer.getPositionVec().z());
Vec3d viewerPos = new Vec3d(PathRenderer.posX(), PathRenderer.posY(), PathRenderer.posZ());
ClientPlayerEntity player = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().player();
RayTraceResult result = player.world.rayTraceBlocks(new RayTraceContext(near.add(viewerPos), far.add(viewerPos), RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player));
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
currentMouseOver = ((BlockRayTraceResult) result).getPos();
}
}*/
}
}
@Override
@ -110,33 +116,32 @@ public class GuiClick extends Screen implements Helper {
}
public void onRender() {
//FIXME
/*GlStateManager.getMatrix(GL_MODELVIEW_MATRIX, (FloatBuffer) MODELVIEW.clear());
GlStateManager.getMatrix(GL_PROJECTION_MATRIX, (FloatBuffer) PROJECTION.clear());
GL11.glGetIntegerv(GL_VIEWPORT, (IntBuffer) VIEWPORT.clear());
glGetFloatv(GL_MODELVIEW_MATRIX, (FloatBuffer) MODELVIEW.clear());
glGetFloatv(GL_PROJECTION_MATRIX, (FloatBuffer) PROJECTION.clear());
glGetIntegerv(GL_VIEWPORT, (IntBuffer) VIEWPORT.clear());
if (currentMouseOver != null) {
Entity e = mc.getRenderViewEntity();
// drawSingleSelectionBox WHEN?
PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(currentMouseOver), Color.CYAN);
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
GlStateManager.enableBlend();
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
GlStateManager.color4f(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F);
GlStateManager.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
GlStateManager.disableTexture();
GlStateManager.depthMask(false);
GlStateManager.disableDepthTest();
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
RenderSystem.color4f(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F);
RenderSystem.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
RenderSystem.disableTexture();
RenderSystem.depthMask(false);
RenderSystem.disableDepthTest();
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
BetterBlockPos b = new BetterBlockPos(clickStart);
IRenderer.drawAABB(new AxisAlignedBB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
GlStateManager.enableDepthTest();
RenderSystem.enableDepthTest();
GlStateManager.depthMask(true);
GlStateManager.enableTexture();
GlStateManager.disableBlend();
RenderSystem.depthMask(true);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
}*/
}
}
private Vec3d toWorld(double x, double y, double z) {

View File

@ -21,6 +21,7 @@ import baritone.api.BaritoneAPI;
import baritone.api.Settings;
import baritone.api.utils.Helper;
import baritone.utils.accessor.IEntityRenderManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
@ -28,7 +29,7 @@ import net.minecraft.util.math.AxisAlignedBB;
import java.awt.*;
import static org.lwjgl.opengl.GL11.GL_LINES;
import static org.lwjgl.opengl.GL11.*;
public interface IRenderer {
@ -37,24 +38,23 @@ public interface IRenderer {
IEntityRenderManager renderManager = (IEntityRenderManager) Helper.mc.getRenderManager();
Settings settings = BaritoneAPI.getSettings();
//FIXME this entire class
static void glColor(Color color, float alpha) {
float[] colorComponents = color.getColorComponents(null);
//GlStateManager.color4f(colorComponents[0], colorComponents[1], colorComponents[2], alpha);
RenderSystem.color4f(colorComponents[0], colorComponents[1], colorComponents[2], alpha);
}
static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
/*GlStateManager.enableBlend();
GlStateManager.disableLighting();
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
RenderSystem.enableBlend();
RenderSystem.disableLighting();
RenderSystem.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
glColor(color, alpha);
GlStateManager.lineWidth(lineWidth);
GlStateManager.disableTexture();
GlStateManager.depthMask(false);
RenderSystem.lineWidth(lineWidth);
RenderSystem.disableTexture();
RenderSystem.depthMask(false);
if (ignoreDepth) {
GlStateManager.disableDepthTest();
}*/
RenderSystem.disableDepthTest();
}
}
static void startLines(Color color, float lineWidth, boolean ignoreDepth) {
@ -62,14 +62,14 @@ public interface IRenderer {
}
static void endLines(boolean ignoredDepth) {
/*if (ignoredDepth) {
GlStateManager.enableDepthTest();
if (ignoredDepth) {
RenderSystem.enableDepthTest();
}
GlStateManager.depthMask(true);
GlStateManager.enableTexture();
GlStateManager.enableLighting();
GlStateManager.disableBlend();*/
RenderSystem.depthMask(true);
RenderSystem.enableTexture();
RenderSystem.enableLighting();
RenderSystem.disableBlend();
}
static void drawAABB(AxisAlignedBB aabb) {

View File

@ -26,7 +26,9 @@ import baritone.api.utils.Helper;
import baritone.api.utils.interfaces.IGoalRenderPos;
import baritone.behavior.PathingBehavior;
import baritone.pathing.path.PathExecutor;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
@ -245,11 +247,12 @@ public final class PathRenderer implements IRenderer, Helper {
Helper.mc.getTextureManager().bindTexture(TEXTURE_BEACON_BEAM);
if (settings.renderGoalIgnoreDepth.value) {
// FIXME
//GlStateManager.disableDepthTest();
RenderSystem.disableDepthTest();
}
//FIXME
/* BeaconTileEntityRenderer.renderBeamSegment(
// FIXME
/*
BeaconTileEntityRenderer.renderBeamSegment(
goalPos.getX() - renderPosX,
-renderPosY,
goalPos.getZ() - renderPosZ,
@ -263,11 +266,11 @@ public final class PathRenderer implements IRenderer, Helper {
// Arguments filled by the private method lol
0.2D,
0.25D
);*/
);
*/
if (settings.renderGoalIgnoreDepth.value) {
//FIXME
//GlStateManager.enableDepthTest();
RenderSystem.enableDepthTest();
}
glPopAttrib();