Skip to content

Commit

Permalink
Fix compatibility with WorldGuard (#2743)
Browse files Browse the repository at this point in the history
* Make the Vector classes into Records (#2477)

* Make the Vector classes into Records

* Drop custom equals and hashCode methods in Vector/BlockVector classes

(cherry picked from commit 0df2b6af4c1ce18b77eedd5c62eeb45011512103)
Signed-off-by: Pierre Maurice Schwang <mail@pschwang.eu>

* chore: cleanup cherry-pick issues, migrate to new methods

* chore: add since attributes to deprecated tags, use MathMan instead of Math std lib for rounding ints

* chore: mark custom hashCode + equals implementations diffing from upstream

---------

Co-authored-by: Maddy Miller <mnmiller1@me.com>
  • Loading branch information
PierreSchwang and me4502 authored May 25, 2024
1 parent f9c523c commit c77d341
Show file tree
Hide file tree
Showing 17 changed files with 449 additions and 349 deletions.
2 changes: 1 addition & 1 deletion worldedit-bukkit/adapters/adapter-1_20_5/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ repositories {

dependencies {
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240520.005421-60")
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240523.202134-70")
compileOnly(libs.paperlib)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ public abstract class AbstractFilterBlock extends FilterBlock {
public abstract Extent getExtent();

@Override
public int getX() {
return getPosition().getX();
public int x() {
return getPosition().x();
}

@Override
public int getY() {
return getPosition().getY();
public int y() {
return getPosition().y();
}

@Override
public int getZ() {
return getPosition().getZ();
public int z() {
return getPosition().z();
}

@Override
Expand Down Expand Up @@ -72,12 +72,12 @@ public void setNbtData(@Nullable CompoundTag nbtData) {

@Override
public BlockVector3 getMinimumPoint() {
return at(getX(), getY(), getZ());
return at(x(), y(), z());
}

@Override
public BlockVector3 getMaximumPoint() {
return at(getX(), getY(), getZ());
return at(x(), y(), z());
}

@Override
Expand All @@ -88,7 +88,7 @@ public void setBlock(BlockState state) {
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
if (x == this.getX() && y == this.getY() && z == this.getZ()) {
if (x == this.x() && y == this.y() && z == this.z()) {
setFullBlock(block.toBaseBlock());
return true;
}
Expand All @@ -97,7 +97,7 @@ public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T b

@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
if (x == this.getX() && y == this.getY() && z == this.getZ()) {
if (x == this.x() && y == this.y() && z == this.z()) {
setBiome(biome);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ public void setNbtData(@Nullable CompoundTag nbtData) {
}

@Override
public int getX() {
public int x() {
return x;
}

@Override
public int getY() {
public int y() {
return (heights[index] & 0xFF) + yOffset;
}

@Override
public int getZ() {
public int z() {
return z;
}

Expand All @@ -112,12 +112,12 @@ public boolean setBiome(int x, int y, int z, BiomeType biome) {

@Override
public void setBiome(final BiomeType biome) {
getExtent().setBiome(getX(), getY(), getZ(), biome);
getExtent().setBiome(x(), y(), z(), biome);
}

@Override
public BiomeType getBiome() {
return getExtent().getBiomeType(getX(), getY(), getZ());
return getExtent().getBiomeType(x(), y(), z());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,17 @@ public BiomeType getBiome() {
}

@Override
public final int getX() {
public final int x() {
return xx + x;
}

@Override
public final int getY() {
public final int y() {
return yy + y;
}

@Override
public final int getZ() {
public final int z() {
return zz + z;
}

Expand Down Expand Up @@ -304,31 +304,31 @@ public final BlockState getBlockNorth() {
if (z > 0) {
return states[getArr[index - 16]];
}
return getExtent().getBlock(getX(), getY(), getZ() - 1);
return getExtent().getBlock(x(), y(), z() - 1);
}

@Override
public final BlockState getBlockEast() {
if (x < 15) {
return states[getArr[index + 1]];
}
return getExtent().getBlock(getX() + 1, getY(), getZ());
return getExtent().getBlock(x() + 1, y(), z());
}

@Override
public final BlockState getBlockSouth() {
if (z < 15) {
return states[getArr[index + 16]];
}
return getExtent().getBlock(getX(), getY(), getZ() + 1);
return getExtent().getBlock(x(), y(), z() + 1);
}

@Override
public final BlockState getBlockWest() {
if (x > 0) {
return states[getArr[index - 1]];
}
return getExtent().getBlock(getX() - 1, getY(), getZ());
return getExtent().getBlock(x() - 1, y(), z());
}

@Override
Expand Down Expand Up @@ -401,7 +401,7 @@ public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T b

@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getBlockZ(), biome);
return setBiome(position.x(), position.y(), position.z(), biome);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,60 +73,60 @@ public BaseBlock getFullBlock(int x, int y, int z) {
}

public BlockState getBlockBelow() {
return getBlock(getX(), getY() - 1, getZ());
return getBlock(x(), y() - 1, z());
}

public BlockState getBlockAbove() {
return getBlock(getX(), getY() + 1, getZ());
return getBlock(x(), y() + 1, z());
}

public BlockState getBlockNorth() {
return getBlock(getX(), getY(), getZ() - 1);
return getBlock(x(), y(), z() - 1);
}

public BlockState getBlockEast() {
return getBlock(getX() + 1, getY(), getZ());
return getBlock(x() + 1, y(), z());
}

public BlockState getBlockSouth() {
return getBlock(getX(), getY(), getZ() + 1);
return getBlock(x(), y(), z() + 1);
}

public BlockState getBlockWest() {
return getBlock(getX() - 1, getY(), getZ());
return getBlock(x() - 1, y(), z());
}

public BlockState getBlockRelativeY(int y) {
return getBlock(getX(), getY() + y, getZ());
return getBlock(x(), y() + y, z());
}

@Override
public abstract int getX();
public abstract int x();

@Override
public abstract int getY();
public abstract int y();

@Override
public abstract int getZ();
public abstract int z();

public int getLocalX() {
return getX() & 15;
return x() & 15;
}

public int getLocalY() {
return getY() & 15;
return y() & 15;
}

public int getLocalZ() {
return getZ() & 15;
return z() & 15;
}

public int getChunkX() {
return getX() >> 4;
return x() >> 4;
}

public int getChunkZ() {
return getZ() >> 4;
return z() >> 4;
}

/*
Expand Down Expand Up @@ -204,7 +204,7 @@ public BiomeType getBiome(BlockVector3 position) {

@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getZ(), biome);
return setBiome(position.x(), position.y(), position.z(), biome);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ public SingleFilterBlock init(int x, int y, int z, BaseBlock block) {
}

@Override
public int getX() {
public int x() {
return x;
}

@Override
public int getY() {
public int y() {
return y;
}

@Override
public int getZ() {
public int z() {
return z;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,8 @@ public long toLongPackedForm() {
}

@Override
public int getX() {
return parent.getX();
}

@Override
public int getBlockX() {
return parent.getBlockX();
public int x() {
return parent.x();
}

@Override
Expand All @@ -110,13 +105,8 @@ public BlockVector3 withX(int x) {
}

@Override
public int getY() {
return parent.getY();
}

@Override
public int getBlockY() {
return parent.getBlockY();
public int y() {
return parent.y();
}

@Override
Expand All @@ -125,13 +115,8 @@ public BlockVector3 withY(int y) {
}

@Override
public int getZ() {
return parent.getZ();
}

@Override
public int getBlockZ() {
return parent.getBlockZ();
public int z() {
return parent.z();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public MutableBlockVector3() {
}

public MutableBlockVector3(BlockVector3 other) {
this(other.getX(), other.getY(), other.getZ());
this(other.x(), other.y(), other.z());
}

public MutableBlockVector3 setComponents(BlockVector3 other) {
return setComponents(other.getBlockX(), other.getBlockY(), other.getBlockZ());
return setComponents(other.x(), other.y(), other.z());
}

private int x;
Expand All @@ -47,33 +47,33 @@ public MutableBlockVector3 setComponents(int x, int y, int z) {
}

@Override
public final int getX() {
public final int x() {
return x;
}

@Override
public final int getY() {
public final int y() {
return y;
}

@Override
public final int getZ() {
public final int z() {
return z;
}

@Override
public BlockVector3 getMinimum(BlockVector3 v2) {
this.x = Math.min(v2.getX(), x);
this.y = Math.min(v2.getY(), y);
this.z = Math.min(v2.getZ(), z);
this.x = Math.min(v2.x(), x);
this.y = Math.min(v2.y(), y);
this.z = Math.min(v2.z(), z);
return this;
}

@Override
public BlockVector3 getMaximum(BlockVector3 v2) {
this.x = Math.max(v2.getX(), x);
this.y = Math.max(v2.getY(), y);
this.z = Math.max(v2.getZ(), z);
this.x = Math.max(v2.x(), x);
this.y = Math.max(v2.y(), y);
this.z = Math.max(v2.z(), z);
return this;
}

Expand Down
Loading

0 comments on commit c77d341

Please sign in to comment.