1
- From 3aeeaf31b7a7f888f54e47826e8ec0ddbe65c4bf Mon Sep 17 00:00:00 2001
2
-
3
- Date: Sun, 20 Apr 1997 14:37:42 +0100
4
- Subject: [PATCH] paper File Patches
5
-
6
-
7
- diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
8
- index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb041036f93a 100644
9
1
--- a/net/minecraft/world/level/chunk/LevelChunk.java
10
2
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
11
- @@ -76 ,7 +76 ,7 @@ public class LevelChunk extends ChunkAccess {
3
+ @@ -77 ,7 +_ ,7 @@
12
4
};
13
5
private final Map<BlockPos, LevelChunk.RebindableTickingBlockEntityWrapper> tickersInLevel = Maps.newHashMap();
14
6
public boolean loaded;
@@ -17,7 +9,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
17
9
@Nullable
18
10
private Supplier<FullChunkStatus> fullStatus;
19
11
@Nullable
20
- @@ -85 ,6 +85 ,14 @@ public class LevelChunk extends ChunkAccess {
12
+ @@ -86 ,6 +_ ,14 @@
21
13
private final LevelChunkTicks<Block> blockTicks;
22
14
private final LevelChunkTicks<Fluid> fluidTicks;
23
15
private LevelChunk.UnsavedListener unsavedListener = chunkPos -> {};
@@ -32,7 +24,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
32
24
33
25
public LevelChunk(Level level, ChunkPos pos) {
34
26
this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null);
35
- @@ -102 ,7 +110 ,7 @@ public class LevelChunk extends ChunkAccess {
27
+ @@ -103 ,7 +_ ,7 @@
36
28
@Nullable BlendingData blendingData
37
29
) {
38
30
super(pos, data, level, level.registryAccess().lookupOrThrow(Registries.BIOME), inhabitedTime, sections, blendingData);
@@ -41,7 +33,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
41
33
this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>();
42
34
43
35
for (Heightmap.Types types : Heightmap.Types.values()) {
44
- @@ -154 ,6 +162 ,10 @@ public class LevelChunk extends ChunkAccess {
36
+ @@ -155 ,6 +_ ,10 @@
45
37
this.skyLightSources = chunk.skyLightSources;
46
38
this.setLightCorrect(chunk.isLightCorrect());
47
39
this.markUnsaved();
@@ -52,7 +44,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
52
44
}
53
45
54
46
public void setUnsavedListener(LevelChunk.UnsavedListener unsavedListener) {
55
- @@ -162 ,6 +174 ,12 @@ public class LevelChunk extends ChunkAccess {
47
+ @@ -163 ,6 +_ ,12 @@
56
48
unsavedListener.setUnsaved(this.chunkPos);
57
49
}
58
50
}
@@ -65,7 +57,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
65
57
66
58
@Override
67
59
public void markUnsaved() {
68
- @@ -195 ,8 +213 ,25 @@ public class LevelChunk extends ChunkAccess {
60
+ @@ -196 ,8 +_ ,25 @@
69
61
: super.getListenerRegistry(sectionY);
70
62
}
71
63
@@ -91,7 +83,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
91
83
int x = pos.getX();
92
84
int y = pos.getY();
93
85
int z = pos.getZ();
94
- @@ -231,33 +266,54 @@ public class LevelChunk extends ChunkAccess {
86
+ @@ -232,28 +_,42 @@
95
87
}
96
88
}
97
89
@@ -136,37 +128,33 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
136
128
}
137
129
138
130
@Nullable
139
- @Override
140
- public BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving) {
141
- + // CraftBukkit start
142
- + return this.setBlockState(pos, state, isMoving, true);
143
- + }
144
- +
145
- + @Nullable
146
- + public BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving, boolean doPlace) {
147
- + // CraftBukkit end
148
- int y = pos.getY();
149
- LevelChunkSection section = this.getSection(this.getSectionIndex(y));
150
- boolean hasOnlyAir = section.hasOnlyAir();
151
- @@ -292,7 +348,7 @@ public class LevelChunk extends ChunkAccess {
131
+ @@ -298,7 +_,7 @@
132
+ if (flag && blockState.hasBlockEntity()) {
133
+ if (!this.level.isClientSide && flag2) {
134
+ BlockEntity blockEntity = this.level.getBlockEntity(pos);
135
+ - if (blockEntity != null) {
136
+ + if (blockEntity != null && !this.level.isBlockPlaceCancelled) { // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent
137
+ blockEntity.preRemoveSideEffects(pos, blockState);
138
+ }
139
+ }
140
+ @@ -306,14 +_,14 @@
141
+ this.removeBlockEntity(pos);
142
+ }
143
+
144
+ - if ((flag || block instanceof BaseRailBlock) && this.level instanceof ServerLevel serverLevel && ((flags & 1) != 0 || flag1)) {
145
+ + if ((flag || block instanceof BaseRailBlock) && this.level instanceof ServerLevel serverLevel && ((flags & 1) != 0 || flag1) && !this.level.isBlockPlaceCancelled) { // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent
146
+ blockState.affectNeighborsAfterRemoval(serverLevel, pos, flag1);
152
147
}
153
148
154
- boolean hasBlockEntity = blockState.hasBlockEntity();
155
- - if (!this.level.isClientSide) {
156
- + if (!this.level.isClientSide && !this.level.isBlockPlaceCancelled) { // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent
157
- blockState.onRemove(this.level, pos, state, isMoving);
158
- } else if (!blockState.is(block) && hasBlockEntity) {
159
- this.removeBlockEntity(pos);
160
- @@ -301,7 +357,7 @@ public class LevelChunk extends ChunkAccess {
161
149
if (!section.getBlockState(i, i1, i2).is(block)) {
162
150
return null;
163
151
} else {
164
- - if (!this.level.isClientSide) {
165
- + if (!this.level.isClientSide && doPlace && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
166
- state.onPlace(this.level, pos, blockState, isMoving );
152
+ - if (!this.level.isClientSide && (flags & 512) == 0 ) {
153
+ + if (!this.level.isClientSide && (flags & 512) == 0 && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
154
+ state.onPlace(this.level, pos, blockState, flag1 );
167
155
}
168
156
169
- @@ -355 ,7 +411 ,12 @@ public class LevelChunk extends ChunkAccess {
157
+ @@ -367 ,7 +_ ,12 @@
170
158
171
159
@Nullable
172
160
public BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) {
@@ -180,7 +168,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
180
168
if (blockEntity == null) {
181
169
CompoundTag compoundTag = this.pendingBlockEntities.remove(pos);
182
170
if (compoundTag != null) {
183
- @@ -409 ,7 +470 ,13 @@ public class LevelChunk extends ChunkAccess {
171
+ @@ -421 ,7 +_ ,13 @@
184
172
BlockPos blockPos = blockEntity.getBlockPos();
185
173
BlockState blockState = this.getBlockState(blockPos);
186
174
if (!blockState.hasBlockEntity()) {
@@ -195,7 +183,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
195
183
} else {
196
184
BlockState blockState1 = blockEntity.getBlockState();
197
185
if (blockState != blockState1) {
198
- @@ -457 ,6 +524 ,11 @@ public class LevelChunk extends ChunkAccess {
186
+ @@ -469 ,6 +_ ,11 @@
199
187
public void removeBlockEntity(BlockPos pos) {
200
188
if (this.isInLevel()) {
201
189
BlockEntity blockEntity = this.blockEntities.remove(pos);
@@ -207,7 +195,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
207
195
if (blockEntity != null) {
208
196
if (this.level instanceof ServerLevel serverLevel) {
209
197
this.removeGameEventListener(blockEntity, serverLevel);
210
- @@ -499 ,6 +571 ,65 @@ public class LevelChunk extends ChunkAccess {
198
+ @@ -511 ,6 +_ ,65 @@
211
199
}
212
200
}
213
201
@@ -273,7 +261,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
273
261
public boolean isEmpty() {
274
262
return false;
275
263
}
276
- @@ -711 ,23 +842 ,24 @@ public class LevelChunk extends ChunkAccess {
264
+ @@ -719 ,23 +_ ,24 @@
277
265
if (this.blockEntity.getType().isValid(blockState)) {
278
266
this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity);
279
267
this.loggedInvalidBlockState = false;
0 commit comments