Files
PlazmaBukkitMC/patches/server/0019-Configurable-nether-portal-size.patch
IPECTER 8348420bb7 HotFix - CustomRecipe
Add - Bump Dependencies
2023-10-19 22:22:36 +09:00

86 lines
4.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <dev@alpha93.kr>
Date: Sat, 25 Mar 2023 00:10:52 +0900
Subject: [PATCH] Configurable nether portal size
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalShape.java b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
index e7554ec800f321e4e34c926c53f2375a8c3aa979..677f546cee0ebda24a6e77cb5fedd41078c7fff4 100644
--- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java
+++ b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
@@ -100,7 +100,7 @@ public class PortalShape {
private int calculateWidth() {
int i = this.getDistanceUntilEdgeAboveFrame(this.bottomLeft, this.rightDir);
- return i >= 2 && i <= 21 ? i : 0;
+ return i >= this.level.getMinecraftWorld().plazmaLevelConfiguration().structure.portal.netherPortal.size.width.min() && i <= this.level.getMinecraftWorld().plazmaLevelConfiguration().structure.portal.netherPortal.size.width.max() ? i : 0; // Plazma
}
private int getDistanceUntilEdgeAboveFrame(BlockPos pos, Direction direction) {
@@ -133,7 +133,7 @@ public class PortalShape {
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
int i = this.getDistanceUntilTop(blockposition_mutableblockposition);
- return i >= 3 && i <= 21 && this.hasTopFrame(blockposition_mutableblockposition, i) ? i : 0;
+ return i >= this.level.getMinecraftWorld().plazmaLevelConfiguration().structure.portal.netherPortal.size.height.min() && i <= this.level.getMinecraftWorld().plazmaLevelConfiguration().structure.portal.netherPortal.size.height.max() && this.hasTopFrame(blockposition_mutableblockposition, i) ? i : 0; // Plazma
}
private boolean hasTopFrame(BlockPos.MutableBlockPos pos, int height) {
@@ -187,7 +187,7 @@ public class PortalShape {
}
public boolean isValid() {
- return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
+ return this.bottomLeft != null && this.width >= this.level.getMinecraftWorld().plazmaLevelConfiguration().structure.portal.netherPortal.size.width.min() && this.width <= this.level.getMinecraftWorld().plazmaLevelConfiguration().structure.portal.netherPortal.size.width.max() && this.height >= this.level.getMinecraftWorld().plazmaLevelConfiguration().structure.portal.netherPortal.size.height.min() && this.height <= this.level.getMinecraftWorld().plazmaLevelConfiguration().structure.portal.netherPortal.size.height.max(); // Plazma
}
// CraftBukkit start - return boolean
diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
index b1a75e865e61f9cdfb6a6a57cbab3db1f2a709d3..3ca0f64bf5dcf104a84db91f22fae75790468052 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
@@ -40,7 +40,43 @@ public class LevelConfigurations extends ConfigurationPart {
public NetherPortal netherPortal;
public class NetherPortal extends ConfigurationPart {
+ public Size size;
+ public class Size extends ConfigurationPart {
+ public Width width;
+ public Height height;
+
+ public class Width extends ConfigurationPart {
+
+ int min = 2;
+ int max = 21;
+
+ public int min() {
+ return Math.max(this.min, 1);
+ }
+
+ public int max() {
+ return Math.max(this.min, this.max);
+ }
+
+ }
+
+ public class Height extends ConfigurationPart {
+
+ int min = 3;
+ int max = 21;
+
+ public int min() {
+ return Math.max(this.min, 2);
+ }
+
+ public int max() {
+ return Math.max(this.min, this.max);
+ }
+
+ }
+
+ }
}