Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/patches/server/0997-Only-capture-actual-tree-growth.patch
Noah van der Aa b8edb0e130
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9648)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
6b34da8f SPIGOT-7467: Add getAddress to RemoteConsoleCommandSender

CraftBukkit Changes:
db4ba2897 SPIGOT-7467: Add getAddress to RemoteConsoleCommandSender
4f7ff4dec PR-1246: Add missing AbstractTestingBase to tests which need them
f70a7b68d SPIGOT-7465, MC-264979: Fresh installations print NoSuchFileException for server.properties
8ef7afef6 PR-1240: Call BlockGrowEvent for vines that are growing on additional sides of an existing vine block

Spigot Changes:
d2eba2c8 Rebuild patches
2023-08-28 13:05:48 +02:00

95 Zeilen
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 3decfca75ae1ace3da8ff47815a47d84c2a86105..b1e4a84bc5351ffe472d8371565665148253ad8f 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
@@ -49,17 +49,25 @@ 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 a743f36f2682a6b72ffa6644782fc081d1479eb7..1478483c0a5e35dfe0865ba5d819822765940dbf 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
@@ -41,7 +41,12 @@ 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);
@@ -49,7 +54,10 @@ 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;
}
}
@@ -122,4 +130,29 @@ 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
}