添加离开载具按键
This commit is contained in:
parent
a1ee630f23
commit
77bf0abab1
8 changed files with 55 additions and 3 deletions
|
@ -162,6 +162,7 @@ public class ModUtils {
|
|||
addNetworkMessage(RadarMenuOpenMessage.class, RadarMenuOpenMessage::encode, RadarMenuOpenMessage::decode, RadarMenuOpenMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||
addNetworkMessage(RadarMenuCloseMessage.class, RadarMenuCloseMessage::encode, RadarMenuCloseMessage::decode, RadarMenuCloseMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||
addNetworkMessage(RadarSetPosMessage.class, RadarSetPosMessage::encode, RadarSetPosMessage::decode, RadarSetPosMessage::handler);
|
||||
addNetworkMessage(PlayerStopRidingMessage.class, PlayerStopRidingMessage::encode, PlayerStopRidingMessage::decode, PlayerStopRidingMessage::handler);
|
||||
|
||||
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
|
||||
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));
|
||||
|
|
|
@ -215,6 +215,9 @@ public class ClickHandler {
|
|||
if (key == ModKeyMappings.INTERACT.getKey().getValue()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new InteractMessage(0));
|
||||
}
|
||||
if (key == ModKeyMappings.DISMOUNT.getKey().getValue()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new PlayerStopRidingMessage(0));
|
||||
}
|
||||
if (key == ModKeyMappings.EDIT_MODE.getKey().getValue() && ClientEventHandler.burstFireSize == 0) {
|
||||
ClientEventHandler.holdFire = false;
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new EditModeMessage(0));
|
||||
|
|
|
@ -22,6 +22,7 @@ public class ModKeyMappings {
|
|||
public static final KeyMapping SENSITIVITY_INCREASE = new KeyMapping("key.superbwarfare.sensitivity_increase", GLFW.GLFW_KEY_PAGE_UP, "key.categories.superbwarfare");
|
||||
public static final KeyMapping SENSITIVITY_REDUCE = new KeyMapping("key.superbwarfare.sensitivity_reduce", GLFW.GLFW_KEY_PAGE_DOWN, "key.categories.superbwarfare");
|
||||
public static final KeyMapping INTERACT = new KeyMapping("key.superbwarfare.interact", GLFW.GLFW_KEY_X, "key.categories.superbwarfare");
|
||||
public static final KeyMapping DISMOUNT = new KeyMapping("key.superbwarfare.dismount", GLFW.GLFW_KEY_J, "key.categories.superbwarfare");
|
||||
|
||||
public static final KeyMapping BREATH = new KeyMapping("key.superbwarfare.breath", GLFW.GLFW_KEY_LEFT_CONTROL, "key.categories.superbwarfare") {
|
||||
private boolean isDownOld = false;
|
||||
|
@ -60,6 +61,7 @@ public class ModKeyMappings {
|
|||
event.register(SENSITIVITY_INCREASE);
|
||||
event.register(SENSITIVITY_REDUCE);
|
||||
event.register(INTERACT);
|
||||
event.register(DISMOUNT);
|
||||
event.register(BREATH);
|
||||
event.register(CONFIG);
|
||||
event.register(EDIT_MODE);
|
||||
|
@ -78,8 +80,6 @@ public class ModKeyMappings {
|
|||
@SubscribeEvent
|
||||
public static void onClientTick(TickEvent.ClientTickEvent event) {
|
||||
if (Minecraft.getInstance().screen == null) {
|
||||
FIRE_MODE.consumeClick();
|
||||
INTERACT.consumeClick();
|
||||
BREATH.consumeClick();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,12 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
/**
|
||||
* Code based on @Luke100000's ImmersiveAircraft
|
||||
*/
|
||||
@Mixin(LocalPlayer.class)
|
||||
public class ClientPlayerEntityMixin extends AbstractClientPlayer {
|
||||
|
||||
public ClientPlayerEntityMixin(ClientLevel world, GameProfile profile) {
|
||||
super(world, profile);
|
||||
}
|
||||
|
|
|
@ -12,8 +12,12 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(value = Player.class, priority = 1100)
|
||||
/**
|
||||
* Code based on @Luke100000's ImmersiveAircraft
|
||||
*/
|
||||
@Mixin(value = Player.class, priority = 1145)
|
||||
public abstract class PlayerEntityMixin extends Entity {
|
||||
|
||||
public PlayerEntityMixin(EntityType<?> type, Level world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package com.atsuishio.superbwarfare.network.message;
|
||||
|
||||
import com.atsuishio.superbwarfare.entity.VehicleEntity;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PlayerStopRidingMessage {
|
||||
|
||||
private final int type;
|
||||
|
||||
public PlayerStopRidingMessage(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static void encode(PlayerStopRidingMessage message, FriendlyByteBuf buffer) {
|
||||
buffer.writeInt(message.type);
|
||||
}
|
||||
|
||||
public static PlayerStopRidingMessage decode(FriendlyByteBuf buffer) {
|
||||
return new PlayerStopRidingMessage(buffer.readInt());
|
||||
}
|
||||
|
||||
public static void handler(PlayerStopRidingMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayer player = ctx.get().getSender();
|
||||
if (player == null) return;
|
||||
var vehicle = player.getVehicle();
|
||||
if (!(vehicle instanceof VehicleEntity)) return;
|
||||
|
||||
player.stopRiding();
|
||||
player.setJumping(false);
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
|
@ -380,6 +380,7 @@
|
|||
"key.superbwarfare.sensitivity_increase": "Increase Sensitivity",
|
||||
"key.superbwarfare.sensitivity_reduce": "Reduce Sensitivity",
|
||||
"key.superbwarfare.interact": "Interact",
|
||||
"key.superbwarfare.dismount": "Dismount",
|
||||
"key.superbwarfare.breath": "Breathe",
|
||||
"key.superbwarfare.config": "Open Config Screen",
|
||||
"key.superbwarfare.edit_mode": "Edit Weapon",
|
||||
|
|
|
@ -380,6 +380,7 @@
|
|||
"key.superbwarfare.sensitivity_increase": "增加灵敏度",
|
||||
"key.superbwarfare.sensitivity_reduce": "减少灵敏度",
|
||||
"key.superbwarfare.interact": "交互",
|
||||
"key.superbwarfare.dismount": "离开载具",
|
||||
"key.superbwarfare.breath": "屏息",
|
||||
"key.superbwarfare.config": "打开配置界面",
|
||||
"key.superbwarfare.edit_mode": "改装",
|
||||
|
|
Loading…
Add table
Reference in a new issue