禁用快捷栏渲染
This commit is contained in:
parent
295a2c3ca0
commit
1ec3d8c2be
3 changed files with 29 additions and 10 deletions
|
@ -1434,6 +1434,26 @@ public class ClientEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 载具banHand时,禁用快捷栏渲染
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public static void handleAvoidRenderingHotbar(RenderGuiOverlayEvent.Pre event) {
|
||||
if (event.getOverlay() != VanillaGuiOverlay.HOTBAR.type()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getVehicle() instanceof ArmedVehicleEntity vehicle && vehicle.banHand(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleDrawMessage(boolean draw, Supplier<NetworkEvent.Context> ctx) {
|
||||
if (ctx.get().getDirection().getReceptionSide() == LogicalSide.CLIENT) {
|
||||
drawTime = 1;
|
||||
|
|
|
@ -60,14 +60,15 @@ public class MinecraftMixin {
|
|||
|
||||
var seatIndex = vehicle.getSeatIndex(player);
|
||||
|
||||
// 数字键 武器切换
|
||||
if (vehicle instanceof WeaponVehicleEntity weaponVehicle
|
||||
&& !Screen.hasShiftDown()
|
||||
&& weaponVehicle.hasWeapon(seatIndex)
|
||||
&& weaponVehicle.getWeaponType(seatIndex) != index
|
||||
) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new SwitchVehicleWeaponMessage(seatIndex, index, false));
|
||||
if (vehicle instanceof WeaponVehicleEntity weaponVehicle && weaponVehicle.banHand(player)) {
|
||||
ci.cancel();
|
||||
|
||||
// 数字键 武器切换
|
||||
if (!Screen.hasShiftDown()
|
||||
&& weaponVehicle.hasWeapon(seatIndex)
|
||||
&& weaponVehicle.getWeaponType(seatIndex) != index) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new SwitchVehicleWeaponMessage(seatIndex, index, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,9 @@ import net.minecraftforge.network.NetworkEvent;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
public class SwitchVehicleWeaponMessage {
|
||||
|
||||
private final int index;
|
||||
|
||||
private final double value;
|
||||
|
||||
private final boolean isScroll;
|
||||
|
||||
public SwitchVehicleWeaponMessage(int index, double value, boolean isScroll) {
|
||||
|
@ -45,5 +44,4 @@ public class SwitchVehicleWeaponMessage {
|
|||
});
|
||||
context.get().setPacketHandled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue