From 510120a26bcf634154db03a30affbeb98bb48dab Mon Sep 17 00:00:00 2001 From: throwaway180185 Date: Thu, 16 Dec 2021 01:51:55 -0500 Subject: [PATCH 1/3] setup --- .../java/com/flansmod/client/handlers/KeyInputHandler.java | 7 +++++++ .../java/com/flansmod/common/driveables/EntitySeat.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/com/flansmod/client/handlers/KeyInputHandler.java b/src/main/java/com/flansmod/client/handlers/KeyInputHandler.java index 5eb8ded57..c340f4729 100644 --- a/src/main/java/com/flansmod/client/handlers/KeyInputHandler.java +++ b/src/main/java/com/flansmod/client/handlers/KeyInputHandler.java @@ -42,6 +42,10 @@ public class KeyInputHandler FlansKeyConflictContext.VEHICLE, Keyboard.KEY_M, "key.flansmod.category"); + public static KeyBinding seatSwitchKey = new KeyBinding("key.seatSwitch.desc", + FlansKeyConflictContext.VEHICLE, + Keyboard.KEY_P, + "key.flansmod.category"); public static KeyBinding bombKey = new KeyBinding("key.dropBomb.desc", FlansKeyConflictContext.VEHICLE, Keyboard.KEY_B, @@ -117,6 +121,7 @@ public class KeyInputHandler { ClientRegistry.registerKeyBinding(downKey); ClientRegistry.registerKeyBinding(vehicleMenuKey); + ClientRegistry.registerKeyBinding(seatSwitchKey); ClientRegistry.registerKeyBinding(bombKey); ClientRegistry.registerKeyBinding(gunKey); ClientRegistry.registerKeyBinding(controlSwitchKey); @@ -273,6 +278,8 @@ void checkEventKeys() controllable.pressKey(15, player, true); if(toggleCameraPerspective.isKeyDown()) controllable.pressKey(18, player, true); + if(seatSwitchKey.isPressed()) + controllable.pressKey(25, player, true); } } } diff --git a/src/main/java/com/flansmod/common/driveables/EntitySeat.java b/src/main/java/com/flansmod/common/driveables/EntitySeat.java index a7b952ea5..df4f7e86f 100644 --- a/src/main/java/com/flansmod/common/driveables/EntitySeat.java +++ b/src/main/java/com/flansmod/common/driveables/EntitySeat.java @@ -751,6 +751,10 @@ public boolean serverHandleKeyPress(int key, EntityPlayer player) } } return true; + case 25: + driveable.getSeats(); + driveable.getSeat(0); + return true; } return false; } From 0f078622310cda7e34a6070f5782a9c58adab607 Mon Sep 17 00:00:00 2001 From: throwaway180185 Date: Fri, 17 Dec 2021 22:41:35 -0500 Subject: [PATCH 2/3] halfway works bind works to move from secondary seat to main seat, but not from main to secondary --- .../common/driveables/EntityDriveable.java | 37 +++++++++++++++++++ .../common/driveables/EntityPlane.java | 18 +++++++++ .../common/driveables/EntitySeat.java | 18 ++++++++- .../common/driveables/EntityVehicle.java | 18 +++++++++ 4 files changed, 89 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/flansmod/common/driveables/EntityDriveable.java b/src/main/java/com/flansmod/common/driveables/EntityDriveable.java index bb3767782..6ab6d1127 100644 --- a/src/main/java/com/flansmod/common/driveables/EntityDriveable.java +++ b/src/main/java/com/flansmod/common/driveables/EntityDriveable.java @@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.NonNullList; import net.minecraft.util.math.AxisAlignedBB; @@ -484,6 +485,24 @@ public boolean serverHandleKeyPress(int key, EntityPlayer player) shoot(false); return true; } + case 25: + { + EntitySeat[] vehicleSeats = getSeats(); + EntitySeat playerSeat = getSeat(player); + EnumHand hand = player.getActiveHand(); + if(vehicleSeats.length > (playerSeat.getExpectedSeatID() + 1)) + { + int newSeatID = playerSeat.getExpectedSeatID() + 1; + EntitySeat newSeat = getSeat(newSeatID); + newSeat.processInitialInteract(player, hand); + } + else + { + EntitySeat newSeat = getSeat(0); + newSeat.processInitialInteract(player, hand); + } + return true; + } } return false; } @@ -530,6 +549,24 @@ else if(!primaryShootHeld) togglePerspective(); return true; } + case 25: + { + EntitySeat[] vehicleSeats = getSeats(); + EntitySeat playerSeat = getSeat(player); + EnumHand hand = player.getActiveHand(); + if(vehicleSeats.length > (playerSeat.getExpectedSeatID() + 1)) + { + int newSeatID = playerSeat.getExpectedSeatID() + 1; + EntitySeat newSeat = getSeat(newSeatID); + newSeat.processInitialInteract(player, hand); + } + else + { + EntitySeat newSeat = getSeat(0); + newSeat.processInitialInteract(player, hand); + } + return true; + } default: { return false; diff --git a/src/main/java/com/flansmod/common/driveables/EntityPlane.java b/src/main/java/com/flansmod/common/driveables/EntityPlane.java index fd793d3fb..407614ebf 100644 --- a/src/main/java/com/flansmod/common/driveables/EntityPlane.java +++ b/src/main/java/com/flansmod/common/driveables/EntityPlane.java @@ -304,6 +304,24 @@ public boolean pressKey(int key, EntityPlayer player, boolean isOnEvent) axes.setAngles(axes.getYaw(), 0, 0); return true; } + case 25: + { + EntitySeat[] vehicleSeats = getSeats(); + EntitySeat playerSeat = getSeat(player); + EnumHand hand = player.getActiveHand(); + if(vehicleSeats.length > (playerSeat.getExpectedSeatID() + 1)) + { + int newSeatID = playerSeat.getExpectedSeatID() + 1; + EntitySeat newSeat = getSeat(newSeatID); + newSeat.processInitialInteract(player, hand); + } + else + { + EntitySeat newSeat = getSeat(0); + newSeat.processInitialInteract(player, hand); + } + return true; + } default: { return super.pressKey(key, player, isOnEvent); diff --git a/src/main/java/com/flansmod/common/driveables/EntitySeat.java b/src/main/java/com/flansmod/common/driveables/EntitySeat.java index df4f7e86f..87dfd0f10 100644 --- a/src/main/java/com/flansmod/common/driveables/EntitySeat.java +++ b/src/main/java/com/flansmod/common/driveables/EntitySeat.java @@ -752,9 +752,23 @@ public boolean serverHandleKeyPress(int key, EntityPlayer player) } return true; case 25: - driveable.getSeats(); - driveable.getSeat(0); + { + EntitySeat[] vehicleSeats = driveable.getSeats(); + EntitySeat playerSeat = getSeat(player); + EnumHand hand = player.getActiveHand(); + if(vehicleSeats.length > (playerSeat.getExpectedSeatID() + 1)) + { + int newSeatID = playerSeat.getExpectedSeatID() + 1; + EntitySeat newSeat = driveable.getSeat(newSeatID); + newSeat.processInitialInteract(player, hand); + } + else + { + EntitySeat newSeat = driveable.getSeat(0); + newSeat.processInitialInteract(player, hand); + } return true; + } } return false; } diff --git a/src/main/java/com/flansmod/common/driveables/EntityVehicle.java b/src/main/java/com/flansmod/common/driveables/EntityVehicle.java index d21082b65..280bae537 100644 --- a/src/main/java/com/flansmod/common/driveables/EntityVehicle.java +++ b/src/main/java/com/flansmod/common/driveables/EntityVehicle.java @@ -260,6 +260,24 @@ public boolean pressKey(int key, EntityPlayer player, boolean isOnEvent) } return true; } + case 25: + { + EntitySeat[] vehicleSeats = getSeats(); + EntitySeat playerSeat = getSeat(player); + EnumHand hand = player.getActiveHand(); + if(vehicleSeats.length > (playerSeat.getExpectedSeatID() + 1)) + { + int newSeatID = playerSeat.getExpectedSeatID() + 1; + EntitySeat newSeat = getSeat(newSeatID); + newSeat.processInitialInteract(player, hand); + } + else + { + EntitySeat newSeat = getSeat(0); + newSeat.processInitialInteract(player, hand); + } + return true; + } default: { return super.pressKey(key, player, isOnEvent); From 9071f069995cec461d6df8ac4bcd0192b0c8e959 Mon Sep 17 00:00:00 2001 From: throwaway180185 Date: Sat, 18 Dec 2021 15:35:40 -0500 Subject: [PATCH 3/3] fixed driver's seat removed hacky solution --- .../common/driveables/EntityDriveable.java | 14 ++------------ .../common/driveables/EntityPlane.java | 18 ------------------ .../common/driveables/EntityVehicle.java | 18 ------------------ 3 files changed, 2 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/flansmod/common/driveables/EntityDriveable.java b/src/main/java/com/flansmod/common/driveables/EntityDriveable.java index 6ab6d1127..2631acff3 100644 --- a/src/main/java/com/flansmod/common/driveables/EntityDriveable.java +++ b/src/main/java/com/flansmod/common/driveables/EntityDriveable.java @@ -551,19 +551,9 @@ else if(!primaryShootHeld) } case 25: { - EntitySeat[] vehicleSeats = getSeats(); - EntitySeat playerSeat = getSeat(player); - EnumHand hand = player.getActiveHand(); - if(vehicleSeats.length > (playerSeat.getExpectedSeatID() + 1)) - { - int newSeatID = playerSeat.getExpectedSeatID() + 1; - EntitySeat newSeat = getSeat(newSeatID); - newSeat.processInitialInteract(player, hand); - } - else + if(isOnEvent) { - EntitySeat newSeat = getSeat(0); - newSeat.processInitialInteract(player, hand); + FlansMod.getPacketHandler().sendToServer(new PacketDriveableKey(key)); } return true; } diff --git a/src/main/java/com/flansmod/common/driveables/EntityPlane.java b/src/main/java/com/flansmod/common/driveables/EntityPlane.java index 407614ebf..fd793d3fb 100644 --- a/src/main/java/com/flansmod/common/driveables/EntityPlane.java +++ b/src/main/java/com/flansmod/common/driveables/EntityPlane.java @@ -304,24 +304,6 @@ public boolean pressKey(int key, EntityPlayer player, boolean isOnEvent) axes.setAngles(axes.getYaw(), 0, 0); return true; } - case 25: - { - EntitySeat[] vehicleSeats = getSeats(); - EntitySeat playerSeat = getSeat(player); - EnumHand hand = player.getActiveHand(); - if(vehicleSeats.length > (playerSeat.getExpectedSeatID() + 1)) - { - int newSeatID = playerSeat.getExpectedSeatID() + 1; - EntitySeat newSeat = getSeat(newSeatID); - newSeat.processInitialInteract(player, hand); - } - else - { - EntitySeat newSeat = getSeat(0); - newSeat.processInitialInteract(player, hand); - } - return true; - } default: { return super.pressKey(key, player, isOnEvent); diff --git a/src/main/java/com/flansmod/common/driveables/EntityVehicle.java b/src/main/java/com/flansmod/common/driveables/EntityVehicle.java index 280bae537..d21082b65 100644 --- a/src/main/java/com/flansmod/common/driveables/EntityVehicle.java +++ b/src/main/java/com/flansmod/common/driveables/EntityVehicle.java @@ -260,24 +260,6 @@ public boolean pressKey(int key, EntityPlayer player, boolean isOnEvent) } return true; } - case 25: - { - EntitySeat[] vehicleSeats = getSeats(); - EntitySeat playerSeat = getSeat(player); - EnumHand hand = player.getActiveHand(); - if(vehicleSeats.length > (playerSeat.getExpectedSeatID() + 1)) - { - int newSeatID = playerSeat.getExpectedSeatID() + 1; - EntitySeat newSeat = getSeat(newSeatID); - newSeat.processInitialInteract(player, hand); - } - else - { - EntitySeat newSeat = getSeat(0); - newSeat.processInitialInteract(player, hand); - } - return true; - } default: { return super.pressKey(key, player, isOnEvent);