mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
94 lines
4.8 KiB
Diff
94 lines
4.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Sat, 21 Aug 2021 18:53:03 -0700
|
|
Subject: [PATCH] Only capture actual tree growth
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java b/src/main/java/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/grower/AbstractMegaTreeGrower.java
|
|
@@ -0,0 +0,0 @@ public abstract class AbstractMegaTreeGrower extends AbstractTreeGrower {
|
|
ConfiguredFeature<?, ?> worldgenfeatureconfigured = (ConfiguredFeature) holder.value();
|
|
BlockState iblockdata1 = Blocks.AIR.defaultBlockState();
|
|
|
|
+ // Paper start
|
|
+ final CaptureState captureState = new CaptureState(world).recordAndSetToFalse();
|
|
+ try (captureState) {
|
|
+ // Paper end
|
|
world.setBlock(pos.offset(x, 0, z), iblockdata1, 4);
|
|
world.setBlock(pos.offset(x + 1, 0, z), iblockdata1, 4);
|
|
world.setBlock(pos.offset(x, 0, z + 1), iblockdata1, 4);
|
|
world.setBlock(pos.offset(x + 1, 0, z + 1), iblockdata1, 4);
|
|
+ } // Paper
|
|
if (worldgenfeatureconfigured.place(world, chunkGenerator, random, pos.offset(x, 0, z))) {
|
|
return true;
|
|
} else {
|
|
+ captureState.recordAndSetToFalse(); // Paper
|
|
+ try (captureState) { // Paper
|
|
world.setBlock(pos.offset(x, 0, z), state, 4);
|
|
world.setBlock(pos.offset(x + 1, 0, z), state, 4);
|
|
world.setBlock(pos.offset(x, 0, z + 1), state, 4);
|
|
world.setBlock(pos.offset(x + 1, 0, z + 1), state, 4);
|
|
+ } // Paper
|
|
return false;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/grower/AbstractTreeGrower.java b/src/main/java/net/minecraft/world/level/block/grower/AbstractTreeGrower.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/grower/AbstractTreeGrower.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/grower/AbstractTreeGrower.java
|
|
@@ -0,0 +0,0 @@ public abstract class AbstractTreeGrower {
|
|
ConfiguredFeature<?, ?> worldgenfeatureconfigured = (ConfiguredFeature) holder.value();
|
|
BlockState iblockdata1 = world.getFluidState(pos).createLegacyBlock();
|
|
|
|
+ // Paper start - don't capture the change to air for tree blocks
|
|
+ final CaptureState captureState = new CaptureState(world).recordAndSetToFalse();
|
|
+ try (captureState) {
|
|
+ // Paper end
|
|
world.setBlock(pos, iblockdata1, 4);
|
|
+ } // Paper
|
|
if (worldgenfeatureconfigured.place(world, chunkGenerator, random, pos)) {
|
|
if (world.getBlockState(pos) == iblockdata1) {
|
|
world.sendBlockUpdated(pos, state, iblockdata1, 2);
|
|
@@ -0,0 +0,0 @@ public abstract class AbstractTreeGrower {
|
|
|
|
return true;
|
|
} else {
|
|
+ captureState.recordAndSetToFalse(); // Paper - don't capture the change to air for tree blocks
|
|
+ try (captureState) { // Paper
|
|
world.setBlock(pos, state, 4);
|
|
+ } // Paper
|
|
return false;
|
|
}
|
|
}
|
|
@@ -0,0 +0,0 @@ public abstract class AbstractTreeGrower {
|
|
}
|
|
}
|
|
// CraftBukkit end
|
|
+ // Paper start
|
|
+ static class CaptureState implements AutoCloseable {
|
|
+ private final ServerLevel level;
|
|
+ private boolean previousCaptureTreeGeneration;
|
|
+ private boolean previousCaptureBlockStates;
|
|
+
|
|
+ CaptureState(net.minecraft.server.level.ServerLevel level) {
|
|
+ this.level = level;
|
|
+ }
|
|
+
|
|
+ CaptureState recordAndSetToFalse() {
|
|
+ this.previousCaptureTreeGeneration = this.level.captureTreeGeneration;
|
|
+ this.previousCaptureBlockStates = this.level.captureBlockStates;
|
|
+ this.level.captureTreeGeneration = false;
|
|
+ this.level.captureBlockStates = false;
|
|
+ return this;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void close() {
|
|
+ this.level.captureTreeGeneration = this.previousCaptureTreeGeneration;
|
|
+ this.level.captureBlockStates = this.previousCaptureBlockStates;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
}
|