From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Sun, 2 Apr 2023 22:02:28 +0300 Subject: [PATCH] Boat Settings diff --git a/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java index 5d16d2250bae9c982a0af9ad2580a63532b140f7..9eede8eb7fefc414f3a1207cd3ca2b33deb5ea13 100644 --- a/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java +++ b/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java @@ -77,4 +77,11 @@ public class DivineWorldConfig { final Map value = DivineConfig.getMap("world-settings." + worldName + "." + path, null); return value.isEmpty() ? fallback : value; } + + public boolean dontEjectPlayerFromBoatUnderwater = true; + public boolean alwaysAllowToEnterTheBoat = true; + private void boatFeatures() { + dontEjectPlayerFromBoatUnderwater = getBoolean("gameplay-mechanics.boat.dont-eject-players-from-boat-underwater", dontEjectPlayerFromBoatUnderwater); + alwaysAllowToEnterTheBoat = getBoolean("gameplay-mechanics.boat.always-allow-to-enter-the-boat", alwaysAllowToEnterTheBoat); + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java index 49660b0b9ee24de96006441a46bf6efa95873db3..ebd35ca6833aa5cfb913be96ca0c8c13cef45872 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java @@ -356,7 +356,18 @@ public class Boat extends Entity implements VariantHolder { } if (!this.level.isClientSide && this.outOfControlTicks >= 60.0F) { - this.ejectPassengers(); + // DivineMC start - Don't eject players + if (this.level.divinemcConfig.dontEjectPlayerFromBoatUnderwater) { + for (int i = this.passengers.size() - 1; i >= 0; --i) { + Entity passenger = this.passengers.get(i); + if (!(passenger instanceof Player)) { + passenger.stopRiding(); + } + } + } else { + this.ejectPassengers(); + } + // DivineMC end } if (this.getHurtTime() > 0) { @@ -897,7 +908,13 @@ public class Boat extends Entity implements VariantHolder { @Override public InteractionResult interact(Player player, InteractionHand hand) { - return player.isSecondaryUseActive() ? InteractionResult.PASS : (this.outOfControlTicks < 60.0F ? (!this.level.isClientSide ? (player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS) : InteractionResult.SUCCESS) : InteractionResult.PASS); + // DivineMC start - always allow to enter the boat + if (this.level.divinemcConfig.alwaysAllowToEnterTheBoat) { + return player.isSecondaryUseActive() ? InteractionResult.PASS : (true || this.outOfControlTicks < 60.0F ? (!this.level.isClientSide ? (player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS) : InteractionResult.SUCCESS) : InteractionResult.PASS); + } else { + return player.isSecondaryUseActive() ? InteractionResult.PASS : (this.outOfControlTicks < 60.0F ? (!this.level.isClientSide ? (player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS) : InteractionResult.SUCCESS) : InteractionResult.PASS); + } + // DivineMC end } @Override @@ -993,7 +1010,13 @@ public class Boat extends Entity implements VariantHolder { @Override protected boolean canAddPassenger(Entity passenger) { - return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER); + // DivineMC start - always allow to enter the boat + if (this.level.divinemcConfig.alwaysAllowToEnterTheBoat) { + return this.getPassengers().size() < this.getMaxPassengers()/* && !this.isEyeInFluid(FluidTags.WATER)*/; + } else { + return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER); + } + // DivineMC end } protected int getMaxPassengers() {