@@ -37,7 +37,7 @@ public class KeyInputHandler
37
37
FlansKeyConflictContext .VEHICLE ,
38
38
Keyboard .KEY_LCONTROL ,
39
39
"key.flansmod.category" );
40
- public static KeyBinding inventoryKey = new KeyBinding ("key.vehicleMenu.desc" ,
40
+ public static KeyBinding vehicleMenuKey = new KeyBinding ("key.vehicleMenu.desc" ,
41
41
FlansKeyConflictContext .VEHICLE ,
42
42
Keyboard .KEY_M ,
43
43
"key.flansmod.category" );
@@ -101,13 +101,21 @@ public class KeyInputHandler
101
101
FlansKeyConflictContext .VEHICLE ,
102
102
Keyboard .KEY_F5 ,
103
103
"key.flansmod.category" );
104
+ public static KeyBinding primaryVehicleInteract = new KeyBinding ("key.primaryVehicleInteract.desc" ,
105
+ FlansKeyConflictContext .VEHICLE ,
106
+ Minecraft .getMinecraft ().gameSettings .keyBindAttack .getKeyCode (),
107
+ "key.flansmod.category" );
108
+ public static KeyBinding secondaryVehicleInteract = new KeyBinding ("key.secondaryVehicleInteract.desc" ,
109
+ FlansKeyConflictContext .VEHICLE ,
110
+ Minecraft .getMinecraft ().gameSettings .keyBindUseItem .getKeyCode (),
111
+ "key.flansmod.category" );
104
112
105
113
private Minecraft mc ;
106
114
107
115
KeyInputHandler ()
108
116
{
109
117
ClientRegistry .registerKeyBinding (downKey );
110
- ClientRegistry .registerKeyBinding (inventoryKey );
118
+ ClientRegistry .registerKeyBinding (vehicleMenuKey );
111
119
ClientRegistry .registerKeyBinding (bombKey );
112
120
ClientRegistry .registerKeyBinding (gunKey );
113
121
ClientRegistry .registerKeyBinding (controlSwitchKey );
@@ -122,11 +130,13 @@ public class KeyInputHandler
122
130
ClientRegistry .registerKeyBinding (lookAtGunKey );
123
131
ClientRegistry .registerKeyBinding (debugKey );
124
132
ClientRegistry .registerKeyBinding (reloadModelsKey );
133
+ ClientRegistry .registerKeyBinding (primaryVehicleInteract );
134
+ ClientRegistry .registerKeyBinding (secondaryVehicleInteract );
125
135
126
136
mc = Minecraft .getMinecraft ();
127
137
}
128
138
129
- void checkDrivingKeys ()
139
+ void checkTickKeys ()
130
140
{
131
141
EntityPlayer player = mc .player ;
132
142
if (player == null )
@@ -139,43 +149,29 @@ void checkDrivingKeys()
139
149
{
140
150
IControllable controllable = (IControllable )ridingEntity ;
141
151
if (mc .gameSettings .keyBindForward .isKeyDown ())
142
- controllable .pressKey (0 , player );
152
+ controllable .pressKey (0 , player , false );
143
153
if (mc .gameSettings .keyBindBack .isKeyDown ())
144
- controllable .pressKey (1 , player );
154
+ controllable .pressKey (1 , player , false );
145
155
if (mc .gameSettings .keyBindLeft .isKeyDown ())
146
- controllable .pressKey (2 , player );
156
+ controllable .pressKey (2 , player , false );
147
157
if (mc .gameSettings .keyBindRight .isKeyDown ())
148
- controllable .pressKey (3 , player );
158
+ controllable .pressKey (3 , player , false );
149
159
if (mc .gameSettings .keyBindJump .isKeyDown ())
150
- controllable .pressKey (4 , player );
160
+ controllable .pressKey (4 , player , false );
151
161
if (downKey .isKeyDown ())
152
- controllable .pressKey (5 , player );
153
- if (mc .gameSettings .keyBindSneak .isPressed ())
154
- controllable .pressKey (6 , player );
155
- if (mc .gameSettings .keyBindInventory .isPressed () || inventoryKey .isPressed ())
156
- controllable .pressKey (7 , player );
157
- if (bombKey .isKeyDown ())
158
- controllable .pressKey (8 , player );
159
- if (gunKey .isKeyDown ())
160
- controllable .pressKey (9 , player );
161
- if (controlSwitchKey .isPressed ())
162
- controllable .pressKey (10 , player );
162
+ controllable .pressKey (5 , player , false );
163
+ if (secondaryVehicleInteract .isKeyDown ())
164
+ controllable .pressKey (8 , player , false );
165
+ if (primaryVehicleInteract .isKeyDown ())
166
+ controllable .pressKey (9 , player , false );
163
167
if (leftRollKey .isKeyDown ())
164
- controllable .pressKey (11 , player );
168
+ controllable .pressKey (11 , player , false );
165
169
if (rightRollKey .isKeyDown ())
166
- controllable .pressKey (12 , player );
167
- if (gearKey .isPressed ())
168
- controllable .pressKey (13 , player );
169
- if (doorKey .isPressed ())
170
- controllable .pressKey (14 , player );
171
- if (modeKey .isPressed ())
172
- controllable .pressKey (15 , player );
173
- if (toggleCameraPerspective .isKeyDown ())
174
- controllable .pressKey (18 , player );
170
+ controllable .pressKey (12 , player , false );
175
171
}
176
172
}
177
173
178
- void checkUniversalKeys ()
174
+ void checkEventKeys ()
179
175
{
180
176
if (FMLClientHandler .instance ().isGUIOpen (GuiChat .class ) || mc .currentScreen != null )
181
177
return ;
@@ -223,11 +219,13 @@ void checkUniversalKeys()
223
219
}
224
220
}
225
221
}
222
+ return ;
226
223
}
227
224
if (lookAtGunKey .isPressed ())
228
225
{
229
226
FlansModClient .getGunAnimations (mc .player , EnumHand .MAIN_HAND ).lookAt = LookAtState .TILT1 ;
230
227
FlansModClient .getGunAnimations (mc .player , EnumHand .OFF_HAND ).lookAt = LookAtState .TILT1 ;
228
+ return ;
231
229
}
232
230
if (debugKey .isPressed ())
233
231
{
@@ -237,10 +235,41 @@ void checkUniversalKeys()
237
235
{
238
236
FlansMod .packetHandler .sendToServer (new PacketRequestDebug ());
239
237
}
238
+ return ;
240
239
}
241
240
if (reloadModelsKey .isPressed ())
242
241
{
243
242
FlansModClient .reloadModels (Keyboard .isKeyDown (Keyboard .KEY_LSHIFT ));
243
+ return ;
244
+ }
245
+
246
+ if (player == null )
247
+ {
248
+ return ;
249
+ }
250
+
251
+ Entity ridingEntity = player .getRidingEntity ();
252
+ if (ridingEntity instanceof IControllable )
253
+ {
254
+ IControllable controllable = (IControllable )ridingEntity ;
255
+ if (mc .gameSettings .keyBindSneak .isPressed ())
256
+ controllable .pressKey (6 , player , true );
257
+ if (vehicleMenuKey .isPressed ())
258
+ controllable .pressKey (7 , player , true );
259
+ if (primaryVehicleInteract .isPressed ())
260
+ controllable .pressKey (9 , player , true );
261
+ if (secondaryVehicleInteract .isPressed ())
262
+ controllable .pressKey (8 , player , true );
263
+ if (controlSwitchKey .isPressed ())
264
+ controllable .pressKey (10 , player , true );
265
+ if (gearKey .isPressed ())
266
+ controllable .pressKey (13 , player , true );
267
+ if (doorKey .isPressed ())
268
+ controllable .pressKey (14 , player , true );
269
+ if (modeKey .isPressed ())
270
+ controllable .pressKey (15 , player , true );
271
+ if (toggleCameraPerspective .isKeyDown ())
272
+ controllable .pressKey (18 , player , true );
244
273
}
245
274
}
246
275
}
0 commit comments