Skip to content

Commit

Permalink
refactor: refactor SectionPos
Browse files Browse the repository at this point in the history
  • Loading branch information
MC-XiaoHei committed Aug 29, 2024
1 parent e25d678 commit 87eb107
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions patches/server/0058-Rewrite-nether-portal-find-logic.patch
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ index 840611677feb4979eb2d492063ae4388ea350506..ab2a2cf0df10cee8045fbb86abce9eaf

public static class IntBounds {
diff --git a/src/main/java/net/minecraft/core/SectionPos.java b/src/main/java/net/minecraft/core/SectionPos.java
index fe3577e533fb829c85fd4881b1bcca3b70aaf1a5..4284d952d30e97042196de740c311851098fd8e4 100644
index fe3577e533fb829c85fd4881b1bcca3b70aaf1a5..8e4dc000beedde8109a17de648cdef893465b3a7 100644
--- a/src/main/java/net/minecraft/core/SectionPos.java
+++ b/src/main/java/net/minecraft/core/SectionPos.java
@@ -33,6 +33,40 @@ public class SectionPos extends Vec3i {
@@ -33,6 +33,43 @@ public class SectionPos extends Vec3i {
super(x, y, z);
}

Expand All @@ -60,31 +60,34 @@ index fe3577e533fb829c85fd4881b1bcca3b70aaf1a5..4284d952d30e97042196de740c311851
+ }
+
+ public SectionPos north() {
+ return fromVec3i(super.north());
+ return relative(Direction.NORTH, 1);
+ }
+
+ public SectionPos south() {
+ return fromVec3i(super.south());
+ return relative(Direction.SOUTH, 1);
+ }
+
+ public SectionPos west() {
+ return fromVec3i(super.west());
+ return relative(Direction.WEST, 1);
+ }
+
+ public SectionPos east() {
+ return fromVec3i(super.east());
+ return relative(Direction.EAST, 1);
+ }
+
+ public SectionPos below() {
+ return fromVec3i(super.below());
+ return relative(Direction.DOWN, 1);
+ }
+
+ public SectionPos above() {
+ return fromVec3i(super.above());
+ return relative(Direction.UP, 1);
+ }
+
+ private SectionPos fromVec3i(Vec3i i) {
+ return new SectionPos(i.x, i.y, i.z);
+ @Override
+ public SectionPos relative(Direction direction, int i) {
+ return i == 0
+ ? this
+ : new SectionPos(this.getX() + direction.getStepX() * i, this.getY() + direction.getStepY() * i, this.getZ() + direction.getStepZ() * i);
+ }
+ // Lumina end - rewrite nether portal find logic
+
Expand Down

0 comments on commit 87eb107

Please sign in to comment.