Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seat Button #1431

Open
wants to merge 3 commits into
base: 1.12.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/flansmod/common/driveables/EntityDriveable.java
Original file line number Diff line number Diff line change
@@ -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;
18 changes: 18 additions & 0 deletions src/main/java/com/flansmod/common/driveables/EntitySeat.java
Original file line number Diff line number Diff line change
@@ -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;
}