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