Files
Purpur/patches/server/0231-Fix-Important-Issue-Crash-with-Plugin-or-Datapack-Ge.patch
2021-10-19 01:44:30 -07:00

47 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: DoctaEnkoda <bierquejason@gmail.com>
Date: Tue, 20 Jul 2021 02:18:23 +0200
Subject: [PATCH] Fix Important Issue Crash with Plugin or Datapack Generation
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/DecoratedFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/DecoratedFeature.java
index ae11f1ecf23b38b84ab09f66796d1509a21bfbd8..0a4a0a3d81753a7dea6a6483f601254928c697fb 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/DecoratedFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/DecoratedFeature.java
@@ -24,12 +24,16 @@ public class DecoratedFeature extends Feature<DecoratedFeatureConfiguration> {
Random random = context.random();
BlockPos blockPos = context.origin();
ConfiguredFeature<?, ?> configuredFeature = decoratedFeatureConfiguration.feature.get();
- decoratedFeatureConfiguration.decorator.getPositions(new DecorationContext(worldGenLevel, chunkGenerator), random, blockPos).forEach((blockPosx) -> {
- if (configuredFeature.place(worldGenLevel, chunkGenerator, random, blockPosx)) {
- mutableBoolean.setTrue();
- }
-
- });
+ // Purpur Start - Change forEach to Iterator for check with try catch error with caves 1.18
+ java.util.Iterator<BlockPos> blockPosIterator = decoratedFeatureConfiguration.decorator.getPositions(new DecorationContext(worldGenLevel, chunkGenerator), random, blockPos).iterator();
+ while (blockPosIterator.hasNext()) {
+ try {
+ if (configuredFeature.place(worldGenLevel, chunkGenerator, random, blockPosIterator.next())) {
+ mutableBoolean.setTrue();
+ }
+ } catch (Exception ignored) {} // No need set false (Exception Possible : NullPointerException and RuntimeException
+ }
+ // Purpur End
return mutableBoolean.isTrue();
}
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/TreeFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/TreeFeature.java
index 0be9ce0734e3ba72893a7349bb9f83a94f4af30c..f1a04ef36ee5e898529e99d98905b74607a16177 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/TreeFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/TreeFeature.java
@@ -147,7 +147,7 @@ public class TreeFeature extends Feature<TreeConfiguration> {
worldGenLevel.setBlock(pos, state, 19);
};
boolean bl = this.doPlace(worldGenLevel, random, blockPos, biConsumer, biConsumer2, treeConfiguration);
- if (bl && (!set.isEmpty() || !set2.isEmpty())) {
+ if (bl && !set.isEmpty() && !set2.isEmpty()) { // Purpur - Fix Paper#6068
if (!treeConfiguration.decorators.isEmpty()) {
List<BlockPos> list = Lists.newArrayList(set);
List<BlockPos> list2 = Lists.newArrayList(set2);