Skip to content

Commit 7633dde

Browse files
committed
move things around
1 parent 2445c79 commit 7633dde

34 files changed

+142
-231
lines changed

paper-api/src/main/java/org/bukkit/block/TileState.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public interface TileState extends BlockState, PersistentDataHolder {
2828
* stored by the {@link BlockState}.
2929
*
3030
* When storing changes on the {@link PersistentDataHolder}, the updated
31-
* content will only be applied to the actual tile entity after one of the
31+
* content will only be applied to the actual block entity after one of the
3232
* {@link #update()} methods is called.
3333
*
3434
* @return the custom tag container
@@ -40,7 +40,7 @@ public interface TileState extends BlockState, PersistentDataHolder {
4040
// Paper start
4141
/**
4242
* Checks if this TileState is a snapshot or a live
43-
* representation of the underlying tile entity.
43+
* representation of the underlying block entity.
4444
* <p>
4545
* NOTE: You may still have to call {@link BlockState#update()} on
4646
* live representations to update any visuals on the block.

paper-api/src/main/java/org/bukkit/entity/FallingBlock.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public interface FallingBlock extends Entity {
4747
org.bukkit.block.BlockState getBlockState();
4848

4949
/**
50-
* Sets the {@link BlockData} and possibly present tile entity data for the falling block.
50+
* Sets the {@link BlockData} and possibly present block entity data for the falling block.
5151
*
5252
* @param blockState the BlockState to use
5353
*/

paper-api/src/main/java/org/bukkit/inventory/Inventory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public interface Inventory extends Iterable<ItemStack> {
400400
/**
401401
* Gets the block or entity belonging to the open inventory
402402
*
403-
* @param useSnapshot Create a snapshot if the holder is a tile entity
403+
* @param useSnapshot Create a snapshot if the holder is a block entity
404404
* @return The holder of the inventory; null if it has no holder.
405405
*/
406406
@Nullable

paper-api/src/main/java/org/bukkit/inventory/view/builder/LocationInventoryViewBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public interface LocationInventoryViewBuilder<V extends InventoryView> extends I
4545
* building this view it may come with the costs associated with chunk
4646
* loading.
4747
* <p>
48-
* Providing a location of a tile entity with a non matching menu comes with
48+
* Providing a location of a block entity with a non matching menu comes with
4949
* extra costs associated with ensuring that the correct view is created.
5050
*
5151
* @param location the location to bind to this view

paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
buffer.writeVarInt(0);
66
} else {
77
+ // Paper start - data sanitization for items
8-
+ final io.papermc.paper.util.ItemObfuscationSession itemObfuscationSession = value.map.isEmpty()
8+
+ final io.papermc.paper.util.sanitizer.ItemObfuscationSession itemObfuscationSession = value.map.isEmpty()
99
+ ? null // Avoid thread local lookup of current session if it won't be needed anyway.
10-
+ : io.papermc.paper.util.ItemObfuscationSession.currentSession();
10+
+ : io.papermc.paper.util.sanitizer.ItemObfuscationSession.currentSession();
1111
+ // Paper end - data sanitization for items
1212
int i = 0;
1313
int i1 = 0;
@@ -17,15 +17,15 @@
1717
)) {
1818
if (entry.getValue().isPresent()) {
1919
- i++;
20-
+ if (!io.papermc.paper.util.ItemComponentSanitizer.shouldDrop(itemObfuscationSession, entry.getKey())) i++; // Paper - data sanitization for items
20+
+ if (!io.papermc.paper.util.sanitizer.ItemComponentSanitizer.shouldDrop(itemObfuscationSession, entry.getKey())) i++; // Paper - data sanitization for items
2121
} else {
2222
i1++;
2323
}
2424
@@ -126,6 +_,7 @@
2525
value.map
2626
)) {
2727
Optional<?> optional = entryx.getValue();
28-
+ optional = io.papermc.paper.util.ItemComponentSanitizer.override(itemObfuscationSession, entryx.getKey(), entryx.getValue()); // Paper - data sanitization for items
28+
+ optional = io.papermc.paper.util.sanitizer.ItemComponentSanitizer.override(itemObfuscationSession, entryx.getKey(), entryx.getValue()); // Paper - data sanitization for items
2929
if (optional.isPresent()) {
3030
DataComponentType<?> dataComponentType = entryx.getKey();
3131
DataComponentType.STREAM_CODEC.encode(buffer, dataComponentType);

paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
);
66
public static final DataComponentType<ChargedProjectiles> CHARGED_PROJECTILES = register(
77
- "charged_projectiles", builder -> builder.persistent(ChargedProjectiles.CODEC).networkSynchronized(ChargedProjectiles.STREAM_CODEC).cacheEncoding()
8-
+ "charged_projectiles", builder -> builder.persistent(ChargedProjectiles.CODEC).networkSynchronized(io.papermc.paper.util.OversizedItemComponentSanitizer.CHARGED_PROJECTILES).cacheEncoding() // Paper - sanitize charged projectiles
8+
+ "charged_projectiles", builder -> builder.persistent(ChargedProjectiles.CODEC).networkSynchronized(io.papermc.paper.util.sanitizer.OversizedItemComponentSanitizer.CHARGED_PROJECTILES).cacheEncoding() // Paper - sanitize charged projectiles
99
);
1010
public static final DataComponentType<BundleContents> BUNDLE_CONTENTS = register(
1111
- "bundle_contents", builder -> builder.persistent(BundleContents.CODEC).networkSynchronized(BundleContents.STREAM_CODEC).cacheEncoding()
12-
+ "bundle_contents", builder -> builder.persistent(BundleContents.CODEC).networkSynchronized(io.papermc.paper.util.OversizedItemComponentSanitizer.BUNDLE_CONTENTS).cacheEncoding() // Paper - sanitize bundle contents
12+
+ "bundle_contents", builder -> builder.persistent(BundleContents.CODEC).networkSynchronized(io.papermc.paper.util.sanitizer.OversizedItemComponentSanitizer.BUNDLE_CONTENTS).cacheEncoding() // Paper - sanitize bundle contents
1313
);
1414
public static final DataComponentType<PotionContents> POTION_CONTENTS = register(
1515
"potion_contents", builder -> builder.persistent(PotionContents.CODEC).networkSynchronized(PotionContents.STREAM_CODEC).cacheEncoding()
@@ -18,7 +18,7 @@
1818
);
1919
public static final DataComponentType<ItemContainerContents> CONTAINER = register(
2020
- "container", builder -> builder.persistent(ItemContainerContents.CODEC).networkSynchronized(ItemContainerContents.STREAM_CODEC).cacheEncoding()
21-
+ "container", builder -> builder.persistent(ItemContainerContents.CODEC).networkSynchronized(io.papermc.paper.util.OversizedItemComponentSanitizer.CONTAINER).cacheEncoding() // Paper - sanitize container contents
21+
+ "container", builder -> builder.persistent(ItemContainerContents.CODEC).networkSynchronized(io.papermc.paper.util.sanitizer.OversizedItemComponentSanitizer.CONTAINER).cacheEncoding() // Paper - sanitize container contents
2222
);
2323
public static final DataComponentType<BlockItemStateProperties> BLOCK_STATE = register(
2424
"block_state", builder -> builder.persistent(BlockItemStateProperties.CODEC).networkSynchronized(BlockItemStateProperties.STREAM_CODEC).cacheEncoding()

paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55

66
private static void pack(List<SynchedEntityData.DataValue<?>> dataValues, RegistryFriendlyByteBuf buffer) {
7-
+ try (io.papermc.paper.util.ItemObfuscationSession ignored = io.papermc.paper.util.ItemObfuscationSession.start(io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level)) { // Paper - data sanitization
7+
+ try (io.papermc.paper.util.sanitizer.ItemObfuscationSession ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.start(io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level)) { // Paper - data sanitization
88
for (SynchedEntityData.DataValue<?> dataValue : dataValues) {
99
dataValue.write(buffer);
1010
}

paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
buffer.writeVarInt(this.entity);
1919
int size = this.slots.size();
2020

21-
+ try (final io.papermc.paper.util.ItemObfuscationSession ignored = io.papermc.paper.util.ItemObfuscationSession.start(this.sanitize ? io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level : io.papermc.paper.util.ItemObfuscationSession.ObfuscationLevel.NONE)) { // Paper - data sanitization
21+
+ try (final io.papermc.paper.util.sanitizer.ItemObfuscationSession ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.start(this.sanitize ? io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level : io.papermc.paper.util.sanitizer.ItemObfuscationSession.ObfuscationLevel.NONE)) { // Paper - data sanitization
2222
for (int i = 0; i < size; i++) {
2323
Pair<EquipmentSlot, ItemStack> pair = this.slots.get(i);
2424
EquipmentSlot equipmentSlot = pair.getFirst();

paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@
10561056
+ // blocks at the same Y level with the same state can be assumed to be saplings which trigger observers regardless of if the
10571057
+ // tree grew or not
10581058
+ if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) {
1059-
+ this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlag(), 512);
1059+
+ this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlags(), 512);
10601060
+ }
10611061
+ }
10621062
+ // Paper end - notify observers even if grow failed

paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch

+1-5
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
this.debugLogging(pos, false, sequence, "too far");
9393
} else if (pos.getY() > maxBuildHeight) {
9494
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
95-
@@ -138,16 +_,39 @@
95+
@@ -138,16 +_,35 @@
9696
} else {
9797
if (action == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) {
9898
if (!this.level.mayInteract(this.player, pos)) {
@@ -102,7 +102,6 @@
102102
this.debugLogging(pos, false, sequence, "may not interact");
103103
- return;
104104
- }
105-
+ // Update any tile entity data for this block
106105
+ this.capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
107106
+ // CraftBukkit end
108107
+ return;
@@ -111,9 +110,6 @@
111110
+ // CraftBukkit start
112111
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, pos, face, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND);
113112
+ if (event.isCancelled()) {
114-
+ // Let the client know the block still exists
115-
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Paper - Don't resync blocks
116-
+ // Update any tile entity data for this block
117113
+ this.capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
118114
+ return;
119115
+ }

paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
buffer.writeVarInt(0);
1010
} else {
1111
- buffer.writeVarInt(value.getCount());
12-
+ buffer.writeVarInt(io.papermc.paper.util.ItemComponentSanitizer.sanitizeCount(io.papermc.paper.util.ItemObfuscationSession.currentSession(), value, value.getCount())); // Paper - potentially sanitize count
12+
+ buffer.writeVarInt(io.papermc.paper.util.sanitizer.ItemComponentSanitizer.sanitizeCount(io.papermc.paper.util.sanitizer.ItemObfuscationSession.currentSession(), value, value.getCount())); // Paper - potentially sanitize count
1313
Item.STREAM_CODEC.encode(buffer, value.getItemHolder());
1414
+ // Paper start - adventure; conditionally render translatable components
1515
+ boolean prev = net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.get();
16-
+ try (final io.papermc.paper.util.SafeAutoClosable ignored = io.papermc.paper.util.ItemObfuscationSession.withContext(c -> c.itemStack(value))) { // pass the itemstack as context to the obfuscation session
16+
+ try (final io.papermc.paper.util.SafeAutoClosable ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.withContext(c -> c.itemStack(value))) { // pass the itemstack as context to the obfuscation session
1717
+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(true);
1818
streamCodec.encode(buffer, value.components.asPatch());
1919
+ } finally {
@@ -125,7 +125,7 @@
125125
+ }
126126
+
127127
+ for (org.bukkit.block.BlockState blockstate : blocks) {
128-
+ int updateFlag = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getFlag();
128+
+ int updateFlags = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getFlags();
129129
+ net.minecraft.world.level.block.state.BlockState oldBlock = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getHandle();
130130
+ BlockPos newPos = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getPosition();
131131
+ net.minecraft.world.level.block.state.BlockState block = serverLevel.getBlockState(newPos);
@@ -134,7 +134,7 @@
134134
+ block.onPlace(serverLevel, newPos, oldBlock, true, context);
135135
+ }
136136
+
137-
+ serverLevel.notifyAndUpdatePhysics(newPos, null, oldBlock, block, serverLevel.getBlockState(newPos), updateFlag, net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point
137+
+ serverLevel.notifyAndUpdatePhysics(newPos, null, oldBlock, block, serverLevel.getBlockState(newPos), updateFlags, net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point
138138
+ }
139139
+
140140
+ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled

paper-server/patches/sources/net/minecraft/world/level/Level.java.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
+ this.capturedBlockStates.put(pos.immutable(), blockstate);
355355
+ }
356356
+ blockstate.setData(state);
357-
+ blockstate.setFlag(flags);
357+
+ blockstate.setFlags(flags);
358358
+ return true;
359359
+ }
360360
+ // CraftBukkit end
@@ -369,7 +369,7 @@
369369
+ boolean captured = false;
370370
+ if (this.captureBlockStates && !this.capturedBlockStates.containsKey(pos)) {
371371
+ CraftBlockState blockstate = (CraftBlockState) world.getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState(); // Paper - use CB getState to get a suitable snapshot
372-
+ blockstate.setFlag(flags); // Paper - set flag
372+
+ blockstate.setFlags(flags); // Paper - set flag
373373
+ this.capturedBlockStates.put(pos.immutable(), blockstate);
374374
+ captured = true;
375375
+ }

paper-server/patches/sources/net/minecraft/world/level/block/SpongeBlock.java.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
+ // Paper end - Fix SpongeAbsortEvent handling
8686
+ }
8787
+ }
88-
+ level.setBlock(blockPos, block.getHandle(), block.getFlag());
88+
+ level.setBlock(blockPos, block.getHandle(), block.getFlags());
8989
+ }
9090
+
9191
+ return true;

paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import io.papermc.paper.configuration.constraint.Constraints;
66
import io.papermc.paper.configuration.type.number.DoubleOr;
77
import io.papermc.paper.configuration.type.number.IntOr;
8-
import io.papermc.paper.util.ItemObfuscationBinding;
8+
import io.papermc.paper.util.sanitizer.ItemObfuscationBinding;
99
import net.kyori.adventure.text.Component;
1010
import net.kyori.adventure.text.format.NamedTextColor;
1111
import net.minecraft.core.component.DataComponents;
1212
import net.minecraft.network.protocol.Packet;
1313
import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket;
1414
import net.minecraft.resources.ResourceLocation;
15-
import net.minecraft.world.item.Items;
1615
import org.jspecify.annotations.Nullable;
1716
import org.slf4j.Logger;
1817
import org.spongepowered.configurate.objectmapping.ConfigSerializable;

paper-server/src/main/java/io/papermc/paper/util/ItemComponentSanitizer.java paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemComponentSanitizer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.papermc.paper.util;
1+
package io.papermc.paper.util.sanitizer;
22

33
import com.google.common.collect.ImmutableMap;
44
import io.papermc.paper.configuration.GlobalConfiguration;

paper-server/src/main/java/io/papermc/paper/util/ItemObfuscationBinding.java paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationBinding.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.papermc.paper.util;
1+
package io.papermc.paper.util.sanitizer;
22

33
import io.papermc.paper.configuration.GlobalConfiguration;
44
import java.util.Collections;
@@ -97,8 +97,7 @@ public BoundObfuscationConfiguration getAssetObfuscation(final ItemStack itemSta
9797
DataComponents.CAN_PLACE_ON,
9898
DataComponents.CAN_BREAK,
9999
DataComponents.ATTRIBUTE_MODIFIERS,
100-
DataComponents.HIDE_ADDITIONAL_TOOLTIP,
101-
DataComponents.HIDE_TOOLTIP,
100+
DataComponents.TOOLTIP_DISPLAY,
102101
DataComponents.REPAIR_COST,
103102
DataComponents.USE_REMAINDER,
104103
DataComponents.FOOD,

paper-server/src/main/java/io/papermc/paper/util/ItemObfuscationSession.java paper-server/src/main/java/io/papermc/paper/util/sanitizer/ItemObfuscationSession.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
package io.papermc.paper.util;
1+
package io.papermc.paper.util.sanitizer;
22

33
import java.util.function.UnaryOperator;
44
import com.google.common.base.Preconditions;
5+
import io.papermc.paper.util.SafeAutoClosable;
56
import net.minecraft.world.item.ItemStack;
67
import org.jspecify.annotations.NullMarked;
78
import org.jspecify.annotations.Nullable;

paper-server/src/main/java/io/papermc/paper/util/OversizedItemComponentSanitizer.java paper-server/src/main/java/io/papermc/paper/util/sanitizer/OversizedItemComponentSanitizer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package io.papermc.paper.util;
1+
package io.papermc.paper.util.sanitizer;
22

3+
import io.papermc.paper.util.SafeAutoClosable;
34
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
45
import java.util.List;
56
import java.util.function.UnaryOperator;

paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@
195195
import org.bukkit.craftbukkit.tag.CraftDamageTag;
196196
import org.bukkit.craftbukkit.tag.CraftEntityTag;
197197
import org.bukkit.craftbukkit.tag.CraftFluidTag;
198+
import org.bukkit.craftbukkit.tag.CraftGameEventTag;
198199
import org.bukkit.craftbukkit.tag.CraftItemTag;
199200
import org.bukkit.craftbukkit.util.ApiVersion;
200201
import org.bukkit.craftbukkit.util.CraftChatMessage;
@@ -2913,7 +2914,7 @@ public <T extends Keyed> org.bukkit.Tag<T> getTag(String registry, NamespacedKey
29132914
Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class, "Game Event namespace must have GameEvent type");
29142915
TagKey<net.minecraft.world.level.gameevent.GameEvent> gameEventTagKey = TagKey.create(net.minecraft.core.registries.Registries.GAME_EVENT, key);
29152916
if (net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.get(gameEventTagKey).isPresent()) {
2916-
return (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT, gameEventTagKey);
2917+
return (org.bukkit.Tag<T>) new CraftGameEventTag(net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT, gameEventTagKey);
29172918
}
29182919
}
29192920
// Paper end
@@ -2958,7 +2959,7 @@ public <T extends Keyed> Iterable<org.bukkit.Tag<T>> getTags(String registry, Cl
29582959
case org.bukkit.Tag.REGISTRY_GAME_EVENTS -> {
29592960
Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class);
29602961
net.minecraft.core.Registry<net.minecraft.world.level.gameevent.GameEvent> gameEvents = net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT;
2961-
return gameEvents.getTags().map(pair -> (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(gameEvents, pair.key())).collect(ImmutableList.toImmutableList());
2962+
return gameEvents.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftGameEventTag(gameEvents, pair.key())).collect(ImmutableList.toImmutableList());
29622963
}
29632964
// Paper end
29642965
default -> throw new IllegalArgumentException();

0 commit comments

Comments
 (0)