Skip to content

Commit d6c852e

Browse files
committed
fixed issues on imports yarn 1.20.1 and 1.21.4 differences
need more to look on it
1 parent b2e55ad commit d6c852e

14 files changed

Lines changed: 218 additions & 216 deletions

File tree

fabric/src/main/java/com/axalotl/async/commands/AsyncCommand.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
import com.mojang.brigadier.CommandDispatcher;
44
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
5-
import net.minecraft.server.command.CommandManagerourceStack;
6-
import net.minecraft.text.Component;
5+
import net.minecraft.server.command.ServerCommandSource;
6+
import net.minecraft.text.Text;
77

88
import static net.minecraft.server.command.CommandManager.literal;
99

1010
public class AsyncCommand {
11-
public final static Component prefix = Component.literal("§8[§f\uD83C\uDF00§8]§7 ");
11+
public static final Text prefix = Text.literal("§8[§f🌀§8]§7 ");
1212

1313
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
14-
LiteralArgumentBuilder<ServerCommandSource> main = literal("async").requires(source -> source.hasPermission(4));
15-
main = ConfigCommand.registerConfig(main).requires(source -> source.hasPermission(4));
16-
main = StatsCommand.registerStatus(main).requires(source -> source.hasPermission(4));
14+
LiteralArgumentBuilder<ServerCommandSource> main = literal("async").requires(source -> source.hasPermissionLevel(4));
15+
main = ConfigCommand.registerConfig(main).requires(source -> source.hasPermissionLevel(4));
16+
main = StatsCommand.registerStatus(main).requires(source -> source.hasPermissionLevel(4));
1717
dispatcher.register(main);
1818
}
1919
}

fabric/src/main/java/com/axalotl/async/commands/ConfigCommand.java

Lines changed: 58 additions & 57 deletions
Large diffs are not rendered by default.

fabric/src/main/java/com/axalotl/async/commands/StatsCommand.java

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
import com.mojang.brigadier.arguments.ArgumentType;
66
import com.mojang.brigadier.arguments.IntegerArgumentType;
77
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
8+
import net.minecraft.entity.Entity;
9+
import net.minecraft.server.world.ServerWorld;
810
import net.minecraft.util.Formatting;
9-
import net.minecraft.ResourceLocationException;
10-
import net.minecraft.server.command.CommandManagerourceStack;
11-
import net.minecraft.core.registries.Registries;
12-
import net.minecraft.text.Component;
13-
import net.minecraft.text.MutableComponent;
11+
import net.minecraft.util.InvalidIdentifierException;
12+
import net.minecraft.server.command.ServerCommandSource;
13+
import net.minecraft.entity.EntityType;
1414
import net.minecraft.util.Identifier;
15+
import net.minecraft.util.registry.Registry;
16+
import net.minecraft.text.Text;
17+
import net.minecraft.text.MutableText;
1518
import net.minecraft.server.MinecraftServer;
16-
import net.minecraft.world.entity.EntityType;
1719
import org.apache.logging.log4j.LogManager;
1820
import org.apache.logging.log4j.Logger;
1921

@@ -41,13 +43,13 @@ public class StatsCommand {
4143

4244
public static LiteralArgumentBuilder<ServerCommandSource> registerStatus(LiteralArgumentBuilder<ServerCommandSource> root) {
4345
return root.then(literal("stats")
44-
.requires(cmdSrc -> cmdSrc.hasPermission(4))
46+
.requires(cmdSrc -> cmdSrc.hasPermissionLevel(4))
4547
.executes(cmdCtx -> {
4648
showGeneralStats(cmdCtx.getSource());
4749
return 1;
4850
})
4951
.then(literal("entity")
50-
.requires(cmdSrc -> cmdSrc.hasPermission(4))
52+
.requires(cmdSrc -> cmdSrc.hasPermissionLevel(4))
5153
.executes(cmdCtx -> {
5254
showEntityStats(cmdCtx.getSource(), 0);
5355
return 1;
@@ -65,18 +67,18 @@ private static void showGeneralStats(ServerCommandSource source) {
6567
double avgThreads = calculateAverageThreads();
6668
double threadUtilization = (avgThreads / availableProcessors) * 100.0;
6769

68-
MutableComponent message = prefix.copy()
69-
.append(Component.literal("Performance Statistics ").withStyle(style -> style.withColor(ChatFormatting.GOLD)))
70-
.append(Component.literal("\nActive Processing Threads: ").withStyle(style -> style.withColor(ChatFormatting.WHITE)))
71-
.append(Component.literal(DECIMAL_FORMAT.format(avgThreads)).withStyle(style -> style.withColor(ChatFormatting.GREEN)))
72-
.append(Component.literal(" / " + availableProcessors).withStyle(style -> style.withColor(ChatFormatting.GRAY)))
73-
.append(Component.literal("\nThread Utilization: ").withStyle(style -> style.withColor(ChatFormatting.WHITE)))
74-
.append(Component.literal(DECIMAL_FORMAT.format(threadUtilization) + "%").withStyle(style -> style.withColor(ChatFormatting.GREEN)))
75-
.append(Component.literal("\nAsync Status: ").withStyle(style -> style.withColor(ChatFormatting.WHITE)))
76-
.append(Component.literal(AsyncConfig.disabled ? "Disabled" : "Enabled").withStyle(style ->
77-
style.withColor(AsyncConfig.disabled ? ChatFormatting.RED : ChatFormatting.GREEN)));
78-
79-
source.sendSuccess(() -> message, true);
70+
MutableText message = prefix.copy()
71+
.append(Text.literal("Performance Statistics ").styled(style -> style.withColor(Formatting.GOLD)))
72+
.append(Text.literal("\nActive Processing Threads: ").styled(style -> style.withColor(Formatting.WHITE)))
73+
.append(Text.literal(DECIMAL_FORMAT.format(avgThreads)).styled(style -> style.withColor(Formatting.GREEN)))
74+
.append(Text.literal(" / " + availableProcessors).styled(style -> style.withColor(Formatting.GRAY)))
75+
.append(Text.literal("\nThread Utilization: ").styled(style -> style.withColor(Formatting.WHITE)))
76+
.append(Text.literal(DECIMAL_FORMAT.format(threadUtilization) + "%").styled(style -> style.withColor(Formatting.GREEN)))
77+
.append(Text.literal("\nAsync Status: ").styled(style -> style.withColor(Formatting.WHITE)))
78+
.append(Text.literal(AsyncConfig.disabled ? "Disabled" : "Enabled").styled(style ->
79+
style.withColor(AsyncConfig.disabled ? Formatting.RED : Formatting.GREEN)));
80+
81+
source.sendFeedback(() -> message, true);
8082
}
8183

8284
private static void showEntityStats(ServerCommandSource source, int topCount) {
@@ -87,15 +89,15 @@ private static void showEntityStats(ServerCommandSource source, int topCount) {
8789
AtomicInteger totalEntities = new AtomicInteger(0);
8890
AtomicInteger totalAsyncEntities = new AtomicInteger(0);
8991

90-
MutableComponent message = prefix.copy()
91-
.append(Component.literal("Entity Statistics ").withStyle(style -> style.withColor(ChatFormatting.GOLD)));
92+
MutableText message = prefix.copy()
93+
.append(Text.literal("Entity Statistics ").styled(style -> style.withColor(Formatting.GOLD)));
9294

93-
server.getAllLevels().forEach(world -> {
94-
String worldName = world.dimension().location().toString();
95+
for (ServerWorld world : server.getWorlds()) {
96+
String worldName = world.getRegistryKey().getValue().toString();
9597
AtomicInteger worldCount = new AtomicInteger(0);
9698
AtomicInteger asyncCount = new AtomicInteger(0);
9799

98-
world.entityTickList.forEach(entity -> {
100+
for (Entity entity : world.iterateEntities()) {
99101
if (entity != null && entity.isAlive()) {
100102
EntityType<?> entityType = entity.getType();
101103

@@ -109,20 +111,20 @@ private static void showEntityStats(ServerCommandSource source, int topCount) {
109111
asyncEntityTypeCounts.merge(entityType, 1, Integer::sum);
110112
}
111113
}
112-
});
114+
};
113115

114-
message.append(Component.literal("\n" + worldName + ": ").withStyle(style -> style.withColor(ChatFormatting.YELLOW)))
115-
.append(Component.literal(String.valueOf(worldCount.get())).withStyle(style -> style.withColor(ChatFormatting.GREEN)))
116-
.append(Component.literal(" entities (").withStyle(style -> style.withColor(ChatFormatting.GRAY)))
117-
.append(Component.literal(String.valueOf(asyncCount.get())).withStyle(style -> style.withColor(ChatFormatting.AQUA)))
118-
.append(Component.literal(" async)").withStyle(style -> style.withColor(ChatFormatting.GRAY)));
119-
});
116+
message.append(Text.literal("\n" + worldName + ": ").styled(style -> style.withColor(Formatting.YELLOW)))
117+
.append(Text.literal(String.valueOf(worldCount.get())).styled(style -> style.withColor(Formatting.GREEN)))
118+
.append(Text.literal(" entities (").styled(style -> style.withColor(Formatting.GRAY)))
119+
.append(Text.literal(String.valueOf(asyncCount.get())).styled(style -> style.withColor(Formatting.AQUA)))
120+
.append(Text.literal(" async)").styled(style -> style.withColor(Formatting.GRAY)));
121+
};
120122

121-
message.append(Component.literal("\nTotal Entities: ").withStyle(style -> style.withColor(ChatFormatting.WHITE)))
122-
.append(Component.literal(String.valueOf(totalEntities.get())).withStyle(style -> style.withColor(ChatFormatting.GOLD)))
123-
.append(Component.literal(" (").withStyle(style -> style.withColor(ChatFormatting.GRAY)))
124-
.append(Component.literal(String.valueOf(totalAsyncEntities.get())).withStyle(style -> style.withColor(ChatFormatting.AQUA)))
125-
.append(Component.literal(" async)").withStyle(style -> style.withColor(ChatFormatting.GRAY)));
123+
message.append(Text.literal("\nTotal Entities: ").styled(style -> style.withColor(Formatting.WHITE)))
124+
.append(Text.literal(String.valueOf(totalEntities.get())).styled(style -> style.withColor(Formatting.GOLD)))
125+
.append(Text.literal(" (").styled(style -> style.withColor(Formatting.GRAY)))
126+
.append(Text.literal(String.valueOf(totalAsyncEntities.get())).styled(style -> style.withColor(Formatting.AQUA)))
127+
.append(Text.literal(" async)").styled(style -> style.withColor(Formatting.GRAY)));
126128

127129
if (topCount > 0) {
128130
List<Map.Entry<EntityType<?>, Integer>> sortedEntities = new ArrayList<>(entityTypeCounts.entrySet());
@@ -133,30 +135,30 @@ private static void showEntityStats(ServerCommandSource source, int topCount) {
133135
}
134136

135137
if (!sortedEntities.isEmpty()) {
136-
message.append(Component.literal("\n\nTop " + sortedEntities.size() + " Entity Types:").withStyle(style -> style.withColor(ChatFormatting.GOLD)));
138+
message.append(Text.literal("\n\nTop " + sortedEntities.size() + " Entity Types:").styled(style -> style.withColor(Formatting.GOLD)));
137139

138140
int rank = 1;
139141
for (Map.Entry<EntityType<?>, Integer> entry : sortedEntities) {
140142
EntityType<?> type = entry.getKey();
141143
int count = entry.getValue();
142144
int asyncCount = asyncEntityTypeCounts.getOrDefault(type, 0);
143145

144-
ResourceLocation typeId = EntityType.getKey(type);
146+
Identifier typeId = Registry.ENTITY_TYPE.getId(type);
145147
String name = typeId.toString();
146148

147-
message.append(Component.literal("\n" + rank + ". ").withStyle(style -> style.withColor(ChatFormatting.GRAY)))
148-
.append(Component.literal(name).withStyle(style -> style.withColor(ChatFormatting.YELLOW)))
149-
.append(Component.literal(": ").withStyle(style -> style.withColor(ChatFormatting.GRAY)))
150-
.append(Component.literal(String.valueOf(count)).withStyle(style -> style.withColor(ChatFormatting.GREEN)))
151-
.append(Component.literal(" (").withStyle(style -> style.withColor(ChatFormatting.GRAY)))
152-
.append(Component.literal(String.valueOf(asyncCount)).withStyle(style -> style.withColor(ChatFormatting.AQUA)))
153-
.append(Component.literal(" async)").withStyle(style -> style.withColor(ChatFormatting.GRAY)));
149+
message.append(Text.literal("\n" + rank + ". ").styled(style -> style.withColor(Formatting.GRAY)))
150+
.append(Text.literal(name).styled(style -> style.withColor(Formatting.YELLOW)))
151+
.append(Text.literal(": ").styled(style -> style.withColor(Formatting.GRAY)))
152+
.append(Text.literal(String.valueOf(count)).styled(style -> style.withColor(Formatting.GREEN)))
153+
.append(Text.literal(" (").styled(style -> style.withColor(Formatting.GRAY)))
154+
.append(Text.literal(String.valueOf(asyncCount)).styled(style -> style.withColor(Formatting.AQUA)))
155+
.append(Text.literal(" async)").styled(style -> style.withColor(Formatting.GRAY)));
154156

155157
rank++;
156158
}
157159
}
158160
}
159-
source.sendSuccess(() -> message, true);
161+
source.sendFeedback(() -> message, true);
160162
});
161163
}
162164

fabric/src/main/resources/async.accesswidener

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ accessible field net/minecraft/world/chunk/WorldChunk$WrappedBlockEntityTickInvo
55
accessible field net/minecraft/world/chunk/WorldChunk$DirectBlockEntityTickInvoker blockEntity Lnet/minecraft/block/entity/BlockEntity;
66
accessible method net/minecraft/server/world/ServerWorld processBlockEvent (Lnet/minecraft/server/world/BlockEvent;)Z
77
accessible method net/minecraft/server/world/ServerChunkManager getChunkHolder (J)Lnet/minecraft/server/world/ChunkHolder;
8+
accessible class net/minecraft/world/BlockEventData
89
accessible method net/minecraft/server/world/ServerChunkManager$MainThreadExecutor runTask ()Z
910
accessible method net/minecraft/world/World tickBlockEntities ()V
1011
accessible method net/minecraft/server/world/ThreadedAnvilChunkStorage shouldTick (Lnet/minecraft/util/math/ChunkPos;)Z

forge/src/main/java/com/axalotl/async/commands/AsyncCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import static net.minecraft.server.command.CommandManager.literal;
99

1010
public class AsyncCommand {
11-
public final static Component prefix = Component.literal("§8[§f\uD83C\uDF00§8]§7 ");
11+
public final static Text prefix = Text.literal("§8[§f\uD83C\uDF00§8]§7 ");
1212

1313
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated) {
1414
LiteralArgumentBuilder<ServerCommandSource> main = literal("async");

0 commit comments

Comments
 (0)