From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Sat, 10 Jun 2023 13:01:08 +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 8f7666f3c33eaf2bee0d68cc4ef1cfab09dea08a..f1a7dc3e00f90be923828a1d812ae3026a584439 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java @@ -357,7 +357,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) { @@ -898,7 +909,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 @@ -994,7 +1011,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() {