From fcd819f6f4fc105da53ceb24413ecbf874b347e1 Mon Sep 17 00:00:00 2001 From: TehBrian Date: Sun, 12 Nov 2023 09:56:40 -0500 Subject: [PATCH] add 5% chance to noclip into backrooms on portal use --- .../transportation/PortalListener.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/city/thefloating/floatyplugin/transportation/PortalListener.java b/src/main/java/city/thefloating/floatyplugin/transportation/PortalListener.java index 80cb86e..bb00483 100644 --- a/src/main/java/city/thefloating/floatyplugin/transportation/PortalListener.java +++ b/src/main/java/city/thefloating/floatyplugin/transportation/PortalListener.java @@ -19,6 +19,7 @@ import java.time.Instant; import java.util.HashMap; import java.util.Map; +import java.util.Random; /** * Sends players to the correct realms upon entering a portal. @@ -33,6 +34,8 @@ public final class PortalListener implements Listener { private static final Duration MESSAGE_COOLDOWN = Duration.ofSeconds(15); + private static final Random RANDOM = new Random(); + private final Map lastMessageTime = new HashMap<>(); private final Map lastPortalAttempt = new HashMap<>(); @@ -96,8 +99,8 @@ private void onNetherPortal(final Player player) { } } case BACKROOMS -> this.sendRateLimitedMessage(player, this.langConfig.c(NodePath.path("portal", "backrooms"))); - case NETHER -> this.transposer.transpose(player, Realm.OVERWORLD); - default -> this.transposer.transpose(player, Realm.NETHER); + case NETHER -> this.fuzzyTranspose(player, Realm.OVERWORLD); + default -> this.fuzzyTranspose(player, Realm.NETHER); } } @@ -111,8 +114,23 @@ private void onEndPortal(final Player player) { } } case BACKROOMS -> this.sendRateLimitedMessage(player, this.langConfig.c(NodePath.path("portal", "backrooms"))); - case END -> this.transposer.transpose(player, Realm.OVERWORLD); - default -> this.transposer.transpose(player, Realm.END); + case END -> this.fuzzyTranspose(player, Realm.OVERWORLD); + default -> this.fuzzyTranspose(player, Realm.END); + } + } + + /** + * Transpose player with random chance to transpose to the backrooms. + * + * @param player the player to transpose + * @param realm the realm to possibly transpose player to + */ + private void fuzzyTranspose(final Player player, final Realm realm) { + // random chance to noclip into the backrooms. 5% chance. + if (RANDOM.nextFloat() < 0.05) { + this.transposer.noclipIntoBackrooms(player); + } else { + this.transposer.transpose(player, realm); } }