From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: feat: TU19 (Dec 2014) Features & Content (#155) * try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki --- Minecraft.World/ScoreboardSaveData.h | 189 +++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 Minecraft.World/ScoreboardSaveData.h (limited to 'Minecraft.World/ScoreboardSaveData.h') diff --git a/Minecraft.World/ScoreboardSaveData.h b/Minecraft.World/ScoreboardSaveData.h new file mode 100644 index 00000000..4a59b45e --- /dev/null +++ b/Minecraft.World/ScoreboardSaveData.h @@ -0,0 +1,189 @@ +#pragma once + +// 4J Not converted +#if 0 +class ScoreboardSaveData extends SavedData { + public static final String FILE_ID = "scoreboard"; + + private Scoreboard scoreboard; + private CompoundTag delayLoad; + + public ScoreboardSaveData() { + this(FILE_ID); + } + + public ScoreboardSaveData(String id) { + super(id); + } + + public void setScoreboard(Scoreboard scoreboard) { + this.scoreboard = scoreboard; + + if (delayLoad != null) { + load(delayLoad); + } + } + + @Override + public void load(CompoundTag tag) { + if (scoreboard == null) { + delayLoad = tag; + return; + } + + loadObjectives((ListTag) tag.getList("Objectives")); + loadPlayerScores((ListTag) tag.getList("PlayerScores")); + + if (tag.contains("DisplaySlots")) { + loadDisplaySlots(tag.getCompound("DisplaySlots")); + } + + if (tag.contains("Teams")) { + loadTeams((ListTag) tag.getList("Teams")); + } + } + + protected void loadTeams(ListTag list) { + for (int i = 0; i < list.size(); i++) { + CompoundTag tag = list.get(i); + + PlayerTeam team = scoreboard.addPlayerTeam(tag.getString("Name")); + team.setDisplayName(tag.getString("DisplayName")); + team.setPrefix(tag.getString("Prefix")); + team.setSuffix(tag.getString("Suffix")); + if (tag.contains("AllowFriendlyFire")) team.setAllowFriendlyFire(tag.getBoolean("AllowFriendlyFire")); + if (tag.contains("SeeFriendlyInvisibles")) team.setSeeFriendlyInvisibles(tag.getBoolean("SeeFriendlyInvisibles")); + + loadTeamPlayers(team, (ListTag) tag.getList("Players")); + } + } + + protected void loadTeamPlayers(PlayerTeam team, ListTag list) { + for (int i = 0; i < list.size(); i++) { + scoreboard.addPlayerToTeam(list.get(i).data, team); + } + } + + protected void loadDisplaySlots(CompoundTag tag) { + for (int i = 0; i < Scoreboard.DISPLAY_SLOTS; i++) { + if (tag.contains("slot_" + i)) { + String name = tag.getString("slot_" + i); + Objective objective = scoreboard.getObjective(name); + scoreboard.setDisplayObjective(i, objective); + } + } + } + + protected void loadObjectives(ListTag list) { + for (int i = 0; i < list.size(); i++) { + CompoundTag tag = list.get(i); + + ObjectiveCriteria criteria = ObjectiveCriteria.CRITERIA_BY_NAME.get(tag.getString("CriteriaName")); + Objective objective = scoreboard.addObjective(tag.getString("Name"), criteria); + objective.setDisplayName(tag.getString("DisplayName")); + } + } + + protected void loadPlayerScores(ListTag list) { + for (int i = 0; i < list.size(); i++) { + CompoundTag tag = list.get(i); + + Objective objective = scoreboard.getObjective(tag.getString("Objective")); + Score score = scoreboard.getPlayerScore(tag.getString("Name"), objective); + score.setScore(tag.getInt("Score")); + } + } + + @Override + public void save(CompoundTag tag) { + if (scoreboard == null) { + MinecraftServer.getInstance().getLogger().warning("Tried to save scoreboard without having a scoreboard..."); + return; + } + + tag.put("Objectives", saveObjectives()); + tag.put("PlayerScores", savePlayerScores()); + tag.put("Teams", saveTeams()); + + saveDisplaySlots(tag); + } + + protected ListTag saveTeams() { + ListTag list = new ListTag(); + Collection teams = scoreboard.getPlayerTeams(); + + for (PlayerTeam team : teams) { + CompoundTag tag = new CompoundTag(); + + tag.putString("Name", team.getName()); + tag.putString("DisplayName", team.getDisplayName()); + tag.putString("Prefix", team.getPrefix()); + tag.putString("Suffix", team.getSuffix()); + tag.putBoolean("AllowFriendlyFire", team.isAllowFriendlyFire()); + tag.putBoolean("SeeFriendlyInvisibles", team.canSeeFriendlyInvisibles()); + + ListTag playerList = new ListTag(); + + for (String player : team.getPlayers()) { + playerList.add(new StringTag("", player)); + } + + tag.put("Players", playerList); + + list.add(tag); + } + + return list; + } + + protected void saveDisplaySlots(CompoundTag tag) { + CompoundTag slots = new CompoundTag(); + boolean hasDisplaySlot = false; + + for (int i = 0; i < Scoreboard.DISPLAY_SLOTS; i++) { + Objective objective = scoreboard.getDisplayObjective(i); + + if (objective != null) { + slots.putString("slot_" + i, objective.getName()); + hasDisplaySlot = true; + } + } + + if (hasDisplaySlot) tag.putCompound("DisplaySlots", slots); + } + + protected ListTag saveObjectives() { + ListTag list = new ListTag(); + Collection objectives = scoreboard.getObjectives(); + + for (Objective objective : objectives) { + CompoundTag tag = new CompoundTag(); + + tag.putString("Name", objective.getName()); + tag.putString("CriteriaName", objective.getCriteria().getName()); + tag.putString("DisplayName", objective.getDisplayName()); + + list.add(tag); + } + + return list; + } + + protected ListTag savePlayerScores() { + ListTag list = new ListTag(); + Collection scores = scoreboard.getScores(); + + for (Score score : scores) { + CompoundTag tag = new CompoundTag(); + + tag.putString("Name", score.getOwner()); + tag.putString("Objective", score.getObjective().getName()); + tag.putInt("Score", score.getScore()); + + list.add(tag); + } + + return list; + } +}; +#endif \ No newline at end of file -- cgit v1.2.3