|
34 | 34 | import net.kyori.adventure.text.Component; |
35 | 35 | import net.minecraft.advancements.Advancement; |
36 | 36 | import net.minecraft.advancements.AdvancementHolder; |
| 37 | +import net.minecraft.core.BlockPos; |
37 | 38 | import net.minecraft.network.Connection; |
38 | 39 | import net.minecraft.network.chat.ChatType; |
39 | 40 | import net.minecraft.network.chat.MessageSignature; |
40 | 41 | import net.minecraft.network.chat.PlayerChatMessage; |
| 42 | +import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket; |
41 | 43 | import net.minecraft.network.protocol.game.ClientboundDeleteChatPacket; |
42 | 44 | import net.minecraft.network.protocol.game.ClientboundInitializeBorderPacket; |
43 | 45 | import net.minecraft.resources.ResourceLocation; |
@@ -115,7 +117,9 @@ public abstract class ServerPlayerMixin_API extends PlayerMixin_API implements S |
115 | 117 | // @formatter:on |
116 | 118 |
|
117 | 119 |
|
118 | | - @Shadow @Nullable private Vec3 enteredLavaOnVehiclePosition; |
| 120 | + @Shadow |
| 121 | + @Nullable |
| 122 | + private Vec3 enteredLavaOnVehiclePosition; |
119 | 123 | private volatile Pointers api$pointers; |
120 | 124 |
|
121 | 125 | private final TabList api$tabList = new SpongeTabList((net.minecraft.server.level.ServerPlayer) (Object) this); |
@@ -152,7 +156,7 @@ public ServerSideConnection connection() { |
152 | 156 | /** |
153 | 157 | * @author Minecrell - August 22nd, 2016 |
154 | 158 | * @reason Use InetSocketAddress#getHostString() where possible (instead of |
155 | | - * inspecting SocketAddress#toString()) to support IPv6 addresses |
| 159 | + * inspecting SocketAddress#toString()) to support IPv6 addresses |
156 | 160 | */ |
157 | 161 | @Overwrite |
158 | 162 | public String getIpAddress() { |
@@ -207,6 +211,27 @@ public boolean hasPlayedBefore() { |
207 | 211 | return timeSinceFirstJoined.getSeconds() > 0; |
208 | 212 | } |
209 | 213 |
|
| 214 | + @Override |
| 215 | + public void sendBlockProgress(final int x, final int y, final int z, final double progress) { |
| 216 | + if (progress < 0 || progress > 1) { |
| 217 | + throw new IllegalArgumentException("Progress must be between 0 and 1"); |
| 218 | + } |
| 219 | + |
| 220 | + final BlockPos pos = new BlockPos(x, y, z); |
| 221 | + final int id = ((SpongeServer) this.server).getOrCreateBlockDestructionId(pos); |
| 222 | + final int progressStage = progress == 1 ? 9 : (int) (progress * 10); |
| 223 | + this.connection.send(new ClientboundBlockDestructionPacket(id, pos, progressStage)); |
| 224 | + } |
| 225 | + |
| 226 | + @Override |
| 227 | + public void resetBlockProgress(final int x, final int y, final int z) { |
| 228 | + final BlockPos pos = new BlockPos(x, y, z); |
| 229 | + final Integer id = ((SpongeServer) this.server).getBlockDestructionId(pos); |
| 230 | + if (id != null) { |
| 231 | + this.connection.send(new ClientboundBlockDestructionPacket(id, pos, -1)); |
| 232 | + } |
| 233 | + } |
| 234 | + |
210 | 235 | @Override |
211 | 236 | public boolean respawn() { |
212 | 237 | if (this.impl$isFake) { |
@@ -275,21 +300,21 @@ public Optional<WorldBorder> setWorldBorder(final @Nullable WorldBorder border) |
275 | 300 | return currentBorder; // do not fire an event since nothing would have changed |
276 | 301 | } |
277 | 302 | final ChangeWorldBorderEvent.Player event = |
278 | | - SpongeEventFactory.createChangeWorldBorderEventPlayer(PhaseTracker.getCauseStackManager().currentCause(), |
279 | | - Optional.ofNullable(border), Optional.ofNullable(border), this, Optional.ofNullable(border)); |
| 303 | + SpongeEventFactory.createChangeWorldBorderEventPlayer(PhaseTracker.getCauseStackManager().currentCause(), |
| 304 | + Optional.ofNullable(border), Optional.ofNullable(border), this, Optional.ofNullable(border)); |
280 | 305 | if (SpongeCommon.post(event)) { |
281 | 306 | return currentBorder; |
282 | 307 | } |
283 | 308 |
|
284 | 309 | final net.minecraft.world.level.border.@Nullable WorldBorder oldWorldBorder = ((ServerPlayerBridge) this).bridge$getWorldBorder(); |
285 | 310 | if (oldWorldBorder != null) { // is the world border about to be unset? |
286 | 311 | ((WorldBorderAccessor) oldWorldBorder).accessor$listeners().remove( |
287 | | - ((ServerPlayerBridge) this).bridge$getWorldBorderListener()); // remove the listener, if so |
| 312 | + ((ServerPlayerBridge) this).bridge$getWorldBorderListener()); // remove the listener, if so |
288 | 313 | } |
289 | 314 | final Optional<WorldBorder> toSet = event.newBorder(); |
290 | 315 | if (toSet.isPresent()) { |
291 | 316 | final net.minecraft.world.level.border.WorldBorder mutableWorldBorder = |
292 | | - new net.minecraft.world.level.border.WorldBorder(); |
| 317 | + new net.minecraft.world.level.border.WorldBorder(); |
293 | 318 | ((WorldBorderBridge) mutableWorldBorder).bridge$applyFrom(toSet.get()); |
294 | 319 | ((ServerPlayerBridge) this).bridge$replaceWorldBorder(mutableWorldBorder); |
295 | 320 | mutableWorldBorder.addListener(((ServerPlayerBridge) this).bridge$getWorldBorderListener()); |
@@ -439,7 +464,7 @@ public void sendResourcePacks(final @NonNull ResourcePackRequest request) { |
439 | 464 | } |
440 | 465 |
|
441 | 466 | @Override |
442 | | - public void removeResourcePacks(final @NonNull UUID id, final @NonNull UUID @NonNull... others) { |
| 467 | + public void removeResourcePacks(final @NonNull UUID id, final @NonNull UUID @NonNull ... others) { |
443 | 468 | ((ServerCommonPacketListenerImplBridge) this.connection).bridge$removeResourcePacks(id, others); |
444 | 469 | } |
445 | 470 |
|
|
0 commit comments