New patches, New events, Camera bug fixes

This commit is contained in:
Rigamortis 2019-12-17 01:58:31 -09:00
parent d13b2e92f4
commit 7b3af30c6b
7 changed files with 89 additions and 8 deletions

View File

@ -53,7 +53,6 @@ public class Camera {
GlStateManager.disableLighting();
GlStateManager.disableAlpha();
GlStateManager.disableBlend();
GlStateManager.enableColorMaterial();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
frameBuffer.bindFramebufferTexture();
@ -68,6 +67,7 @@ public class Camera {
tessellator.draw();
frameBuffer.unbindFramebufferTexture();
GlStateManager.popMatrix();
}
}
@ -144,6 +144,7 @@ public class Camera {
frameBuffer.bindFramebuffer(true);
mc.entityRenderer.renderWorld(mc.timer.renderPartialTicks, System.nanoTime());
mc.entityRenderer.setupOverlayRendering();
frameBuffer.unbindFramebuffer();
this.setRecording(false);

View File

@ -0,0 +1,10 @@
package me.rigamortis.seppuku.api.event.render;
import me.rigamortis.seppuku.api.event.EventCancellable;
/**
* Author Seth
* 12/17/2019 @ 1:24 AM.
*/
public class EventRenderBlockDamage extends EventCancellable {
}

View File

@ -0,0 +1,10 @@
package me.rigamortis.seppuku.api.event.render;
import me.rigamortis.seppuku.api.event.EventCancellable;
/**
* Author Seth
* 12/17/2019 @ 1:23 AM.
*/
public class EventRenderSky extends EventCancellable {
}

View File

@ -32,7 +32,7 @@ public final class RearViewComponent extends ResizableHudComponent {
this.rearviewCamera.setRendering(true);
if (this.rearviewCamera.isValid()) {
this.rearviewCamera.setPos(Minecraft.getMinecraft().player.getPositionEyes(partialTicks));
this.rearviewCamera.setPos(Minecraft.getMinecraft().player.getPositionEyes(partialTicks).subtract(0, 1, 0));
this.rearviewCamera.setYaw(Minecraft.getMinecraft().player.rotationYaw - 180.0f);
this.rearviewCamera.setPitch(0.0f);
this.rearviewCamera.render(this.getX() + 2, this.getY() + 12, this.getX() + this.getW() - 2, this.getY() + this.getH() - 2);

View File

@ -4,9 +4,7 @@ import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.camera.Camera;
import me.rigamortis.seppuku.api.event.minecraft.EventUpdateFramebufferSize;
import me.rigamortis.seppuku.api.event.player.EventFovModifier;
import me.rigamortis.seppuku.api.event.render.EventHurtCamEffect;
import me.rigamortis.seppuku.api.event.render.EventRenderEntityOutlines;
import me.rigamortis.seppuku.api.event.render.EventRenderOverlay;
import me.rigamortis.seppuku.api.event.render.*;
import net.minecraft.client.Minecraft;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -73,6 +71,20 @@ public final class CameraManager {
}
}
@Listener
public void renderSky(EventRenderSky event) {
if (this.isCameraRecording()) {
event.setCanceled(true);
}
}
@Listener
public void renderBlockDamage(EventRenderBlockDamage event) {
if (this.isCameraRecording()) {
event.setCanceled(true);
}
}
public void addCamera(Camera cam) {
this.cameraList.add(cam);
}

View File

@ -76,6 +76,11 @@ public final class EntityPlayerSPPatch extends ClassPatch {
final EventPlayerUpdate event = new EventPlayerUpdate(stage);
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
if (stage == EventStageable.EventStage.PRE) {
//update all camera fbos after we render
Seppuku.INSTANCE.getCameraManager().update();
}
return event.isCanceled();
}
@ -130,9 +135,6 @@ public final class EntityPlayerSPPatch extends ClassPatch {
if (stage == EventStageable.EventStage.PRE) {
Seppuku.INSTANCE.getRotationManager().updateRotations();
Seppuku.INSTANCE.getPositionManager().updatePosition();
//update all camera fbos after we render
Seppuku.INSTANCE.getCameraManager().update();
}
//dispatch our event and pass the stage in

View File

@ -1,7 +1,9 @@
package me.rigamortis.seppuku.impl.patch;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.render.EventRenderBlockDamage;
import me.rigamortis.seppuku.api.event.render.EventRenderEntityOutlines;
import me.rigamortis.seppuku.api.event.render.EventRenderSky;
import me.rigamortis.seppuku.api.patch.ClassPatch;
import me.rigamortis.seppuku.api.patch.MethodPatch;
import me.rigamortis.seppuku.impl.management.PatchManager;
@ -42,4 +44,48 @@ public final class RenderGlobalPatch extends ClassPatch {
return event.isCanceled();
}
@MethodPatch(
mcpName = "renderSky",
notchName = "a",
mcpDesc = "(FI)V",
notchDesc = "(FI)V")
public void renderSky(MethodNode methodNode, PatchManager.Environment env) {
final InsnList insnList = new InsnList();
insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "renderSkyHook", "()Z", false));
final LabelNode jmp = new LabelNode();
insnList.add(new JumpInsnNode(IFEQ, jmp));
insnList.add(new InsnNode(RETURN));
insnList.add(jmp);
methodNode.instructions.insert(insnList);
}
public static boolean renderSkyHook() {
final EventRenderSky event = new EventRenderSky();
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
return event.isCanceled();
}
@MethodPatch(
mcpName = "drawBlockDamageTexture",
notchName = "a",
mcpDesc = "(Lnet/minecraft/client/renderer/Tessellator;Lnet/minecraft/client/renderer/BufferBuilder;Lnet/minecraft/entity/Entity;F)V",
notchDesc = "(Lbve;Lbuk;Lvg;F)V")
public void drawBlockDamageTexture(MethodNode methodNode, PatchManager.Environment env) {
final InsnList insnList = new InsnList();
insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "drawBlockDamageTextureHook", "()Z", false));
final LabelNode jmp = new LabelNode();
insnList.add(new JumpInsnNode(IFEQ, jmp));
insnList.add(new InsnNode(RETURN));
insnList.add(jmp);
methodNode.instructions.insert(insnList);
}
public static boolean drawBlockDamageTextureHook() {
final EventRenderBlockDamage event = new EventRenderBlockDamage();
Seppuku.INSTANCE.getEventManager().dispatchEvent(event);
return event.isCanceled();
}
}