-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: PureGero <puregero@gmail.com> | ||
Date: Sun, 11 Aug 2024 18:50:42 +0900 | ||
Subject: [PATCH] /clear command | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/server/commands/ClearInventoryCommands.java b/src/main/java/net/minecraft/server/commands/ClearInventoryCommands.java | ||
index 4e6171ca870649114d4c7460baad2982173da09e..f3efba187cfb35e08458de59a171c82bff8d3280 100644 | ||
--- a/src/main/java/net/minecraft/server/commands/ClearInventoryCommands.java | ||
+++ b/src/main/java/net/minecraft/server/commands/ClearInventoryCommands.java | ||
@@ -6,7 +6,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
+import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Predicate; | ||
+ | ||
+import io.multipaper.shreddedpaper.ShreddedPaper; | ||
import net.minecraft.commands.CommandBuildContext; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.commands.Commands; | ||
@@ -65,9 +68,16 @@ public class ClearInventoryCommands { | ||
int i = 0; | ||
|
||
for (ServerPlayer serverPlayer : targets) { | ||
- i += serverPlayer.getInventory().clearOrCountMatchingItems(item, maxCount, serverPlayer.inventoryMenu.getCraftSlots()); | ||
- serverPlayer.containerMenu.broadcastChanges(); | ||
- serverPlayer.inventoryMenu.slotsChanged(serverPlayer.getInventory()); | ||
+ // ShreddedPaper start - run on correct thread | ||
+ CompletableFuture<Integer> future = new CompletableFuture<>(); | ||
+ ShreddedPaper.ensureSync(serverPlayer, () -> { | ||
+ int j = serverPlayer.getInventory().clearOrCountMatchingItems(item, maxCount, serverPlayer.inventoryMenu.getCraftSlots()); | ||
+ serverPlayer.containerMenu.broadcastChanges(); | ||
+ serverPlayer.inventoryMenu.slotsChanged(serverPlayer.getInventory()); | ||
+ future.complete(j); | ||
+ }); | ||
+ i += future.getNow(1); // ShreddedPaper - default to 1 if player in on a different thread | ||
+ // ShreddedPaper end - run on correct thread | ||
} | ||
|
||
if (i == 0) { |