Skip to content

Commit ccc82bd

Browse files
dordsor21me4502octylFractalseijikunHarvestminer
authored
chore: cherry-pick appropriate changes from upstream (#3137)
* Add data from MCUtils for 1.21 * Fix nbt access in proxy * Lazily compute BlockState#getAsString (#2566) * Lazily compute BlockState#getAsString * Implement in BaseBlock * Remove <1.16 //drawsel max size handling (#2572) * Cleanup registry init (#2583) * Attempt to fix #2125 * Fix SideEffectSet inconsistencies, improve perf The `apply` term was inconsistent in this API, but should have always been the same. This makes the "set" actually store the state of the given effect, even if it's the default, and therefore consistent. * Add property-based testing for SideEffectSet * Changes /curve /line thickness param from int to double (#2623) * Make task executor lifecycled to platform readiness. Closes #2459. * Bump lin-bus to support old schematics better * Data updates for 1.21.2 * [Bukkit] Stop using EnumMap for potential registry types Biome broke in 1.21.3, Material could break in the future * Add parent dir to manifest classpath to account for paper-remapped load point. Currently, the remapped WorldEdit jar on paper is loaded from a sub-directory of the plugins folder, meaning dependencies like truezip and rhino won't be found in the documented search locations. Adding the parent dir temporarily solves this. See #2692. Closes #2691. * Add setBiome override in MaskingExtent. This makes biome operations respect masks set on an EditSession. * Add //mirror as an alias of //flip. (#2714) * Remove never-working caching and fix bugs in region code (#2716) Fixes #2684 * Fix negative height cones. Despite the description/doc stating that negative heights would generate inverted cones, this wasn't actually implemented. * Fix sending CUI packets to unwilling clients. Some servers track channel registration: NF throws an error every time this happens; Bukkit silently drops it; Fabric silently sends it (presumably the client ignores it). * Added a brush for biomes (#1491) * Added a brush for biomes * IntelliJ reformat * Move the warning * Update worldedit-core/src/main/resources/lang/strings.json Co-authored-by: Octavia Togami <[email protected]> * Use BiomeFactory instead Co-authored-by: Octavia Togami <[email protected]> * Add morph brush (#2078) * Add erosion brush * Rename to the Morph brush, and add Erode and Dilate presets Co-authored-by: Lewis B <[email protected]> * Add a -c flag to the biome brush to set entire column (#2235) * Add a -c flag to the biome brush to set entire column * Use new region factories that take fixed positions * Rename to FixedHeight from just Fixed * Deprecate MultiStageReorder and ReorderMode (#1999) * Start deprecating MultiStage reorder * Rather than changing behaviour just deprecate * Add deprecation message * Apply PR review notes * Add API to disable history tracking in EditSessions (#2189) * Add API to disable history tracking in EditSessions * Update worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java Co-authored-by: Octavia Togami <[email protected]> Co-authored-by: Octavia Togami <[email protected]> --------- Co-authored-by: Madeline Miller <[email protected]> Co-authored-by: Octavia Togami <[email protected]> Co-authored-by: Markus Ebner <[email protected]> Co-authored-by: Tyler Wesley <[email protected]> Co-authored-by: wizjany <[email protected]> Co-authored-by: Lewis B <[email protected]>
1 parent fdc9d6d commit ccc82bd

File tree

47 files changed

+998
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+998
-147
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ target
1616
forge-download
1717
out
1818
run
19+
.jqwik-database
1920

2021
/dependency-reduced-pom.xml
2122
*-private.sh

buildSrc/src/main/kotlin/CommonJavaConfig.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ fun Project.applyCommonJavaConfiguration(sourcesJar: Boolean, banSlf4j: Boolean
3636
}
3737

3838
tasks.withType<Test>().configureEach {
39-
useJUnitPlatform()
39+
useJUnitPlatform {
40+
includeEngines("junit-jupiter", "jqwik")
41+
}
4042
}
4143

4244
dependencies {
4345
"compileOnly"("com.google.code.findbugs:jsr305:3.0.2")
4446
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.11.1")
4547
"testImplementation"("org.junit.jupiter:junit-jupiter-params:5.11.1")
48+
"testImplementation"("net.jqwik:jqwik:1.9.0")
4649
"testImplementation"("org.mockito:mockito-core:5.14.0")
4750
"testImplementation"("org.mockito:mockito-junit-jupiter:5.14.0")
4851
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.11.1")

buildSrc/src/main/kotlin/PlatformConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fun Project.applyShadowConfiguration() {
151151

152152
val CLASSPATH = listOf("truezip", "truevfs", "js")
153153
.map { "$it.jar" }
154-
.flatMap { listOf(it, "FastAsyncWorldEdit/$it") }
154+
.flatMap { listOf(it, "FastAsyncWorldEdit/$it", "../$it", "../FastAsyncWorldEdit/$it") }
155155
.joinToString(separator = " ")
156156

157157
sealed class WorldEditKind(

worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightServerLevelDelegateProxy.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
103103
if (tileEntity == null) {
104104
return null;
105105
}
106-
BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos));
107-
newEntity.loadWithComponents(
106+
tileEntity.loadWithComponents(
108107
(CompoundTag) adapter.fromNativeLin(this.editSession.getFullBlock(
109108
blockPos.getX(),
110109
blockPos.getY(),
@@ -113,7 +112,7 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
113112
this.serverLevel.registryAccess()
114113
);
115114

116-
return newEntity;
115+
return tileEntity;
117116
}
118117

119118
private BlockState getBlockState(BlockPos blockPos) {

worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_R1/PaperweightServerLevelDelegateProxy.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
103103
if (tileEntity == null) {
104104
return null;
105105
}
106-
BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos));
107-
newEntity.loadWithComponents(
106+
tileEntity.loadWithComponents(
108107
(CompoundTag) adapter.fromNativeLin(this.editSession.getFullBlock(
109108
blockPos.getX(),
110109
blockPos.getY(),
@@ -113,7 +112,7 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
113112
this.serverLevel.registryAccess()
114113
);
115114

116-
return newEntity;
115+
return tileEntity;
117116
}
118117

119118
private BlockState getBlockState(BlockPos blockPos) {

worldedit-bukkit/adapters/adapter-1_21_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_4/PaperweightServerLevelDelegateProxy.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
103103
if (tileEntity == null) {
104104
return null;
105105
}
106-
BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos));
107-
newEntity.loadWithComponents(
106+
tileEntity.loadWithComponents(
108107
(CompoundTag) adapter.fromNativeLin(this.editSession.getFullBlock(
109108
blockPos.getX(),
110109
blockPos.getY(),
@@ -113,7 +112,7 @@ private BlockEntity getBlockEntity(BlockPos blockPos) {
113112
this.serverLevel.registryAccess()
114113
);
115114

116-
return newEntity;
115+
return tileEntity;
117116
}
118117

119118
private BlockState getBlockState(BlockPos blockPos) {

worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/IBukkitAdapter.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,8 @@ default Entity adapt(org.bukkit.entity.Entity entity) {
166166
*/
167167
default Material adapt(ItemType itemType) {
168168
checkNotNull(itemType);
169-
if (!itemType.id().startsWith("minecraft:")) {
170-
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
171-
}
172-
return Material.getMaterial(itemType.id().substring(10).toUpperCase(Locale.ROOT));
169+
NamespacedKey key = checkNotNull(NamespacedKey.fromString(itemType.id()), "Item type key is invalid");
170+
return Registry.MATERIAL.get(key);
173171
}
174172

175173
/**
@@ -180,11 +178,8 @@ default Material adapt(ItemType itemType) {
180178
*/
181179
default Material adapt(BlockType blockType) {
182180
checkNotNull(blockType);
183-
if (!blockType.id().startsWith("minecraft:")) {
184-
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
185-
}
186-
String id = blockType.id().substring(10).toUpperCase(Locale.ROOT);
187-
return Material.getMaterial(id);
181+
NamespacedKey key = checkNotNull(NamespacedKey.fromString(blockType.id()), "Block type key is invalid");
182+
return Registry.MATERIAL.get(key);
188183
}
189184

190185
default org.bukkit.entity.EntityType adapt(EntityType entityType) {

worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252

5353
import javax.annotation.Nonnull;
5454
import javax.annotation.Nullable;
55-
import java.util.EnumMap;
5655
import java.util.HashMap;
5756
import java.util.Map;
5857
import java.util.Objects;
58+
import java.util.concurrent.ConcurrentHashMap;
5959

6060
import static com.google.common.base.Preconditions.checkNotNull;
6161

@@ -83,6 +83,7 @@ private static IBukkitAdapter getAdapter() {
8383

8484
static {
8585
TO_BLOCK_CONTEXT.setRestricted(false);
86+
TO_BLOCK_CONTEXT.setTryLegacy(false);
8687
}
8788

8889
/**
@@ -366,6 +367,9 @@ public static GameMode adapt(org.bukkit.GameMode gameMode) {
366367
//FAWE end
367368
}
368369

370+
private static final Map<Biome, BiomeType> biomeBiomeTypeCache = new ConcurrentHashMap<>();
371+
private static final Map<BiomeType, Biome> biomeTypeBiomeCache = new ConcurrentHashMap<>();
372+
369373
/**
370374
* Create a WorldEdit BiomeType from a Bukkit one.
371375
*
@@ -402,8 +406,8 @@ public static org.bukkit.entity.EntityType adapt(EntityType entityType) {
402406
//FAWE end
403407
}
404408

405-
private static final EnumMap<Material, BlockType> materialBlockTypeCache = new EnumMap<>(Material.class);
406-
private static final EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);
409+
private static final Map<Material, BlockType> materialBlockTypeCache = new ConcurrentHashMap<>();
410+
private static final Map<Material, ItemType> materialItemTypeCache = new ConcurrentHashMap<>();
407411

408412
/**
409413
* Converts a Material to a BlockType.

worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
2929
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
3030
import org.bukkit.Material;
31-
import org.bukkit.block.data.BlockData;
32-
3331
import javax.annotation.Nullable;
34-
import java.util.ArrayList;
3532
import java.util.Collection;
3633
import java.util.List;
3734
import java.util.Map;

worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,10 @@ private void initializeRegistries() {
312312
/*
313313
314314
// Block & Item
315-
for (Material material : Material.values()) {
316-
if (material.isBlock() && !material.isLegacy()) {
317-
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
315+
Registry.MATERIAL.forEach(material -> {
316+
String key = material.getKey().toString();
317+
if (material.isBlock()) {
318+
BlockType.REGISTRY.register(key, new BlockType(key, blockState -> {
318319
// TODO Use something way less hacky than this.
319320
ParserContext context = new ParserContext();
320321
context.setPreferringWildcard(true);
@@ -331,13 +332,13 @@ private void initializeRegistries() {
331332
}
332333
return defaultState;
333334
} catch (InputParseException e) {
334-
LOGGER.warn("Error loading block state for " + material.getKey(), e);
335+
LOGGER.warn("Error loading block state for " + key, e);
335336
return blockState;
336337
}
337338
}));
338339
}
339-
if (material.isItem() && !material.isLegacy()) {
340-
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
340+
if (material.isItem()) {
341+
ItemType.REGISTRY.register(key, new ItemType(key));
341342
}
342343
}
343344
*/
@@ -359,10 +360,12 @@ private void setupTags() {
359360
// Tags
360361
try {
361362
for (Tag<Material> blockTag : Bukkit.getTags(Tag.REGISTRY_BLOCKS, Material.class)) {
362-
BlockCategory.REGISTRY.register(blockTag.getKey().toString(), new BlockCategory(blockTag.getKey().toString()));
363+
String key = blockTag.getKey().toString();
364+
BlockCategory.REGISTRY.register(key, new BlockCategory(blockTag.getKey().toString()));
363365
}
364366
for (Tag<Material> itemTag : Bukkit.getTags(Tag.REGISTRY_ITEMS, Material.class)) {
365-
ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString()));
367+
String key = itemTag.getKey().toString();
368+
ItemCategory.REGISTRY.register(key, new ItemCategory(itemTag.getKey().toString()));
366369
}
367370
} catch (NoSuchMethodError ignored) {
368371
LOGGER.warn(

0 commit comments

Comments
 (0)