Right clicking an Entity now spectates it
This commit is contained in:
@@ -54,6 +54,7 @@ public class ReplayMod {
|
||||
public static RecordingHandler recordingHandler;
|
||||
public static ChatMessageHandler chatMessageHandler = new ChatMessageHandler();
|
||||
public static KeyInputHandler keyInputHandler = new KeyInputHandler();
|
||||
public static MouseInputHandler mouseInputHandler = new MouseInputHandler();
|
||||
public static ReplaySender replaySender;
|
||||
public static int TP_DISTANCE_LIMIT = 128;
|
||||
public static ReplayFileAppender replayFileAppender;
|
||||
@@ -95,7 +96,7 @@ public class ReplayMod {
|
||||
MinecraftForge.EVENT_BUS.register(guiEventHandler = new GuiEventHandler());
|
||||
|
||||
FMLCommonHandler.instance().bus().register(keyInputHandler);
|
||||
MinecraftForge.EVENT_BUS.register(new MouseInputHandler());
|
||||
MinecraftForge.EVENT_BUS.register(mouseInputHandler);
|
||||
|
||||
recordingHandler = new RecordingHandler();
|
||||
FMLCommonHandler.instance().bus().register(recordingHandler);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.events;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
@@ -8,6 +9,7 @@ import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
@@ -17,7 +19,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
public class MinecraftTicker {
|
||||
|
||||
public static void runMouseKeyboardTick(Minecraft mc) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException {
|
||||
|
||||
ReplayMod.mouseInputHandler.mouseEvent(new MouseEvent());
|
||||
if(mc.thePlayer == null) return;
|
||||
try {
|
||||
mc.mcProfiler.endStartSection("mouse");
|
||||
|
||||
@@ -2,10 +2,6 @@ package eu.crushedpixel.replaymod.events;
|
||||
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
@@ -13,27 +9,21 @@ import org.lwjgl.input.Mouse;
|
||||
public class MouseInputHandler {
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private boolean leftDown = false;
|
||||
private boolean rightDown = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public void mouseEvent(MouseEvent event) {
|
||||
if(!ReplayHandler.isInReplay() || mc.objectMouseOver != null) return;
|
||||
if(Mouse.isButtonDown(0)) {
|
||||
if(!leftDown) {
|
||||
leftDown = true;
|
||||
mc.objectMouseOver = new MovingObjectPosition(MovingObjectPosition.MovingObjectType.MISS,
|
||||
new Vec3(0, 0, 0), EnumFacing.NORTH, new BlockPos(0, 0, 0));
|
||||
}
|
||||
} else {
|
||||
leftDown = false;
|
||||
if(!ReplayHandler.isInReplay() || !Mouse.isButtonDown(1)) {
|
||||
rightDown = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(Mouse.isButtonDown(1)) {
|
||||
if(!rightDown) {
|
||||
rightDown = true;
|
||||
mc.objectMouseOver = new MovingObjectPosition(MovingObjectPosition.MovingObjectType.MISS,
|
||||
new Vec3(0, 0, 0), EnumFacing.NORTH, new BlockPos(0, 0, 0));
|
||||
if(mc.pointedEntity != null && ReplayHandler.isCamera() && mc.currentScreen == null) {
|
||||
ReplayHandler.spectateEntity(mc.pointedEntity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rightDown = false;
|
||||
|
||||
Reference in New Issue
Block a user