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/EntityDriveable.java b/src/main/java/com/flansmod/common/driveables/EntityDriveable.java index bb3767782..2631acff3 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,14 @@ else if(!primaryShootHeld) togglePerspective(); return true; } + case 25: + { + if(isOnEvent) + { + FlansMod.getPacketHandler().sendToServer(new PacketDriveableKey(key)); + } + return true; + } default: { return false; diff --git a/src/main/java/com/flansmod/common/driveables/EntitySeat.java b/src/main/java/com/flansmod/common/driveables/EntitySeat.java index a7b952ea5..87dfd0f10 100644 --- a/src/main/java/com/flansmod/common/driveables/EntitySeat.java +++ b/src/main/java/com/flansmod/common/driveables/EntitySeat.java @@ -751,6 +751,24 @@ public boolean serverHandleKeyPress(int key, EntityPlayer player) } } return true; + case 25: + { + 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; }