Skip to content

Commit

Permalink
Fixed just Client Ride the Vehicles if they to mutch away
Browse files Browse the repository at this point in the history
  • Loading branch information
MrScautHD committed Apr 14, 2022
1 parent 052ba78 commit cf72683
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down

0 comments on commit cf72683

Please sign in to comment.