Skip to content

Commit f6c9929

Browse files
committed
LevelChunk
1 parent ad88bab commit f6c9929

File tree

1 file changed

+31
-43
lines changed

1 file changed

+31
-43
lines changed

paper-server/patches/rejected/net/minecraft/world/level/chunk/LevelChunk.java.patch paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch

+31-43
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
From 3aeeaf31b7a7f888f54e47826e8ec0ddbe65c4bf Mon Sep 17 00:00:00 2001
2-
From: File <[email protected]>
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
91
--- a/net/minecraft/world/level/chunk/LevelChunk.java
102
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
11-
@@ -76,7 +76,7 @@ public class LevelChunk extends ChunkAccess {
3+
@@ -77,7 +_,7 @@
124
};
135
private final Map<BlockPos, LevelChunk.RebindableTickingBlockEntityWrapper> tickersInLevel = Maps.newHashMap();
146
public boolean loaded;
@@ -17,7 +9,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
179
@Nullable
1810
private Supplier<FullChunkStatus> fullStatus;
1911
@Nullable
20-
@@ -85,6 +85,14 @@ public class LevelChunk extends ChunkAccess {
12+
@@ -86,6 +_,14 @@
2113
private final LevelChunkTicks<Block> blockTicks;
2214
private final LevelChunkTicks<Fluid> fluidTicks;
2315
private LevelChunk.UnsavedListener unsavedListener = chunkPos -> {};
@@ -32,7 +24,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
3224

3325
public LevelChunk(Level level, ChunkPos pos) {
3426
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 @@
3628
@Nullable BlendingData blendingData
3729
) {
3830
super(pos, data, level, level.registryAccess().lookupOrThrow(Registries.BIOME), inhabitedTime, sections, blendingData);
@@ -41,7 +33,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
4133
this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>();
4234

4335
for (Heightmap.Types types : Heightmap.Types.values()) {
44-
@@ -154,6 +162,10 @@ public class LevelChunk extends ChunkAccess {
36+
@@ -155,6 +_,10 @@
4537
this.skyLightSources = chunk.skyLightSources;
4638
this.setLightCorrect(chunk.isLightCorrect());
4739
this.markUnsaved();
@@ -52,7 +44,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
5244
}
5345

5446
public void setUnsavedListener(LevelChunk.UnsavedListener unsavedListener) {
55-
@@ -162,6 +174,12 @@ public class LevelChunk extends ChunkAccess {
47+
@@ -163,6 +_,12 @@
5648
unsavedListener.setUnsaved(this.chunkPos);
5749
}
5850
}
@@ -65,7 +57,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
6557

6658
@Override
6759
public void markUnsaved() {
68-
@@ -195,8 +213,25 @@ public class LevelChunk extends ChunkAccess {
60+
@@ -196,8 +_,25 @@
6961
: super.getListenerRegistry(sectionY);
7062
}
7163

@@ -91,7 +83,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
9183
int x = pos.getX();
9284
int y = pos.getY();
9385
int z = pos.getZ();
94-
@@ -231,33 +266,54 @@ public class LevelChunk extends ChunkAccess {
86+
@@ -232,28 +_,42 @@
9587
}
9688
}
9789

@@ -136,37 +128,33 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
136128
}
137129

138130
@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);
152147
}
153148

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 {
161149
if (!section.getBlockState(i, i1, i2).is(block)) {
162150
return null;
163151
} 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);
167155
}
168156

169-
@@ -355,7 +411,12 @@ public class LevelChunk extends ChunkAccess {
157+
@@ -367,7 +_,12 @@
170158

171159
@Nullable
172160
public BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) {
@@ -180,7 +168,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
180168
if (blockEntity == null) {
181169
CompoundTag compoundTag = this.pendingBlockEntities.remove(pos);
182170
if (compoundTag != null) {
183-
@@ -409,7 +470,13 @@ public class LevelChunk extends ChunkAccess {
171+
@@ -421,7 +_,13 @@
184172
BlockPos blockPos = blockEntity.getBlockPos();
185173
BlockState blockState = this.getBlockState(blockPos);
186174
if (!blockState.hasBlockEntity()) {
@@ -195,7 +183,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
195183
} else {
196184
BlockState blockState1 = blockEntity.getBlockState();
197185
if (blockState != blockState1) {
198-
@@ -457,6 +524,11 @@ public class LevelChunk extends ChunkAccess {
186+
@@ -469,6 +_,11 @@
199187
public void removeBlockEntity(BlockPos pos) {
200188
if (this.isInLevel()) {
201189
BlockEntity blockEntity = this.blockEntities.remove(pos);
@@ -207,7 +195,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
207195
if (blockEntity != null) {
208196
if (this.level instanceof ServerLevel serverLevel) {
209197
this.removeGameEventListener(blockEntity, serverLevel);
210-
@@ -499,6 +571,65 @@ public class LevelChunk extends ChunkAccess {
198+
@@ -511,6 +_,65 @@
211199
}
212200
}
213201

@@ -273,7 +261,7 @@ index fc3e691ebd28365ef6c13d576cb4122c1576b6ff..ce781ba2c8b3f9f051201d3809a9cb04
273261
public boolean isEmpty() {
274262
return false;
275263
}
276-
@@ -711,23 +842,24 @@ public class LevelChunk extends ChunkAccess {
264+
@@ -719,23 +_,24 @@
277265
if (this.blockEntity.getType().isValid(blockState)) {
278266
this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity);
279267
this.loggedInvalidBlockState = false;

0 commit comments

Comments
 (0)