From cf72683dac955ef28e706a4ea7b41ffe7c653a8f Mon Sep 17 00:00:00 2001 From: MrScautHD Date: Thu, 14 Apr 2022 10:41:23 +0200 Subject: [PATCH] Fixed just Client Ride the Vehicles if they to mutch away --- .../beyond_earth/entities/LanderEntity.java | 11 +++++++---- .../beyond_earth/entities/RocketTier1Entity.java | 12 ++++++++---- .../beyond_earth/entities/RocketTier2Entity.java | 11 +++++++---- .../beyond_earth/entities/RocketTier3Entity.java | 11 +++++++---- .../beyond_earth/entities/RocketTier4Entity.java | 11 +++++++---- .../mrscauthd/beyond_earth/entities/RoverEntity.java | 11 +++++++---- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/main/java/net/mrscauthd/beyond_earth/entities/LanderEntity.java b/src/main/java/net/mrscauthd/beyond_earth/entities/LanderEntity.java index f5115a1bd..333f7f717 100644 --- a/src/main/java/net/mrscauthd/beyond_earth/entities/LanderEntity.java +++ b/src/main/java/net/mrscauthd/beyond_earth/entities/LanderEntity.java @@ -152,10 +152,13 @@ public void readAdditionalSaveData(CompoundTag compound) { @Override public InteractionResult interact(Player player, InteractionHand hand) { super.interact(player, hand); - InteractionResult retval = InteractionResult.sidedSuccess(this.level.isClientSide); + InteractionResult result = InteractionResult.sidedSuccess(this.level.isClientSide); - if (player instanceof ServerPlayer && player.isCrouching()) { + if (!(player instanceof ServerPlayer)) { + return InteractionResult.PASS; + } + if (player.isCrouching()) { NetworkHooks.openGui((ServerPlayer) player, new MenuProvider() { @Override public Component getDisplayName() { @@ -172,11 +175,11 @@ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player play buf.writeVarInt(this.getId()); }); - return retval; + return result; } player.startRiding(this); - return retval; + return result; } public ItemStackHandler getInventory() { diff --git a/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier1Entity.java b/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier1Entity.java index 409a462e1..a5d44d512 100644 --- a/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier1Entity.java +++ b/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier1Entity.java @@ -68,9 +68,13 @@ protected void spawnRocketItem() { @Override public InteractionResult interact(Player player, InteractionHand hand) { super.interact(player, hand); - InteractionResult retval = InteractionResult.sidedSuccess(this.level.isClientSide); - if (player instanceof ServerPlayer && player.isCrouching()) { + InteractionResult result = InteractionResult.sidedSuccess(this.level.isClientSide); + if (!(player instanceof ServerPlayer)) { + return InteractionResult.PASS; + } + + if (player.isCrouching()) { NetworkHooks.openGui((ServerPlayer) player, new MenuProvider() { @Override public Component getDisplayName() { @@ -87,11 +91,11 @@ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player play buf.writeVarInt(this.getId()); }); - return retval; + return result; } player.startRiding(this); - return retval; + return result; } @Override diff --git a/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier2Entity.java b/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier2Entity.java index 1a45d7ea3..c3a77cadc 100644 --- a/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier2Entity.java +++ b/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier2Entity.java @@ -67,10 +67,13 @@ protected void spawnRocketItem() { @Override public InteractionResult interact(Player player, InteractionHand hand) { super.interact(player, hand); - InteractionResult retval = InteractionResult.sidedSuccess(this.level.isClientSide); + InteractionResult result = InteractionResult.sidedSuccess(this.level.isClientSide); - if (player instanceof ServerPlayer && player.isCrouching()) { + if (!(player instanceof ServerPlayer)) { + return InteractionResult.PASS; + } + if (player.isCrouching()) { NetworkHooks.openGui((ServerPlayer) player, new MenuProvider() { @Override public Component getDisplayName() { @@ -87,11 +90,11 @@ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player play buf.writeVarInt(this.getId()); }); - return retval; + return result; } player.startRiding(this); - return retval; + return result; } @Override diff --git a/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier3Entity.java b/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier3Entity.java index d492b23ad..c49787247 100644 --- a/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier3Entity.java +++ b/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier3Entity.java @@ -67,10 +67,13 @@ protected void spawnRocketItem() { @Override public InteractionResult interact(Player player, InteractionHand hand) { super.interact(player, hand); - InteractionResult retval = InteractionResult.sidedSuccess(this.level.isClientSide); + InteractionResult result = InteractionResult.sidedSuccess(this.level.isClientSide); - if (player instanceof ServerPlayer && player.isCrouching()) { + if (!(player instanceof ServerPlayer)) { + return InteractionResult.PASS; + } + if (player.isCrouching()) { NetworkHooks.openGui((ServerPlayer) player, new MenuProvider() { @Override public Component getDisplayName() { @@ -87,11 +90,11 @@ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player play buf.writeVarInt(this.getId()); }); - return retval; + return result; } player.startRiding(this); - return retval; + return result; } @Override diff --git a/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier4Entity.java b/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier4Entity.java index b32754b69..da9574e71 100644 --- a/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier4Entity.java +++ b/src/main/java/net/mrscauthd/beyond_earth/entities/RocketTier4Entity.java @@ -67,10 +67,13 @@ protected void spawnRocketItem() { @Override public InteractionResult interact(Player player, InteractionHand hand) { super.interact(player, hand); - InteractionResult retval = InteractionResult.sidedSuccess(this.level.isClientSide); + InteractionResult result = InteractionResult.sidedSuccess(this.level.isClientSide); - if (player instanceof ServerPlayer && player.isCrouching()) { + if (!(player instanceof ServerPlayer)) { + return InteractionResult.PASS; + } + if (player.isCrouching()) { NetworkHooks.openGui((ServerPlayer) player, new MenuProvider() { @Override public Component getDisplayName() { @@ -87,11 +90,11 @@ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player play buf.writeVarInt(this.getId()); }); - return retval; + return result; } player.startRiding(this); - return retval; + return result; } @Override diff --git a/src/main/java/net/mrscauthd/beyond_earth/entities/RoverEntity.java b/src/main/java/net/mrscauthd/beyond_earth/entities/RoverEntity.java index f55671277..6bed0fd74 100644 --- a/src/main/java/net/mrscauthd/beyond_earth/entities/RoverEntity.java +++ b/src/main/java/net/mrscauthd/beyond_earth/entities/RoverEntity.java @@ -260,10 +260,13 @@ public void readAdditionalSaveData(CompoundTag compound) { @Override public InteractionResult interact(Player player, InteractionHand hand) { super.interact(player, hand); - InteractionResult retval = InteractionResult.sidedSuccess(this.level.isClientSide); + InteractionResult result = InteractionResult.sidedSuccess(this.level.isClientSide); - if (player instanceof ServerPlayer && player.isCrouching()) { + if (!(player instanceof ServerPlayer)) { + return InteractionResult.PASS; + } + if (player.isCrouching()) { NetworkHooks.openGui((ServerPlayer) player, new MenuProvider() { @Override public Component getDisplayName() { @@ -280,11 +283,11 @@ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player play buf.writeVarInt(this.getId()); }); - return retval; + return result; } player.startRiding(this); - return retval; + return result; } public boolean getforward() {