aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <roman.graef@gmail.com>2023-03-04 02:54:50 +0100
committerGitHub <noreply@github.com>2023-03-04 12:54:50 +1100
commit5dd063fbba6bde64806a7620541dc2d9bdf42871 (patch)
tree01aee1a743a32a0b2546513c59a43559ce3085fe /src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java
parentdb86c98e0c72b18663ef26cd46cef7d53c1d6414 (diff)
downloadnotenoughupdates-5dd063fbba6bde64806a7620541dc2d9bdf42871.tar.gz
notenoughupdates-5dd063fbba6bde64806a7620541dc2d9bdf42871.tar.bz2
notenoughupdates-5dd063fbba6bde64806a7620541dc2d9bdf42871.zip
Replace all commands in NEU with a brigadier implementation (#599)
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java131
1 files changed, 0 insertions, 131 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java
deleted file mode 100644
index d52ed196..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
- *
- * This file is part of NotEnoughUpdates.
- *
- * NotEnoughUpdates is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation, either
- * version 3 of the License, or (at your option) any later version.
- *
- * NotEnoughUpdates is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package io.github.moulberry.notenoughupdates.commands.dungeon;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
-import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor;
-import io.github.moulberry.notenoughupdates.util.Utils;
-import net.minecraft.block.material.MapColor;
-import net.minecraft.client.Minecraft;
-import net.minecraft.command.CommandException;
-import net.minecraft.command.ICommandSender;
-import net.minecraft.item.ItemMap;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.world.storage.MapData;
-
-import java.awt.*;
-import java.io.File;
-import java.util.Map;
-
-public class MapCommand extends ClientCommandBase {
-
- public MapCommand() {
- super("neumap");
- }
-
- @Override
- public void processCommand(ICommandSender sender, String[] args) throws CommandException {
-
- if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null);
- return;
- }
-
- if (args.length == 1 && args[0].equals("reset")) {
- NotEnoughUpdates.INSTANCE.colourMap = null;
- return;
- }
-
- if (args.length != 2) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null);
- return;
- }
-
- if (args[0].equals("save")) {
- ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
- if (stack != null && stack.getItem() instanceof ItemMap) {
- ItemMap map = (ItemMap) stack.getItem();
- MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
-
- if (mapData == null) return;
-
- JsonObject json = new JsonObject();
- for (int i = 0; i < 16384; ++i) {
- int x = i % 128;
- int y = i / 128;
-
- int j = mapData.colors[i] & 255;
-
- Color c;
- if (j / 4 == 0) {
- c = new Color((i + i / 128 & 1) * 8 + 16 << 24, true);
- } else {
- c = new Color(MapColor.mapColorArray[j / 4].getMapColor(j & 3), true);
- }
-
- json.addProperty(x + ":" + y, c.getRGB());
- }
-
- try {
- new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "maps").mkdirs();
- NotEnoughUpdates.INSTANCE.manager.writeJson(
- json,
- new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "maps/" + args[1] + ".json")
- );
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- Utils.addChatMessage(EnumChatFormatting.GREEN + "Saved to file.");
- }
-
- return;
- }
-
- if (args[0].equals("load")) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(new File(
- NotEnoughUpdates.INSTANCE.manager.configLocation,
- "maps/" + args[1] + ".json"
- ));
-
- NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128];
- for (int x = 0; x < 128; x++) {
- for (int y = 0; y < 128; y++) {
- NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0);
- }
- }
- for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
- int x = Integer.parseInt(entry.getKey().split(":")[0]);
- int y = Integer.parseInt(entry.getKey().split(":")[1]);
-
- NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true);
- }
-
- return;
- }
-
- NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null);
- }
-}