geforkt von Mirrors/Paper
Multi Block Change API Implementation
Dieser Commit ist enthalten in:
Ursprung
1476dea76f
Commit
a17ed327b3
@ -21,3 +21,18 @@
|
|||||||
private ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf buf) {
|
private ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf buf) {
|
||||||
this.sectionPos = SectionPos.of(buf.readLong());
|
this.sectionPos = SectionPos.of(buf.readLong());
|
||||||
int i = buf.readVarInt();
|
int i = buf.readVarInt();
|
||||||
|
@@ -54,6 +62,14 @@
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start - Multi Block Change API
|
||||||
|
+ public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap<BlockState> blockChanges) {
|
||||||
|
+ this.sectionPos = sectionPos;
|
||||||
|
+ this.positions = blockChanges.keySet().toShortArray();
|
||||||
|
+ this.states = blockChanges.values().toArray(new BlockState[0]);
|
||||||
|
+ }
|
||||||
|
+ // Paper end - Multi Block Change API
|
||||||
|
+
|
||||||
|
private void write(FriendlyByteBuf buf) {
|
||||||
|
buf.writeLong(this.sectionPos.asLong());
|
||||||
|
buf.writeVarInt(this.positions.length);
|
||||||
|
@ -937,6 +937,32 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
this.getHandle().connection.send(packet);
|
this.getHandle().connection.send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Paper start
|
||||||
|
@Override
|
||||||
|
public void sendMultiBlockChange(final Map<? extends io.papermc.paper.math.Position, BlockData> blockChanges) {
|
||||||
|
if (this.getHandle().connection == null) return;
|
||||||
|
|
||||||
|
Map<SectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap<net.minecraft.world.level.block.state.BlockState>> sectionMap = new HashMap<>();
|
||||||
|
|
||||||
|
for (Map.Entry<? extends io.papermc.paper.math.Position, BlockData> entry : blockChanges.entrySet()) {
|
||||||
|
BlockData blockData = entry.getValue();
|
||||||
|
BlockPos blockPos = io.papermc.paper.util.MCUtil.toBlockPos(entry.getKey());
|
||||||
|
SectionPos sectionPos = SectionPos.of(blockPos);
|
||||||
|
|
||||||
|
it.unimi.dsi.fastutil.shorts.Short2ObjectMap<net.minecraft.world.level.block.state.BlockState> sectionData = sectionMap.computeIfAbsent(sectionPos, key -> new it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap<>());
|
||||||
|
sectionData.put(SectionPos.sectionRelativePos(blockPos), ((CraftBlockData) blockData).getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<SectionPos, it.unimi.dsi.fastutil.shorts.Short2ObjectMap<net.minecraft.world.level.block.state.BlockState>> entry : sectionMap.entrySet()) {
|
||||||
|
SectionPos sectionPos = entry.getKey();
|
||||||
|
it.unimi.dsi.fastutil.shorts.Short2ObjectMap<net.minecraft.world.level.block.state.BlockState> blockData = entry.getValue();
|
||||||
|
|
||||||
|
net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket packet = new net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket(sectionPos, blockData);
|
||||||
|
this.getHandle().connection.send(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendBlockChanges(Collection<BlockState> blocks) {
|
public void sendBlockChanges(Collection<BlockState> blocks) {
|
||||||
Preconditions.checkArgument(blocks != null, "blocks must not be null");
|
Preconditions.checkArgument(blocks != null, "blocks must not be null");
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren