Skip to content

Commit

Permalink
delete gui code
Browse files Browse the repository at this point in the history
  • Loading branch information
MeiNanziiii committed Nov 3, 2024
1 parent f5d62ff commit 8f866c3
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 118 deletions.
12 changes: 0 additions & 12 deletions src/main/java/ua/mei/mgui/api/font/GUITextureManager.java

This file was deleted.

12 changes: 5 additions & 7 deletions src/main/java/ua/mei/mgui/api/hud/ServerHudRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ public static ServerHud register(Identifier identifier, Supplier<ServerHud> hudS
ServerHud hud = hudSupplier.get();
registeredHuds.put(identifier, hud);

registeredHuds = registeredHuds.entrySet()
registeredHuds.entrySet()
.stream()
.sorted(Map.Entry.<Identifier, ServerHud>comparingByValue(Comparator.comparingInt(h -> h.root.getWidth())).reversed())
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue,
(e1, e2) -> e1,
LinkedHashMap::new
));
.forEachOrdered(entry -> {
registeredHuds.remove(entry.getKey());
registeredHuds.put(entry.getKey(), entry.getValue());
});

return hud;
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/ua/mei/mgui/impl/MGuiImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@

@ApiStatus.Internal
public class MGuiImpl implements ModInitializer {
public static final String MOD_ID = "mgui";
public static final boolean GUI_ENABLED = false;

@Override
public void onInitialize() {
PolymerResourcePackUtils.addModAssets("mgui");

VanillaTextures.load();

ServerTickEvents.END_SERVER_TICK.register(ServerHudRenderer::updateAllPlayers);
}
}
26 changes: 11 additions & 15 deletions src/main/java/ua/mei/mgui/impl/ServerHudRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ public class ServerHudRenderer {
private static final Map<ServerPlayerEntity, List<ServerHud>> pendingHudUpdates = new HashMap<>();

public static void renderHudForPlayer(ServerPlayerEntity player) {
List<ServerHud> playerHudUpdates = pendingHudUpdates.getOrDefault(player, Collections.emptyList());
List<ServerHud> playerHudUpdates = pendingHudUpdates.get(player);
if (playerHudUpdates == null || playerHudUpdates.isEmpty()) {
player.sendMessageToClient(Text.empty(), true);
return;
}

HudGroup hudGroup = HudGroup.empty(null);

List<ServerHud> filteredHuds = ServerHudRegistry.getRegisteredHuds().values()
ServerHudRegistry.getRegisteredHuds().values()
.stream()
.filter(playerHudUpdates::contains)
.toList();

for (ServerHud hud : filteredHuds) {
hud.tick(player);
hudGroup.addPart(hud.root);
}
.forEach(hud -> {
hud.tick(player);
hudGroup.addPart(hud.root);
});

player.sendMessageToClient(hudGroup.render(), true);
}
Expand All @@ -44,13 +45,8 @@ public static void addHud(ServerPlayerEntity player, ServerHud hud) {

public static void removeHud(ServerPlayerEntity player, ServerHud hud) {
List<ServerHud> playerHuds = pendingHudUpdates.get(player);

if (playerHuds != null && playerHuds.remove(hud)) {
if (playerHuds.isEmpty()) {
player.sendMessageToClient(Text.empty(), true);
} else {
renderHudForPlayer(player);
}
renderHudForPlayer(player);
}
}
}
51 changes: 0 additions & 51 deletions src/main/java/ua/mei/mgui/impl/VanillaTextures.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/ua/mei/mgui/mixin/ServerPlayerEntityMixin.java

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion src/test/java/ua/mei/mgui/test/MGuiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public void onInitialize() {
hud2 = ServerHudRegistry.register(Identifier.of("mgui_test:test_hud_2"), YetAnotherTestHud::new);
hud = ServerHudRegistry.register(Identifier.of("mgui_test:test_hud"), TestHud::new);


ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
hud.show(handler.player);
hud2.show(handler.player);
Expand Down
1 change: 0 additions & 1 deletion src/test/java/ua/mei/mgui/test/TestHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public TestHud() {
.align(HudAlign.RIGHT)
)
.addPart(GlyphPart.create(this, "gui/sprite_0.png", 128))

)
.addPart(HudGroup.empty(this)
.addPart(HudGroup.empty(this)
Expand Down

0 comments on commit 8f866c3

Please sign in to comment.