Skip to content

Commit

Permalink
Chunk section editing spike, Fabric-only for now
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed Sep 7, 2024
1 parent d3c59b1 commit 550f97d
Show file tree
Hide file tree
Showing 44 changed files with 1,372 additions and 560 deletions.
4 changes: 2 additions & 2 deletions config/checkstyle/checkstyle-suppression.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<suppress files=".*[\\/]worldedit[\\/]bukkit[\\/]adapter[\\/]impl[\\/].*\.java" checks="PackageName"/>
<suppress files=".*[\\/]MathUtils.java" checks="MethodName"/>
<suppress files=".*[\\/]bPermissionsResolver.java" checks="TypeName"/>
<!-- This thing only works via the use of a finalizer. -->
<suppress files=".*[\\/]TracedEditSession.java" checks="NoFinalizer"/>
<!-- None of the old command stuff really matters -->
<suppress files=".*[\\/]minecraft[\\/]util[\\/]commands[\\/].*\.java" checks=".*"/>
<!-- The mixins are allowed to use weird method names -->
<suppress files=".*Mixin.*\.java" checks="MethodName"/>
</suppressions>
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group=com.sk89q.worldedit
version=7.3.7-SNAPSHOT

org.gradle.jvmargs=-Xmx1500M
org.gradle.jvmargs=-Xmx1700M
org.gradle.parallel=true

loom_fabric_repository=https://maven.enginehub.org/artifactory/fabricmc/
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[plugins]
codecov = "org.enginehub.codecov:0.2.0"
neogradle-userdev = "net.neoforged.gradle.userdev:7.0.142"
fabric-loom = "fabric-loom:1.6.12"
fabric-loom = "fabric-loom:1.7.3"
sponge-spongegradle = "org.spongepowered.gradle.plugin:2.2.0"
sponge-vanillagradle = { id = "org.spongepowered.gradle.vanilla", version.ref = "sponge-vanillagradle" }

Expand All @@ -21,8 +21,8 @@ sponge-api = "12.0.0-20240616.151530-3"
sponge-api-major = "12"

# https://parchmentmc.org/docs/getting-started; note that we use older MC versions some times which is OK
parchment-minecraft = "1.20.6"
parchment-mappings = "2024.06.16"
parchment-minecraft = "1.21"
parchment-mappings = "2024.07.28"

# https://repo.spongepowered.org/service/rest/repository/browse/maven-public/org/spongepowered/vanillagradle/
sponge-vanillagradle = "0.2.1-20240617.053350-83"
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pluginManagement {
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("fabric-loom") version "1.6.12"
id("fabric-loom") version "1.7.3"
}
dependencyResolutionManagement {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
Expand Down Expand Up @@ -435,8 +435,8 @@ public void setBiome(Location location, BiomeType biome) {
}

@Override
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightWorldNativeAccess(this,
public NativeWorld<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightNativeWorld(this,
new WeakReference<>(((CraftWorld) world).getHandle()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.world.block.BlockState;
Expand All @@ -41,15 +41,15 @@
import java.util.Objects;
import javax.annotation.Nullable;

public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
public class PaperweightNativeWorld implements NativeWorld<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
private static final int UPDATE = 1;
private static final int NOTIFY = 2;

private final PaperweightAdapter adapter;
private final WeakReference<ServerLevel> world;
private SideEffectSet sideEffectSet;

public PaperweightWorldNativeAccess(PaperweightAdapter adapter, WeakReference<ServerLevel> world) {
public PaperweightNativeWorld(PaperweightAdapter adapter, WeakReference<ServerLevel> world) {
this.adapter = adapter;
this.world = world;
}
Expand All @@ -64,8 +64,8 @@ public void setCurrentSideEffectSet(SideEffectSet sideEffectSet) {
}

@Override
public LevelChunk getChunk(int x, int z) {
return getWorld().getChunk(x, z);
public LevelChunk getChunk(int chunkX, int chunkZ) {
return getWorld().getChunk(chunkX, chunkZ);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
Expand Down Expand Up @@ -435,8 +435,8 @@ public void setBiome(Location location, BiomeType biome) {
}

@Override
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightWorldNativeAccess(this, new WeakReference<>(((CraftWorld) world).getHandle()));
public NativeWorld<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightNativeWorld(this, new WeakReference<>(((CraftWorld) world).getHandle()));
}

private static net.minecraft.core.Direction adapt(Direction face) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.world.block.BlockState;
Expand All @@ -41,15 +41,15 @@
import java.util.Objects;
import javax.annotation.Nullable;

public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
public class PaperweightNativeWorld implements NativeWorld<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
private static final int UPDATE = 1;
private static final int NOTIFY = 2;

private final PaperweightAdapter adapter;
private final WeakReference<ServerLevel> world;
private SideEffectSet sideEffectSet;

public PaperweightWorldNativeAccess(PaperweightAdapter adapter, WeakReference<ServerLevel> world) {
public PaperweightNativeWorld(PaperweightAdapter adapter, WeakReference<ServerLevel> world) {
this.adapter = adapter;
this.world = world;
}
Expand All @@ -64,8 +64,8 @@ public void setCurrentSideEffectSet(SideEffectSet sideEffectSet) {
}

@Override
public LevelChunk getChunk(int x, int z) {
return getWorld().getChunk(x, z);
public LevelChunk getChunk(int chunkX, int chunkZ) {
return getWorld().getChunk(chunkX, chunkZ);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
Expand Down Expand Up @@ -437,8 +437,8 @@ public void setBiome(Location location, BiomeType biome) {
}

@Override
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightWorldNativeAccess(this, new WeakReference<>(((CraftWorld) world).getHandle()));
public NativeWorld<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightNativeWorld(this, new WeakReference<>(((CraftWorld) world).getHandle()));
}

private static net.minecraft.core.Direction adapt(Direction face) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.world.block.BlockState;
Expand All @@ -41,15 +41,15 @@
import java.util.Objects;
import javax.annotation.Nullable;

public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
public class PaperweightNativeWorld implements NativeWorld<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
private static final int UPDATE = 1;
private static final int NOTIFY = 2;

private final PaperweightAdapter adapter;
private final WeakReference<ServerLevel> world;
private SideEffectSet sideEffectSet;

public PaperweightWorldNativeAccess(PaperweightAdapter adapter, WeakReference<ServerLevel> world) {
public PaperweightNativeWorld(PaperweightAdapter adapter, WeakReference<ServerLevel> world) {
this.adapter = adapter;
this.world = world;
}
Expand All @@ -64,8 +64,8 @@ public void setCurrentSideEffectSet(SideEffectSet sideEffectSet) {
}

@Override
public LevelChunk getChunk(int x, int z) {
return getWorld().getChunk(x, z);
public LevelChunk getChunk(int chunkX, int chunkZ) {
return getWorld().getChunk(chunkX, chunkZ);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
Expand Down Expand Up @@ -437,8 +437,8 @@ public void setBiome(Location location, BiomeType biome) {
}

@Override
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightWorldNativeAccess(this, new WeakReference<>(((CraftWorld) world).getHandle()));
public NativeWorld<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightNativeWorld(this, new WeakReference<>(((CraftWorld) world).getHandle()));
}

private static net.minecraft.core.Direction adapt(Direction face) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.world.block.BlockState;
Expand All @@ -41,15 +41,15 @@
import java.util.Objects;
import javax.annotation.Nullable;

public class PaperweightWorldNativeAccess implements WorldNativeAccess<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
public class PaperweightNativeWorld implements NativeWorld<LevelChunk, net.minecraft.world.level.block.state.BlockState, BlockPos> {
private static final int UPDATE = 1;
private static final int NOTIFY = 2;

private final PaperweightAdapter adapter;
private final WeakReference<ServerLevel> world;
private SideEffectSet sideEffectSet;

public PaperweightWorldNativeAccess(PaperweightAdapter adapter, WeakReference<ServerLevel> world) {
public PaperweightNativeWorld(PaperweightAdapter adapter, WeakReference<ServerLevel> world) {
this.adapter = adapter;
this.world = world;
}
Expand All @@ -64,8 +64,8 @@ public void setCurrentSideEffectSet(SideEffectSet sideEffectSet) {
}

@Override
public LevelChunk getChunk(int x, int z) {
return getWorld().getChunk(x, z);
public LevelChunk getChunk(int chunkX, int chunkZ) {
return getWorld().getChunk(chunkX, chunkZ);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.WNASharedImpl;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
Expand Down Expand Up @@ -91,7 +92,7 @@ public class BukkitWorld extends AbstractWorld {
}

private final WeakReference<World> worldRef;
private final WorldNativeAccess<?, ?, ?> worldNativeAccess;
private final NativeWorld<?, ?, ?> worldNativeAccess;

/**
* Construct the object.
Expand Down Expand Up @@ -482,7 +483,7 @@ public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B
clearContainerBlockContents(position);
if (worldNativeAccess != null) {
try {
return worldNativeAccess.setBlock(position, block, sideEffects);
return WNASharedImpl.setBlock(worldNativeAccess, position, block, sideEffects);
} catch (Exception e) {
if (block instanceof BaseBlock baseBlock && baseBlock.getNbt() != null) {
LOGGER.warn("Tried to set a corrupt tile entity at " + position.toString()
Expand Down Expand Up @@ -515,7 +516,7 @@ public BaseBlock getFullBlock(BlockVector3 position) {
public Set<SideEffect> applySideEffects(BlockVector3 position, com.sk89q.worldedit.world.block.BlockState previousType,
SideEffectSet sideEffectSet) {
if (worldNativeAccess != null) {
worldNativeAccess.applySideEffects(position, previousType, sideEffectSet);
WNASharedImpl.applySideEffects(worldNativeAccess, position, previousType, sideEffectSet);
return Sets.intersection(
WorldEditPlugin.getInstance().getInternalPlatform().getSupportedSideEffects(),
sideEffectSet.getSideEffectsToApply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.internal.wna.NativeWorld;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
Expand Down Expand Up @@ -99,12 +99,12 @@ default void tickWatchdog() {
BaseBlock getFullBlock(Location location);

/**
* Create a {@link WorldNativeAccess} for the given world reference.
* Create a {@link NativeWorld} for the given world reference.
*
* @param world the world reference
* @return the native access object
*/
WorldNativeAccess<?, ?, ?> createWorldNativeAccess(World world);
NativeWorld<?, ?, ?> createWorldNativeAccess(World world);

/**
* Get the state for the given entity.
Expand Down
Loading

0 comments on commit 550f97d

Please sign in to comment.