Skip to content

Commit 6c85b7b

Browse files
committed
[NeoForge] Port chunk section editing
1 parent 1a06c36 commit 6c85b7b

24 files changed

Lines changed: 765 additions & 197 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ target
1414
forge-download
1515
out
1616
run
17+
runs/
1718
.jqwik-database
1819

1920
/dependency-reduced-pom.xml

gradle/libs.versions.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[plugins]
22
codecov = "org.enginehub.codecov:0.2.0"
3-
neogradle-userdev = "net.neoforged.gradle.userdev:7.0.142"
3+
neogradle-userdev = { id = "net.neoforged.gradle.userdev", version.ref = "neogradle" }
44
fabric-loom = "fabric-loom:1.7.3"
55
sponge-spongegradle = "org.spongepowered.gradle.plugin:2.2.0"
66
sponge-vanillagradle = { id = "org.spongepowered.gradle.vanilla", version.ref = "sponge-vanillagradle" }
@@ -14,6 +14,7 @@ antlr = "4.13.1"
1414
fabric-api = "0.100.3+1.21"
1515

1616
neoforge-minecraft = "1.21"
17+
neogradle = "7.0.163"
1718

1819
sponge-minecraft = "1.21"
1920
# https://repo.spongepowered.org/service/rest/repository/browse/maven-public/org/spongepowered/spongeapi/
@@ -36,7 +37,7 @@ lang-worldeditBase = "7.3.4"
3637
lang-version = "1450"
3738

3839
[libraries]
39-
neogradle-neoform = "net.neoforged.gradle:neoform:7.0.142"
40+
neogradle-neoform = { module = "net.neoforged.gradle:neoform", version.ref = "neogradle" }
4041
sponge-vanillagradle = { module = "org.spongepowered:vanillagradle", version.ref = "sponge-vanillagradle" }
4142

4243
licenser = "gradle.plugin.org.cadixdev.gradle:licenser:0.6.1"
@@ -90,7 +91,7 @@ fabric-minecraft = "com.mojang:minecraft:1.21"
9091
fabric-loader = "net.fabricmc:fabric-loader:0.15.11"
9192
fabric-permissions-api = "me.lucko:fabric-permissions-api:0.3.1"
9293

93-
neoforge = "net.neoforged:neoforge:21.0.16-beta"
94+
neoforge = "net.neoforged:neoforge:21.0.167"
9495

9596
# Mojang-provided libraries, CHECK AGAINST MINECRAFT for versions
9697
guava = "com.google.guava:guava:32.1.3-jre!!"

worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/collection/ChunkSectionMask.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
120
package com.sk89q.worldedit.internal.util.collection;
221

322
import it.unimi.dsi.fastutil.shorts.AbstractShortCollection;

worldedit-core/src/main/java/com/sk89q/worldedit/internal/wna/NativeAdapter.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
120
package com.sk89q.worldedit.internal.wna;
221

322
import com.sk89q.worldedit.world.block.BlockState;

worldedit-core/src/main/java/com/sk89q/worldedit/internal/wna/NativeBlockState.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
120
package com.sk89q.worldedit.internal.wna;
221

322
/**

worldedit-core/src/main/java/com/sk89q/worldedit/internal/wna/NativeChunk.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
120
package com.sk89q.worldedit.internal.wna;
221

322
import com.sk89q.worldedit.internal.util.collection.ChunkSectionMask;

worldedit-core/src/main/java/com/sk89q/worldedit/internal/wna/NativePosition.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
120
package com.sk89q.worldedit.internal.wna;
221

322
/**

worldedit-core/src/main/java/com/sk89q/worldedit/internal/wna/WNASharedImpl.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
public class WNASharedImpl {
4040
public static <B extends BlockStateHolder<B>> boolean setBlock(
41-
NativeAdapter adapter, NativeWorld nativeWorld, BlockVector3 position, B block, SideEffectSet sideEffects
41+
NativeWorld nativeWorld, BlockVector3 position, B block, SideEffectSet sideEffects
4242
) throws WorldEditException {
4343
checkNotNull(position);
4444
checkNotNull(block);
@@ -49,9 +49,9 @@ public static <B extends BlockStateHolder<B>> boolean setBlock(
4949

5050
// First set the block
5151
NativeChunk chunk = nativeWorld.getChunk(x >> 4, z >> 4);
52-
NativePosition pos = adapter.newBlockPos(x, y, z);
52+
NativePosition pos = nativeWorld.getAdapter().newBlockPos(x, y, z);
5353
NativeBlockState old = chunk.getBlockState(pos);
54-
NativeBlockState newState = adapter.toNative(block.toImmutableState());
54+
NativeBlockState newState = nativeWorld.getAdapter().toNative(block.toImmutableState());
5555
// change block prior to placing if it should be fixed
5656
if (sideEffects.shouldApply(SideEffect.VALIDATION)) {
5757
newState = newState.updateFromNeighbourShapes(nativeWorld, pos);
@@ -100,12 +100,11 @@ public static String extractNbtId(LinCompoundTag tag) {
100100
}
101101

102102
public static void applySideEffects(
103-
NativeAdapter adapter, NativeWorld nativeWorld, SideEffectSet sideEffectSet, BlockVector3 position,
104-
BlockState previousType
103+
NativeWorld nativeWorld, SideEffectSet sideEffectSet, BlockVector3 position, BlockState previousType
105104
) {
106-
NativePosition pos = adapter.newBlockPos(position.x(), position.y(), position.z());
105+
NativePosition pos = nativeWorld.getAdapter().newBlockPos(position.x(), position.y(), position.z());
107106
NativeChunk chunk = nativeWorld.getChunk(position.x() >> 4, position.z() >> 4);
108-
NativeBlockState oldData = adapter.toNative(previousType);
107+
NativeBlockState oldData = nativeWorld.getAdapter().toNative(previousType);
109108
NativeBlockState newData = chunk.getBlockState(pos);
110109

111110
applySideEffectsNoLookups(nativeWorld, chunk, sideEffectSet, pos, oldData, newData);

worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorld.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ public Path getStoragePath() {
201201
@Override
202202
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException {
203203
clearContainerBlockContents(position);
204-
return WNASharedImpl.setBlock(FabricAdapter.asNativeAdapter(), getNativeInterface(), position, block, sideEffects);
204+
return WNASharedImpl.setBlock(getNativeInterface(), position, block, sideEffects);
205205
}
206206

207207
@Override
208208
public Set<SideEffect> applySideEffects(BlockVector3 position, BlockState previousType, SideEffectSet sideEffectSet) {
209-
WNASharedImpl.applySideEffects(FabricAdapter.asNativeAdapter(), getNativeInterface(), sideEffectSet, position, previousType);
209+
WNASharedImpl.applySideEffects(getNativeInterface(), sideEffectSet, position, previousType);
210210
return Sets.intersection(FabricWorldEdit.inst.getPlatform().getSupportedSideEffects(), sideEffectSet.getSideEffectsToApply());
211211
}
212212

worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinNativeBlockState.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
120
package com.sk89q.worldedit.fabric.mixin;
221

322
import com.mojang.serialization.MapCodec;

0 commit comments

Comments
 (0)