Split mod into core, recording, replay, render[todo], paths[todo] and extras[wip] modules
Move everything to com.replaymod package Add KeyBindingRegistry and SettingsRegistry Recreate settings GUI with new GUI API and dynamically from SettingsRegistry Use ReplayFile from ReplayStudio ReplayHandler is now object oriented Add GuiOverlay, GuiSlider and GuiTexturedButton to GUI API Rewrite both overlays to use new GUI API Fix size capping in vertical and horizontal layout Allow CustomLayouts to have parents Fix tooltip rendering when close to screen border Allow changing of columns in GridLayout
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.events;
|
||||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class ReplayExitEvent extends Event {
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.events.handlers;
|
||||
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@@ -13,18 +11,20 @@ public class CrosshairRenderHandler {
|
||||
@SubscribeEvent
|
||||
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
||||
//Crosshair should only render if hovered Entity can actually be spectated
|
||||
if(ReplayHandler.isInReplay() && ReplayHandler.isCamera() && event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||
boolean cancel = !SpectatingHandler.canSpectate(mc.pointedEntity);
|
||||
event.setCanceled(cancel);
|
||||
}
|
||||
// TODO
|
||||
// if(ReplayHandler.isInReplay() && ReplayHandler.isCameraView() && event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||
// boolean cancel = !SpectatingHandler.canSpectate(mc.pointedEntity);
|
||||
// event.setCanceled(cancel);
|
||||
// }
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void preChatRender(RenderGameOverlayEvent.Pre event) {
|
||||
if(ReplayHandler.isInReplay() && ReplayHandler.isCamera() && event.type == RenderGameOverlayEvent.ElementType.CHAT) {
|
||||
//when a crosshair was displayed, the background of the lowest line of chat would be opaque
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
// TODO
|
||||
// if(ReplayHandler.isInReplay() && ReplayHandler.isCameraView() && event.type == RenderGameOverlayEvent.ElementType.CHAT) {
|
||||
// //when a crosshair was displayed, the background of the lowest line of chat would be opaque
|
||||
// GlStateManager.enableTexture2D();
|
||||
// GlStateManager.disableBlend();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package eu.crushedpixel.replaymod.events.handlers;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.gui.GuiReplaySettings;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
import eu.crushedpixel.replaymod.gui.GuiReplaySettings;
|
||||
import eu.crushedpixel.replaymod.gui.online.GuiLoginPrompt;
|
||||
import eu.crushedpixel.replaymod.gui.online.GuiReplayCenter;
|
||||
import eu.crushedpixel.replaymod.gui.replayeditor.GuiReplayEditor;
|
||||
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayProcess;
|
||||
import eu.crushedpixel.replaymod.settings.ReplaySettings;
|
||||
import eu.crushedpixel.replaymod.studio.VersionValidator;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
@@ -26,7 +23,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiEventHandler {
|
||||
@@ -54,19 +50,20 @@ public class GuiEventHandler {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(ReplayHandler.isInReplay()) ReplayHandler.setInReplay(false);
|
||||
}
|
||||
|
||||
if(!ReplayMod.apiClient.isLoggedIn()) return;
|
||||
|
||||
if(event.gui instanceof GuiChat || event.gui instanceof GuiInventory) {
|
||||
if(ReplayHandler.isInReplay()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
// TODO
|
||||
// if(ReplayHandler.isInReplay()) {
|
||||
// event.setCanceled(true);
|
||||
// }
|
||||
} else if(event.gui instanceof GuiDisconnected) {
|
||||
if(!ReplayHandler.isInReplay() && System.currentTimeMillis() - ReplayHandler.lastExit < 5000) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
// TODO
|
||||
// if(!ReplayHandler.isInReplay() && System.currentTimeMillis() - ReplayHandler.lastExit < 5000) {
|
||||
// event.setCanceled(true);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,20 +118,7 @@ public class GuiEventHandler {
|
||||
public void onInit(InitGuiEvent event) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = event.buttonList;
|
||||
if(event.gui instanceof GuiIngameMenu && ReplayHandler.isInReplay()) {
|
||||
ReplayMod.replaySender.setReplaySpeed(0);
|
||||
for(GuiButton b : new ArrayList<GuiButton>(buttonList)) {
|
||||
if(b.id == 1) {
|
||||
b.displayString = I18n.format("replaymod.gui.exit");
|
||||
b.yPosition -= 24 * 2;
|
||||
b.id = GuiConstants.EXIT_REPLAY_BUTTON;
|
||||
} else if(b.id >= 5 && b.id <= 7) {
|
||||
buttonList.remove(b);
|
||||
} else if(b.id != 4) {
|
||||
b.yPosition -= 24 * 2;
|
||||
}
|
||||
}
|
||||
} else if(event.gui instanceof GuiMainMenu) {
|
||||
if(event.gui instanceof GuiMainMenu) {
|
||||
int i1 = event.gui.height / 4 + 24 + 10;
|
||||
|
||||
for(GuiButton b : buttonList) {
|
||||
@@ -171,9 +155,7 @@ public class GuiEventHandler {
|
||||
public void onButton(ActionPerformedEvent event) {
|
||||
if(!event.button.enabled) return;
|
||||
if(event.gui instanceof GuiMainMenu) {
|
||||
if(event.button.id == GuiConstants.REPLAY_MANAGER_BUTTON_ID) {
|
||||
mc.displayGuiScreen(new GuiReplayViewer());
|
||||
} else if(event.button.id == GuiConstants.REPLAY_CENTER_BUTTON_ID) {
|
||||
if(event.button.id == GuiConstants.REPLAY_CENTER_BUTTON_ID) {
|
||||
if(ReplayMod.apiClient.isLoggedIn()) {
|
||||
mc.displayGuiScreen(new GuiReplayCenter());
|
||||
} else {
|
||||
@@ -183,17 +165,7 @@ public class GuiEventHandler {
|
||||
mc.displayGuiScreen(new GuiReplayEditor());
|
||||
}
|
||||
} else if(event.gui instanceof GuiOptions && event.button.id == GuiConstants.REPLAY_OPTIONS_BUTTON_ID) {
|
||||
mc.displayGuiScreen(new GuiReplaySettings(event.gui));
|
||||
}
|
||||
|
||||
if(ReplayHandler.isInReplay() && event.gui instanceof GuiIngameMenu && event.button.id == GuiConstants.EXIT_REPLAY_BUTTON) {
|
||||
if(ReplayHandler.isInPath()) ReplayProcess.stopReplayProcess(false);
|
||||
|
||||
event.button.enabled = false;
|
||||
|
||||
mc.displayGuiScreen(new GuiMainMenu());
|
||||
|
||||
ReplayHandler.endReplay();
|
||||
new GuiReplaySettings(event.gui, ReplayMod.instance.getSettingsRegistry()).display();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
package eu.crushedpixel.replaymod.events.handlers;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class MinecraftTicker {
|
||||
|
||||
public static void runMouseKeyboardTick(Minecraft mc) {
|
||||
ReplayMod.mouseInputHandler.mouseEvent(new MouseEvent());
|
||||
// TODO
|
||||
// ReplayMod.mouseInputHandler.mouseEvent(new MouseEvent());
|
||||
if(mc.thePlayer == null) return;
|
||||
try {
|
||||
mc.mcProfiler.endStartSection("mouse");
|
||||
|
||||
@@ -1,51 +1,45 @@
|
||||
package eu.crushedpixel.replaymod.events.handlers;
|
||||
|
||||
import eu.crushedpixel.replaymod.entities.CameraEntity;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class MouseInputHandler {
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private boolean rightDown = false;
|
||||
private boolean leftDown = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public void mouseEvent(MouseEvent event) {
|
||||
if(!ReplayHandler.isInReplay()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.dwheel != 0 && mc.currentScreen == null) {
|
||||
boolean increase = event.dwheel > 0;
|
||||
CameraEntity.modifyCameraSpeed(increase);
|
||||
}
|
||||
|
||||
if(Mouse.isButtonDown(0)) {
|
||||
if(!leftDown) {
|
||||
leftDown = true;
|
||||
if(mc.pointedEntity != null && ReplayHandler.isCamera() && mc.currentScreen == null) {
|
||||
if(SpectatingHandler.canSpectate(mc.pointedEntity))
|
||||
ReplayHandler.spectateEntity(mc.pointedEntity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
leftDown = false;
|
||||
}
|
||||
|
||||
if(Mouse.isButtonDown(1)) {
|
||||
if(!rightDown) {
|
||||
rightDown = true;
|
||||
if(mc.pointedEntity != null && ReplayHandler.isCamera() && mc.currentScreen == null) {
|
||||
if(SpectatingHandler.canSpectate(mc.pointedEntity))
|
||||
ReplayHandler.spectateEntity(mc.pointedEntity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rightDown = false;
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
// private final Minecraft mc = Minecraft.getMinecraft();
|
||||
// private boolean rightDown = false;
|
||||
// private boolean leftDown = false;
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public void mouseEvent(MouseEvent event) {
|
||||
// if(!ReplayHandler.isInReplay()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(event.dwheel != 0 && mc.currentScreen == null) {
|
||||
// boolean increase = event.dwheel > 0;
|
||||
// CameraEntity.modifyCameraSpeed(increase);
|
||||
// }
|
||||
//
|
||||
// if(Mouse.isButtonDown(0)) {
|
||||
// if(!leftDown) {
|
||||
// leftDown = true;
|
||||
// if(mc.pointedEntity != null && ReplayHandler.isCameraView() && mc.currentScreen == null) {
|
||||
// if(SpectatingHandler.canSpectate(mc.pointedEntity))
|
||||
// ReplayHandler.spectateEntity(mc.pointedEntity);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// leftDown = false;
|
||||
// }
|
||||
//
|
||||
// if(Mouse.isButtonDown(1)) {
|
||||
// if(!rightDown) {
|
||||
// rightDown = true;
|
||||
// if(mc.pointedEntity != null && ReplayHandler.isCameraView() && mc.currentScreen == null) {
|
||||
// if(SpectatingHandler.canSpectate(mc.pointedEntity))
|
||||
// ReplayHandler.spectateEntity(mc.pointedEntity);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// rightDown = false;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,369 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.events.handlers;
|
||||
|
||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||
import eu.crushedpixel.replaymod.utils.Objects;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.*;
|
||||
import net.minecraft.network.play.server.S14PacketEntity.S17PacketEntityLookMove;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||
|
||||
public class RecordingHandler {
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private Double lastX = null, lastY = null, lastZ = null;
|
||||
private ItemStack[] playerItems = new ItemStack[5];
|
||||
private int ticksSinceLastCorrection = 0;
|
||||
private boolean wasSleeping = false;
|
||||
private int lastRiding = -1;
|
||||
private Integer rotationYawHeadBefore = null;
|
||||
|
||||
public void onPlayerJoin() {
|
||||
try {
|
||||
if(!ConnectionEventHandler.isRecording()) return;
|
||||
|
||||
ConnectionEventHandler.insertPacket(spawnPlayer(mc.thePlayer));
|
||||
} catch(Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerRespawn() {
|
||||
if(!ConnectionEventHandler.isRecording()) return;
|
||||
try {
|
||||
ConnectionEventHandler.insertPacket(spawnPlayer(mc.thePlayer));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private S0CPacketSpawnPlayer spawnPlayer(EntityPlayer player) {
|
||||
try {
|
||||
S0CPacketSpawnPlayer packet = new S0CPacketSpawnPlayer();
|
||||
|
||||
ByteBuf bb = Unpooled.buffer();
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
pb.writeVarIntToBuffer(player.getEntityId());
|
||||
pb.writeUuid(EntityPlayer.getUUID(player.getGameProfile()));
|
||||
|
||||
pb.writeInt(MathHelper.floor_double(player.posX * 32.0D));
|
||||
pb.writeInt(MathHelper.floor_double(player.posY * 32.0D));
|
||||
pb.writeInt(MathHelper.floor_double(player.posZ * 32.0D));
|
||||
pb.writeByte((byte) ((int) (player.rotationYaw * 256.0F / 360.0F)));
|
||||
pb.writeByte((byte) ((int) (player.rotationPitch * 256.0F / 360.0F)));
|
||||
|
||||
ItemStack itemstack = player.inventory.getCurrentItem();
|
||||
pb.writeShort(itemstack == null ? 0 : Item.getIdFromItem(itemstack.getItem()));
|
||||
|
||||
player.getDataWatcher().writeTo(pb);
|
||||
|
||||
packet.readPacketData(pb);
|
||||
|
||||
return packet;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetVars() {
|
||||
lastX = lastY = lastZ = null;
|
||||
rotationYawHeadBefore = null;
|
||||
playerItems = new ItemStack[5];
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerTick(PlayerTickEvent e) {
|
||||
if(!ConnectionEventHandler.isRecording()) return;
|
||||
try {
|
||||
if(e.player != mc.thePlayer) return;
|
||||
if(!ConnectionEventHandler.isRecording()) return;
|
||||
|
||||
boolean force = false;
|
||||
if(lastX == null || lastY == null || lastZ == null) {
|
||||
force = true;
|
||||
lastX = e.player.posX;
|
||||
lastY = e.player.posY;
|
||||
lastZ = e.player.posZ;
|
||||
}
|
||||
|
||||
ticksSinceLastCorrection++;
|
||||
if(ticksSinceLastCorrection >= 100) {
|
||||
ticksSinceLastCorrection = 0;
|
||||
force = true;
|
||||
}
|
||||
|
||||
double dx = e.player.posX - lastX;
|
||||
double dy = e.player.posY - lastY;
|
||||
double dz = e.player.posZ - lastZ;
|
||||
|
||||
lastX = e.player.posX;
|
||||
lastY = e.player.posY;
|
||||
lastZ = e.player.posZ;
|
||||
|
||||
Packet packet;
|
||||
if(force || Math.abs(dx) > 4.0 || Math.abs(dy) > 4.0 || Math.abs(dz) > 4.0) {
|
||||
int x = MathHelper.floor_double(e.player.posX * 32.0D);
|
||||
int y = MathHelper.floor_double(e.player.posY * 32.0D);
|
||||
int z = MathHelper.floor_double(e.player.posZ * 32.0D);
|
||||
byte yaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
||||
byte pitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
||||
packet = new S18PacketEntityTeleport(e.player.getEntityId(), x, y, z, yaw, pitch, e.player.onGround);
|
||||
} else {
|
||||
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
||||
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
||||
|
||||
packet = new S17PacketEntityLookMove(e.player.getEntityId(),
|
||||
(byte) Math.round(dx * 32), (byte) Math.round(dy * 32), (byte) Math.round(dz * 32),
|
||||
newYaw, newPitch, e.player.onGround);
|
||||
}
|
||||
|
||||
ConnectionEventHandler.insertPacket(packet);
|
||||
|
||||
//HEAD POS
|
||||
int rotationYawHead = ((int)(e.player.rotationYawHead * 256.0F / 360.0F));
|
||||
|
||||
if(!Objects.equals(rotationYawHead, rotationYawHeadBefore)) {
|
||||
S19PacketEntityHeadLook head = new S19PacketEntityHeadLook();
|
||||
ByteBuf bb1 = Unpooled.buffer();
|
||||
PacketBuffer pb1 = new PacketBuffer(bb1);
|
||||
|
||||
pb1.writeVarIntToBuffer(e.player.getEntityId());
|
||||
pb1.writeByte(rotationYawHead);
|
||||
|
||||
head.readPacketData(pb1);
|
||||
|
||||
ConnectionEventHandler.insertPacket(head);
|
||||
|
||||
rotationYawHeadBefore = rotationYawHead;
|
||||
}
|
||||
|
||||
S12PacketEntityVelocity vel = new S12PacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ);
|
||||
ConnectionEventHandler.insertPacket(vel);
|
||||
|
||||
//Animation Packets
|
||||
//Swing Animation
|
||||
if(e.player.swingProgressInt == 1) {
|
||||
S0BPacketAnimation pac = new S0BPacketAnimation();
|
||||
|
||||
ByteBuf bb = Unpooled.buffer();
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
pb.writeVarIntToBuffer(e.player.getEntityId());
|
||||
pb.writeByte(0);
|
||||
|
||||
pac.readPacketData(pb);
|
||||
|
||||
ConnectionEventHandler.insertPacket(pac);
|
||||
}
|
||||
|
||||
/*
|
||||
//Potion Effect Handling
|
||||
List<Integer> found = new ArrayList<Integer>();
|
||||
for(PotionEffect pe : (Collection<PotionEffect>)e.player.getActivePotionEffects()) {
|
||||
found.add(pe.getPotionID());
|
||||
if(lastEffects.contains(found)) continue;
|
||||
S1DPacketEntityEffect pee = new S1DPacketEntityEffect(entityID, pe);
|
||||
ConnectionEventHandler.insertPacket(pee);
|
||||
}
|
||||
|
||||
for(int id : lastEffects) {
|
||||
if(!found.contains(id)) {
|
||||
S1EPacketRemoveEntityEffect pre = new S1EPacketRemoveEntityEffect(entityID, new PotionEffect(id, 0));
|
||||
ConnectionEventHandler.insertPacket(pre);
|
||||
}
|
||||
}
|
||||
|
||||
lastEffects = found;
|
||||
*/
|
||||
|
||||
//Inventory Handling
|
||||
if(playerItems[0] != mc.thePlayer.getHeldItem()) {
|
||||
playerItems[0] = mc.thePlayer.getHeldItem();
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 0, playerItems[0]);
|
||||
ConnectionEventHandler.insertPacket(pee);
|
||||
}
|
||||
|
||||
if(playerItems[1] != mc.thePlayer.inventory.armorInventory[0]) {
|
||||
playerItems[1] = mc.thePlayer.inventory.armorInventory[0];
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 1, playerItems[1]);
|
||||
ConnectionEventHandler.insertPacket(pee);
|
||||
}
|
||||
|
||||
if(playerItems[2] != mc.thePlayer.inventory.armorInventory[1]) {
|
||||
playerItems[2] = mc.thePlayer.inventory.armorInventory[1];
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 2, playerItems[2]);
|
||||
ConnectionEventHandler.insertPacket(pee);
|
||||
}
|
||||
|
||||
if(playerItems[3] != mc.thePlayer.inventory.armorInventory[2]) {
|
||||
playerItems[3] = mc.thePlayer.inventory.armorInventory[2];
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 3, playerItems[3]);
|
||||
ConnectionEventHandler.insertPacket(pee);
|
||||
}
|
||||
|
||||
if(playerItems[4] != mc.thePlayer.inventory.armorInventory[3]) {
|
||||
playerItems[4] = mc.thePlayer.inventory.armorInventory[3];
|
||||
S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 4, playerItems[4]);
|
||||
ConnectionEventHandler.insertPacket(pee);
|
||||
}
|
||||
|
||||
//Leaving Ride
|
||||
|
||||
if((!mc.thePlayer.isRiding() && lastRiding != -1) ||
|
||||
(mc.thePlayer.isRiding() && lastRiding != mc.thePlayer.ridingEntity.getEntityId())) {
|
||||
if(!mc.thePlayer.isRiding()) {
|
||||
lastRiding = -1;
|
||||
} else {
|
||||
lastRiding = mc.thePlayer.ridingEntity.getEntityId();
|
||||
}
|
||||
|
||||
S1BPacketEntityAttach pea = new S1BPacketEntityAttach();
|
||||
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
PacketBuffer pbuf = new PacketBuffer(buf);
|
||||
|
||||
pbuf.writeInt(e.player.getEntityId());
|
||||
pbuf.writeInt(lastRiding);
|
||||
pbuf.writeBoolean(false);
|
||||
|
||||
pea.readPacketData(pbuf);
|
||||
|
||||
ConnectionEventHandler.insertPacket(pea);
|
||||
}
|
||||
|
||||
//Sleeping
|
||||
if(!mc.thePlayer.isPlayerSleeping() && wasSleeping) {
|
||||
S0BPacketAnimation pac = new S0BPacketAnimation();
|
||||
|
||||
ByteBuf bb = Unpooled.buffer();
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
pb.writeVarIntToBuffer(e.player.getEntityId());
|
||||
pb.writeByte(2);
|
||||
|
||||
pac.readPacketData(pb);
|
||||
|
||||
ConnectionEventHandler.insertPacket(pac);
|
||||
|
||||
wasSleeping = false;
|
||||
}
|
||||
|
||||
} catch(Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPickupItem(ItemPickupEvent event) {
|
||||
if(!ConnectionEventHandler.isRecording()) return;
|
||||
try {
|
||||
ConnectionEventHandler.insertPacket(new S0DPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId()));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onStartEating(PlayerUseItemEvent.Start event) {
|
||||
if(!ConnectionEventHandler.isRecording()) return;
|
||||
try {
|
||||
if(!event.entityPlayer.isEating()) return;
|
||||
S0BPacketAnimation packet = new S0BPacketAnimation();
|
||||
|
||||
ByteBuf bb = Unpooled.buffer();
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
pb.writeVarIntToBuffer(event.entityPlayer.getEntityId());
|
||||
pb.writeByte(3);
|
||||
|
||||
packet.readPacketData(pb);
|
||||
|
||||
ConnectionEventHandler.insertPacket(packet);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onSleep(PlayerSleepInBedEvent event) {
|
||||
if(!ConnectionEventHandler.isRecording()) return;
|
||||
try {
|
||||
if(event.entityPlayer != mc.thePlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println(event.getResult());
|
||||
S0APacketUseBed pub = new S0APacketUseBed();
|
||||
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
PacketBuffer pbuf = new PacketBuffer(buf);
|
||||
|
||||
pbuf.writeVarIntToBuffer(event.entityPlayer.getEntityId());
|
||||
pbuf.writeBlockPos(event.pos);
|
||||
|
||||
pub.readPacketData(pbuf);
|
||||
|
||||
ConnectionEventHandler.insertPacket(pub);
|
||||
|
||||
wasSleeping = true;
|
||||
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void enterMinecart(MinecartInteractEvent event) {
|
||||
if(!ConnectionEventHandler.isRecording()) return;
|
||||
try {
|
||||
if(event.player != mc.thePlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
S1BPacketEntityAttach pea = new S1BPacketEntityAttach();
|
||||
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
PacketBuffer pbuf = new PacketBuffer(buf);
|
||||
|
||||
pbuf.writeInt(event.player.getEntityId());
|
||||
pbuf.writeInt(event.minecart.getEntityId());
|
||||
pbuf.writeBoolean(false);
|
||||
|
||||
pea.readPacketData(pbuf);
|
||||
|
||||
ConnectionEventHandler.insertPacket(pea);
|
||||
|
||||
lastRiding = event.minecart.getEntityId();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void checkForGamePaused(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
if (!ConnectionEventHandler.isRecording()) return;
|
||||
if (mc.isIntegratedServerRunning()) {
|
||||
IntegratedServer server = mc.getIntegratedServer();
|
||||
if (server != null && server.isGamePaused) {
|
||||
ConnectionEventHandler.notifyServerPaused();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,10 @@
|
||||
package eu.crushedpixel.replaymod.events.handlers;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.chat.ChatMessageHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayProcess;
|
||||
import eu.crushedpixel.replaymod.video.ReplayScreenshot;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
public class TickAndRenderListener {
|
||||
|
||||
@@ -30,75 +22,78 @@ public class TickAndRenderListener {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderWorld(RenderWorldLastEvent event) throws Exception {
|
||||
if(!ReplayHandler.isInReplay()) return; //If not in Replay, cancel
|
||||
if (ReplayProcess.isVideoRecording()) return; // If recording, cancel
|
||||
|
||||
if(requestScreenshot == 1) {
|
||||
mc.addScheduledTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.savingthumb", ChatMessageHandler.ChatMessageType.INFORMATION);
|
||||
ReplayScreenshot.prepareScreenshot();
|
||||
requestScreenshot = 2;
|
||||
}
|
||||
});
|
||||
} else if(requestScreenshot == 2) {
|
||||
mc.addScheduledTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ReplayScreenshot.saveScreenshot();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(ReplayHandler.isInPath()) ReplayProcess.tickReplay(false);
|
||||
if(ReplayHandler.isCamera()) mc.setRenderViewEntity(ReplayHandler.getCameraEntity());
|
||||
|
||||
if(mc.isGamePaused() && ReplayHandler.isInPath()) {
|
||||
mc.isGamePaused = false;
|
||||
}
|
||||
// TODO
|
||||
// if(!ReplayHandler.isInReplay()) return; //If not in Replay, cancel
|
||||
// if (ReplayProcess.isVideoRecording()) return; // If recording, cancel
|
||||
//
|
||||
// if(requestScreenshot == 1) {
|
||||
// mc.addScheduledTask(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.savingthumb", ChatMessageHandler.ChatMessageType.INFORMATION);
|
||||
// ReplayScreenshot.prepareScreenshot();
|
||||
// requestScreenshot = 2;
|
||||
// }
|
||||
// });
|
||||
// } else if(requestScreenshot == 2) {
|
||||
// mc.addScheduledTask(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// ReplayScreenshot.saveScreenshot();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// if(ReplayHandler.isInPath()) ReplayProcess.tickReplay(false);
|
||||
// if(ReplayHandler.isCameraView()) mc.setRenderViewEntity(ReplayHandler.getCameraEntity());
|
||||
//
|
||||
// if(mc.isGamePaused() && ReplayHandler.isInPath()) {
|
||||
// mc.isGamePaused = false;
|
||||
// }
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
||||
if(!ReplayHandler.isInReplay() || ReplayProcess.isVideoRecording()) return;
|
||||
|
||||
if(ReplayHandler.getCameraEntity() != null)
|
||||
ReplayHandler.getCameraEntity().updateMovement();
|
||||
if(ReplayHandler.isInPath()) {
|
||||
ReplayProcess.tickReplay(true);
|
||||
} else onMouseMove(new MouseEvent());
|
||||
|
||||
FMLCommonHandler.instance().fireKeyInput();
|
||||
// TODO
|
||||
// if(!ReplayHandler.isInReplay() || ReplayProcess.isVideoRecording()) return;
|
||||
//
|
||||
// if(ReplayHandler.getCameraEntity() != null)
|
||||
// ReplayHandler.getCameraEntity().updateMovement();
|
||||
// if(ReplayHandler.isInPath()) {
|
||||
// ReplayProcess.tickReplay(true);
|
||||
// } else onMouseMove(new MouseEvent());
|
||||
//
|
||||
// FMLCommonHandler.instance().fireKeyInput();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMouseMove(MouseEvent event) {
|
||||
if(!ReplayHandler.isInReplay()) return;
|
||||
|
||||
mc.mcProfiler.startSection("mouse");
|
||||
|
||||
if(Minecraft.isRunningOnMac && mc.inGameHasFocus && !Mouse.isInsideWindow()) {
|
||||
Mouse.setGrabbed(false);
|
||||
Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2);
|
||||
Mouse.setGrabbed(true);
|
||||
}
|
||||
|
||||
if(mc.inGameHasFocus && !(ReplayHandler.isInPath())) {
|
||||
mc.mouseHelper.mouseXYChange();
|
||||
float f1 = mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
|
||||
float f2 = f1 * f1 * f1 * 8.0F;
|
||||
float f3 = (float) mc.mouseHelper.deltaX * f2;
|
||||
float f4 = (float) mc.mouseHelper.deltaY * f2;
|
||||
byte b0 = 1;
|
||||
|
||||
if(mc.gameSettings.invertMouse) {
|
||||
b0 = -1;
|
||||
}
|
||||
|
||||
if(ReplayHandler.getCameraEntity() != null) {
|
||||
ReplayHandler.getCameraEntity().setAngles(f3, f4 * (float) b0);
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
// if(!ReplayHandler.isInReplay()) return;
|
||||
//
|
||||
// mc.mcProfiler.startSection("mouse");
|
||||
//
|
||||
// if(Minecraft.isRunningOnMac && mc.inGameHasFocus && !Mouse.isInsideWindow()) {
|
||||
// Mouse.setGrabbed(false);
|
||||
// Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2);
|
||||
// Mouse.setGrabbed(true);
|
||||
// }
|
||||
//
|
||||
// if(mc.inGameHasFocus && !(ReplayHandler.isInPath())) {
|
||||
// mc.mouseHelper.mouseXYChange();
|
||||
// float f1 = mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
|
||||
// float f2 = f1 * f1 * f1 * 8.0F;
|
||||
// float f3 = (float) mc.mouseHelper.deltaX * f2;
|
||||
// float f4 = (float) mc.mouseHelper.deltaY * f2;
|
||||
// byte b0 = 1;
|
||||
//
|
||||
// if(mc.gameSettings.invertMouse) {
|
||||
// b0 = -1;
|
||||
// }
|
||||
//
|
||||
// if(ReplayHandler.getCameraEntity() != null) {
|
||||
// ReplayHandler.getCameraEntity().setAngles(f3, f4 * (float) b0);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
package eu.crushedpixel.replaymod.events.handlers.keyboard;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.entities.CameraEntity.MoveDirection;
|
||||
import eu.crushedpixel.replaymod.events.handlers.TickAndRenderListener;
|
||||
import eu.crushedpixel.replaymod.gui.GuiAssetManager;
|
||||
import eu.crushedpixel.replaymod.gui.GuiKeyframeRepository;
|
||||
import eu.crushedpixel.replaymod.gui.GuiMouseInput;
|
||||
import eu.crushedpixel.replaymod.gui.GuiObjectManager;
|
||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
||||
import eu.crushedpixel.replaymod.registry.PlayerHandler;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class KeyInputHandler {
|
||||
|
||||
@@ -25,200 +11,200 @@ public class KeyInputHandler {
|
||||
private long prevKeysDown = Sys.getTime();
|
||||
|
||||
public void onKeyInput() throws Exception {
|
||||
if(!ReplayHandler.isInReplay()) return;
|
||||
|
||||
KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings;
|
||||
|
||||
boolean speedup = false;
|
||||
|
||||
if(mc.currentScreen == null) {
|
||||
boolean forward = false, backward = false, left = false, right = false, up = false, down = false;
|
||||
|
||||
if(!ReplayHandler.isInPath()) {
|
||||
for(KeyBinding kb : keyBindings) {
|
||||
if(!kb.isKeyDown()) continue;
|
||||
if(ReplayHandler.isCamera()) {
|
||||
if(kb.getKeyDescription().equals("key.forward")) {
|
||||
forward = true;
|
||||
speedup = true;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.back")) {
|
||||
backward = true;
|
||||
speedup = true;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.jump")) {
|
||||
up = true;
|
||||
speedup = true;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.left")) {
|
||||
left = true;
|
||||
speedup = true;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.right")) {
|
||||
right = true;
|
||||
speedup = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.sneak")) {
|
||||
if(ReplayHandler.isCamera()) {
|
||||
down = true;
|
||||
speedup = true;
|
||||
}
|
||||
ReplayHandler.spectateCamera();
|
||||
}
|
||||
}
|
||||
|
||||
forwardCameraMovement(forward, backward, left, right, up, down);
|
||||
}
|
||||
}
|
||||
|
||||
if(ReplayHandler.getCameraEntity() != null) {
|
||||
if(speedup) {
|
||||
ReplayHandler.getCameraEntity().speedUp();
|
||||
prevKeysDown = Sys.getTime();
|
||||
} else {
|
||||
if(Sys.getTime() - prevKeysDown > 100) {
|
||||
ReplayHandler.getCameraEntity().stopSpeedUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void keyInput(InputEvent.KeyInputEvent event) {
|
||||
try {
|
||||
onKeyInput();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings;
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for(KeyBinding kb : keyBindings) {
|
||||
if(!kb.isKeyDown()) continue;
|
||||
|
||||
handleCustomKeybindings(kb, found, -1);
|
||||
found = true;
|
||||
}
|
||||
|
||||
if(!ReplayHandler.isInReplay() || (mc.currentScreen != null && !(mc.currentScreen instanceof GuiMouseInput))) return;
|
||||
|
||||
for(StaticKeybinding staticKeybinding : KeybindRegistry.staticKeybindings) {
|
||||
if(!Keyboard.isKeyDown(staticKeybinding.getKeyCode())) {
|
||||
staticKeybinding.setDown(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(staticKeybinding.isDown()) return;
|
||||
staticKeybinding.setDown(true);
|
||||
|
||||
switch(staticKeybinding.getId()) {
|
||||
case KeybindRegistry.STATIC_DELETE_KEYFRAME:
|
||||
if(ReplayHandler.getSelectedKeyframe() != null) ReplayHandler.removeKeyframe(ReplayHandler.getSelectedKeyframe());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void forwardCameraMovement(boolean forward, boolean backward, boolean left, boolean right, boolean up, boolean down) {
|
||||
if(forward && !backward) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.FORWARD);
|
||||
} else if(backward && !forward) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.BACKWARD);
|
||||
}
|
||||
|
||||
if(left && !right) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.LEFT);
|
||||
} else if(right && !left) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.RIGHT);
|
||||
}
|
||||
|
||||
if(up && !down) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.UP);
|
||||
} else if(down && !up) {
|
||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.DOWN);
|
||||
}
|
||||
// TODO
|
||||
// if(!ReplayHandler.isInReplay()) return;
|
||||
//
|
||||
// KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings;
|
||||
//
|
||||
// boolean speedup = false;
|
||||
//
|
||||
// if(mc.currentScreen == null) {
|
||||
// boolean forward = false, backward = false, left = false, right = false, up = false, down = false;
|
||||
//
|
||||
// if(!ReplayHandler.isInPath()) {
|
||||
// for(KeyBinding kb : keyBindings) {
|
||||
// if(!kb.isKeyDown()) continue;
|
||||
// if(ReplayHandler.isCameraView()) {
|
||||
// if(kb.getKeyDescription().equals("key.forward")) {
|
||||
// forward = true;
|
||||
// speedup = true;
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals("key.back")) {
|
||||
// backward = true;
|
||||
// speedup = true;
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals("key.jump")) {
|
||||
// up = true;
|
||||
// speedup = true;
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals("key.left")) {
|
||||
// left = true;
|
||||
// speedup = true;
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals("key.right")) {
|
||||
// right = true;
|
||||
// speedup = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals("key.sneak")) {
|
||||
// if(ReplayHandler.isCameraView()) {
|
||||
// down = true;
|
||||
// speedup = true;
|
||||
// }
|
||||
// ReplayHandler.spectateCamera();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// forwardCameraMovement(forward, backward, left, right, up, down);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(ReplayHandler.getCameraEntity() != null) {
|
||||
// if(speedup) {
|
||||
// ReplayHandler.getCameraEntity().speedUp();
|
||||
// prevKeysDown = Sys.getTime();
|
||||
// } else {
|
||||
// if(Sys.getTime() - prevKeysDown > 100) {
|
||||
// ReplayHandler.getCameraEntity().stopSpeedUp();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public void keyInput(InputEvent.KeyInputEvent event) {
|
||||
// try {
|
||||
// onKeyInput();
|
||||
// } catch(Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// KeyBinding[] keyBindings = Minecraft.getMinecraft().gameSettings.keyBindings;
|
||||
//
|
||||
// boolean found = false;
|
||||
//
|
||||
// for(KeyBinding kb : keyBindings) {
|
||||
// if(!kb.isKeyDown()) continue;
|
||||
//
|
||||
// handleCustomKeybindings(kb, found, -1);
|
||||
// found = true;
|
||||
// }
|
||||
//
|
||||
// if(!ReplayHandler.isInReplay() || (mc.currentScreen != null && !(mc.currentScreen instanceof GuiMouseInput))) return;
|
||||
//
|
||||
// for(StaticKeybinding staticKeybinding : KeybindRegistry.staticKeybindings) {
|
||||
// if(!Keyboard.isKeyDown(staticKeybinding.getKeyCode())) {
|
||||
// staticKeybinding.setDown(false);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if(staticKeybinding.isDown()) return;
|
||||
// staticKeybinding.setDown(true);
|
||||
//
|
||||
// switch(staticKeybinding.getId()) {
|
||||
// case KeybindRegistry.STATIC_DELETE_KEYFRAME:
|
||||
// if(ReplayHandler.getSelectedKeyframe() != null) ReplayHandler.removeKeyframe(ReplayHandler.getSelectedKeyframe());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void forwardCameraMovement(boolean forward, boolean backward, boolean left, boolean right, boolean up, boolean down) {
|
||||
// if(forward && !backward) {
|
||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.FORWARD);
|
||||
// } else if(backward && !forward) {
|
||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.BACKWARD);
|
||||
// }
|
||||
//
|
||||
// if(left && !right) {
|
||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.LEFT);
|
||||
// } else if(right && !left) {
|
||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.RIGHT);
|
||||
// }
|
||||
//
|
||||
// if(up && !down) {
|
||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.UP);
|
||||
// } else if(down && !up) {
|
||||
// ReplayHandler.getCameraEntity().setMovement(MoveDirection.DOWN);
|
||||
// }
|
||||
// }
|
||||
|
||||
public void handleCustomKeybindings(KeyBinding kb, boolean found, int keyCode) {
|
||||
//Custom registered handlers
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ADD_MARKER) && (kb.isPressed() || kb.getKeyCode() == keyCode)) {
|
||||
if(ReplayHandler.isInReplay() && (mc.currentScreen == null || mc.currentScreen instanceof GuiMouseInput)) {
|
||||
ReplayHandler.toggleMarker();
|
||||
} else if(ConnectionEventHandler.isRecording()) {
|
||||
ConnectionEventHandler.addMarker();
|
||||
}
|
||||
}
|
||||
|
||||
if(!ReplayHandler.isInReplay() || (mc.currentScreen != null && !(mc.currentScreen instanceof GuiMouseInput))) return;
|
||||
|
||||
if((kb.getKeyDescription().equals("key.chat") || kb.getKeyDescription().equals("key.command"))
|
||||
&& (kb.isPressed() || kb.getKeyCode() == keyCode)) {
|
||||
mc.displayGuiScreen(new GuiMouseInput(ReplayMod.overlay));
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_PLAY_PAUSE) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
ReplayMod.overlay.togglePlayPause();
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_CLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? 0.2f : 1);
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_COUNTERCLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? -0.2f : -1);
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_RESET_TILT) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
ReplayHandler.setCameraTilt(0);
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_THUMBNAIL) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !found && !ReplayHandler.isInPath()) {
|
||||
TickAndRenderListener.requestScreenshot();
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_PLAYER_OVERVIEW) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !found && !ReplayHandler.isInPath()) {
|
||||
PlayerHandler.openPlayerOverview();
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_LIGHTING) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
ReplayMod.replaySettings.setLightingEnabled(!ReplayMod.replaySettings.isLightingEnabled());
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_CLEAR_KEYFRAMES) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
ReplayHandler.resetKeyframes(false, ReplayMod.replaySettings.showClearKeyframesCallback());
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_SYNC_TIMELINE) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
ReplayHandler.syncTimeCursor(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT));
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_KEYFRAME_PRESETS) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
mc.displayGuiScreen(new GuiKeyframeRepository(ReplayHandler.getKeyframeRepository()));
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_PATH_PREVIEW) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
ReplayMod.replaySettings.setShowPathPreview(!ReplayMod.replaySettings.showPathPreview());
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ASSET_MANAGER) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
mc.displayGuiScreen(new GuiAssetManager());
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_OBJECT_MANAGER) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
mc.displayGuiScreen(new GuiObjectManager());
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_TOGGLE_INTERPOLATION) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
ReplayMod.replaySettings.toggleInterpolation();
|
||||
}
|
||||
// TODO: Transfer to new key binding registry
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ADD_MARKER) && (kb.isPressed() || kb.getKeyCode() == keyCode)) {
|
||||
// if(ReplayHandler.isInReplay() && (mc.currentScreen == null || mc.currentScreen instanceof GuiMouseInput)) {
|
||||
// ReplayHandler.toggleMarker();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(!ReplayHandler.isInReplay() || (mc.currentScreen != null && !(mc.currentScreen instanceof GuiMouseInput))) return;
|
||||
//
|
||||
// if((kb.getKeyDescription().equals("key.chat") || kb.getKeyDescription().equals("key.command"))
|
||||
// && (kb.isPressed() || kb.getKeyCode() == keyCode)) {
|
||||
// mc.displayGuiScreen(new GuiMouseInput(ReplayMod.overlay));
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_PLAY_PAUSE) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// ReplayMod.overlay.togglePlayPause();
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_CLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? 0.2f : 1);
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_COUNTERCLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? -0.2f : -1);
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_RESET_TILT) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// ReplayHandler.setCameraTilt(0);
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_THUMBNAIL) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !found && !ReplayHandler.isInPath()) {
|
||||
// TickAndRenderListener.requestScreenshot();
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_PLAYER_OVERVIEW) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !found && !ReplayHandler.isInPath()) {
|
||||
// PlayerHandler.openPlayerOverview();
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_LIGHTING) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// ReplayMod.replaySettings.setLightingEnabled(!ReplayMod.replaySettings.isLightingEnabled());
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_CLEAR_KEYFRAMES) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// ReplayHandler.resetKeyframes(false, ReplayMod.replaySettings.showClearKeyframesCallback());
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_SYNC_TIMELINE) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// ReplayHandler.syncTimeCursor(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT));
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_KEYFRAME_PRESETS) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// mc.displayGuiScreen(new GuiKeyframeRepository(ReplayHandler.getKeyframeRepository()));
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_PATH_PREVIEW) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// ReplayMod.replaySettings.setShowPathPreview(!ReplayMod.replaySettings.showPathPreview());
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ASSET_MANAGER) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// mc.displayGuiScreen(new GuiAssetManager());
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_OBJECT_MANAGER) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// mc.displayGuiScreen(new GuiObjectManager());
|
||||
// }
|
||||
//
|
||||
// if(kb.getKeyDescription().equals(KeybindRegistry.KEY_TOGGLE_INTERPOLATION) && (kb.isPressed() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
|
||||
// ReplayMod.replaySettings.toggleInterpolation();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user