diff --git a/build.gradle.kts b/build.gradle.kts index e9cc553..34d87c0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";") group = "tmb.randy" -version = providers.environmentVariable("VERSION").getOrElse("1.6.0") +version = providers.environmentVariable("VERSION").getOrElse("1.7.0") labyMod { defaultPackageName = "tmb.randy.tmbgriefergames" diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/Addon.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/Addon.java index 7a156ae..ef5e2df 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/Addon.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/Addon.java @@ -1,10 +1,18 @@ package tmb.randy.tmbgriefergames.core; +import java.util.Objects; import net.labymod.api.Laby; import net.labymod.api.addon.LabyAddon; import net.labymod.api.client.gui.hud.binding.category.HudWidgetCategory; import net.labymod.api.client.gui.screen.activity.types.IngameOverlayActivity; +import net.labymod.api.event.Subscribe; +import net.labymod.api.event.client.chat.ChatReceiveEvent; +import net.labymod.api.event.client.input.KeyEvent; +import net.labymod.api.event.client.input.KeyEvent.State; +import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.models.addon.annotation.AddonMain; +import tmb.randy.tmbgriefergames.core.activities.plotwheel.PlotWheelActivity; +import tmb.randy.tmbgriefergames.core.activities.plotwheel.PlotWheelPlot; import tmb.randy.tmbgriefergames.core.commands.AutocraftV2Command; import tmb.randy.tmbgriefergames.core.commands.AutocraftV3Command; import tmb.randy.tmbgriefergames.core.commands.DKsCommand; @@ -12,6 +20,8 @@ import tmb.randy.tmbgriefergames.core.commands.PayAllCommand; import tmb.randy.tmbgriefergames.core.commands.PlayerTracerCommand; import tmb.randy.tmbgriefergames.core.config.Configuration; +import tmb.randy.tmbgriefergames.core.enums.CBs; +import tmb.randy.tmbgriefergames.core.events.CbChangedEvent; import tmb.randy.tmbgriefergames.core.generated.DefaultReferenceStorage; import tmb.randy.tmbgriefergames.core.util.AccountUnity; import tmb.randy.tmbgriefergames.core.util.HopperTracker; @@ -32,7 +42,6 @@ import tmb.randy.tmbgriefergames.core.widgets.HopperModeWidget; import tmb.randy.tmbgriefergames.core.widgets.ItemClearWidget; import tmb.randy.tmbgriefergames.core.widgets.NearbyWidget; -import java.util.Objects; @AddonMain public class Addon extends LabyAddon { @@ -40,7 +49,7 @@ public class Addon extends LabyAddon { private IBridge bridge; private static Addon SharedInstance; private GameInfoWidget gameInfoWidget; - private final CBtracker CBtracker = new CBtracker(); + private final CBtracker cbtracker = new CBtracker(); private final PlayerTracer playerTracer = new PlayerTracer(); private final HopperTracker hopperTracker = new HopperTracker(); private final PlotSwitch plotSwitch = new PlotSwitch(); @@ -57,15 +66,17 @@ public class Addon extends LabyAddon { private final AccountUnity accountUnity = new AccountUnity(); private final ItemClearTimerListener itemClearTimerListener = new ItemClearTimerListener(); - private final String ADDON_PREFIX = "§6[§5§l§oT§b§l§oM§5§l§oB§6] "; + private static final int commandCountdownLimit = 80; + private static int commandCountdown = 0; + public static PlotWheelPlot queuedPlot = null; - @Override + @Override protected void enable() { this.registerSettingCategory(); SharedInstance = this; bridge = getReferenceStorage().iBridge(); this.registerListener(bridge); - this.registerListener(CBtracker); + this.registerListener(cbtracker); this.registerListener(playerTracer); this.registerListener(chatCleaner); this.registerListener(cooldownNotifier); @@ -80,6 +91,7 @@ protected void enable() { this.registerListener(itemSaver); this.registerListener(accountUnity); this.registerListener(itemClearTimerListener); + this.registerListener(this); this.registerCommand(new DKsCommand()); this.registerCommand(new PayAllCommand()); @@ -99,6 +111,9 @@ protected void enable() { labyAPI().hudWidgetRegistry().register(new NearbyWidget(category)); labyAPI().hudWidgetRegistry().register(new HopperModeWidget(category)); + //PlotWheelActivity activity = new PlotWheelActivity(); + //labyAPI().navigationService().register(new PlotWheelNavigationElement(activity)); + this.logger().info("Enabled the Addon"); } @@ -108,6 +123,7 @@ protected Class configurationClass() { } public void displayNotification(String msg) { + String ADDON_PREFIX = "§6[§5§l§oT§b§l§oM§5§l§oB§6] "; Laby.labyAPI().minecraft().chatExecutor().displayClientMessage(ADDON_PREFIX + msg); } @@ -146,5 +162,57 @@ public static boolean isChatGuiOpen() { public PlayerTracer getPlayerTracer() {return playerTracer;} + @Subscribe + public void keyInput(KeyEvent event) { + if(event.state() == State.PRESS && event.key() == configuration().getPlotWheelHotkey().get() && !isChatGuiOpen() && CBtracker.isCommandAbleCB()) { + Laby.labyAPI().minecraft().minecraftWindow().displayScreen(new PlotWheelActivity()); + } + } + + @Subscribe + public void tick(GameTickEvent event) { + commandCountdown(); + } + + @Subscribe + public void cbChanged(CbChangedEvent event) { + if(event.CB() == CBs.LOBBY && Addon.getSharedInstance().configuration().getSkipHub().get()) + Addon.sendCommand("/portal"); + } + + @Subscribe + public void messageReceived(ChatReceiveEvent event) { + if(event.chatMessage().getPlainText().equals("[Switcher] Daten heruntergeladen!")) { + if(queuedPlot != null) { + if(CBtracker.isPlotworldCB(CBtracker.getCurrentCB())) { + new java.util.Timer().schedule( + new java.util.TimerTask() { + @Override + public void run() { + if(isGG() && (queuedPlot.cb() == CBs.NONE || CBtracker.getCurrentCB() == queuedPlot.cb())) { + Laby.references().chatExecutor().chat(queuedPlot.command()); + queuedPlot = null; + } + } + }, 500 + ); + } + } + } + } + + public static boolean canSendCommand() { return commandCountdown <= 0; } + public static void sendCommand(String command) { + if(canSendCommand()) { + Laby.references().chatExecutor().chat(command); + commandCountdown = commandCountdownLimit; + } + } + + private static void commandCountdown() { + if (commandCountdown > 0) { + commandCountdown--; + } + } } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/CBtracker.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/CBtracker.java index 0644f67..eb61f27 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/CBtracker.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/CBtracker.java @@ -18,26 +18,27 @@ public class CBtracker { public void worldEnterEvent(ScoreboardTeamUpdateEvent event) { if(!Addon.isGG()) return; Scoreboard scoreboard = Laby.labyAPI().minecraft().getScoreboard(); - for (ScoreboardTeam team : scoreboard.getTeams()) { - if(team.getTeamName().equals("server_value")) { - String CBString = ((TextComponent)team.getPrefix()).getText(); + if(scoreboard != null) { + for (ScoreboardTeam team : scoreboard.getTeams()) { + if(team.getTeamName().equals("server_value")) { + String CBString = ((TextComponent)team.getPrefix()).getText(); - CBs newCB = CBs.NONE; + CBs newCB = CBs.NONE; - try { - newCB = CBs.valueOf(CBString.toUpperCase()); - } catch (IllegalArgumentException e) { - Addon.getSharedInstance().logger().warn(e.getMessage()); - } + try { + newCB = CBs.valueOf(CBString.toUpperCase()); + } catch (IllegalArgumentException e) { + Addon.getSharedInstance().logger().warn(e.getMessage()); + } - if(newCB != currentCB) { - currentCB = newCB; - Addon.getSharedInstance().logger().info("Joined CityBuild " + newCB.getName()); - Laby.fireEvent(new CbChangedEvent(newCB)); + if(newCB != currentCB) { + currentCB = newCB; + Addon.getSharedInstance().logger().info("Joined " + newCB.getName()); + Laby.fireEvent(new CbChangedEvent(newCB)); + } } } } - } public static CBs getCurrentCB() {return currentCB;} @@ -48,10 +49,17 @@ public static boolean isPlotworldCB() { default -> true; }; } - public static boolean canSendPayment() { + public static boolean isCommandAbleCB() { return switch (currentCB) { case PORTAL, LOBBY, NONE -> false; default -> true; }; } + + public static boolean isPlotworldCB(CBs cb) { + return switch (cb) { + case WASSER, LAVA, PORTAL, LOBBY, NONE -> false; + default -> true; + }; + } } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/FileManager.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/FileManager.java index 045e98a..d3853e0 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/FileManager.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/FileManager.java @@ -4,18 +4,24 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import net.labymod.api.Laby; +import tmb.randy.tmbgriefergames.core.activities.plotwheel.PlotWheelPlot; +import tmb.randy.tmbgriefergames.core.enums.CBs; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.UUID; public class FileManager { private static final File storageFile = new File(new File(Laby.labyAPI().labyModLoader().getGameDirectory().toFile(), "labymod-neo/configs/tmbgriefergames"), "tmbgriefergames.json"); private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); + private static Map globalData = new HashMap<>(); private static Map> playerData = new HashMap<>(); static { @@ -24,18 +30,27 @@ public class FileManager { private static void saveData() { try { - if (!storageFile.getParentFile().exists()) { + if (!storageFile.getParentFile().exists()) storageFile.getParentFile().mkdirs(); - } - if (!storageFile.exists()) { + + if (!storageFile.exists()) storageFile.createNewFile(); + + + Map allData = new HashMap<>(); + Map> playerDataAsStringKeys = new HashMap<>(); + for (Map.Entry> entry : playerData.entrySet()) { + playerDataAsStringKeys.put(entry.getKey().toString(), entry.getValue()); } + allData.put("global", globalData); + allData.put("player", playerDataAsStringKeys); + try (FileWriter writer = new FileWriter(storageFile)) { - gson.toJson(playerData, writer); + gson.toJson(allData, writer); } } catch (IOException e) { - e.printStackTrace(); + Addon.getSharedInstance().logger().error("FileManager", e); } } @@ -45,28 +60,84 @@ private static void loadData() { } try (FileReader reader = new FileReader(storageFile)) { - Type type = new TypeToken>>() {}.getType(); - playerData = gson.fromJson(reader, type); - if (playerData == null) { + Type type = new TypeToken>() {}.getType(); + Map allData = gson.fromJson(reader, type); + + if (allData != null) { + globalData = (Map) allData.getOrDefault("global", new HashMap<>()); + + Map> rawPlayerData = (Map>) allData.getOrDefault("player", new HashMap<>()); + playerData = new HashMap<>(); + for (Map.Entry> entry : rawPlayerData.entrySet()) { + UUID playerUUID = UUID.fromString(entry.getKey()); + playerData.put(playerUUID, entry.getValue()); + } + } else { + globalData = new HashMap<>(); playerData = new HashMap<>(); } } catch (IOException e) { - e.printStackTrace(); + Addon.getSharedInstance().logger().error("FileManager", e); + } catch (ClassCastException e) { + Addon.getSharedInstance().logger().error("FileManager - Invalid format", e); + } + } + + public static void setGlobalValue(String key, Object value) { + globalData.put(key, value); + saveData(); + } + + public static Object getGlobalValue(String key) { + return globalData.get(key); + } + + public static void addPlot(PlotWheelPlot plot) { + List plots = loadPlots(); + plots.add(plot); + setGlobalValue("PlotWheel", plots); + } + + public static ArrayList loadPlots() { + Object value = getGlobalValue("PlotWheel"); + ArrayList plots = new ArrayList<>(); + + if (value instanceof List) { + Gson gson = new Gson(); + Type listType = new TypeToken>>() {}.getType(); + List> plotDataList = gson.fromJson(gson.toJson(value), listType); + + for (Map plotData : plotDataList) { + CBs cb = CBs.valueOf((String) plotData.get("cb")); + String name = (String) plotData.get("name"); + String command = (String) plotData.get("command"); + UUID account = plotData.get("account") != null ? UUID.fromString((String) plotData.get("account")) : null; + + plots.add(new PlotWheelPlot(cb, name, command, account)); + } } + + return plots; + } + + public static void deletePlot(PlotWheelPlot plot) { + List plots = loadPlots(); + plots.removeIf(plott -> plott.toString().equals(plot.toString())); + setGlobalValue("PlotWheel", plots); } - public static void setValue(String key, Object value) { - if(Laby.labyAPI().minecraft().getClientPlayer() != null) { - UUID playerUUID = Laby.labyAPI().minecraft().getClientPlayer().profile().getUniqueId(); + public static void setPlayerValue(String key, Object value) { + if (Laby.labyAPI().minecraft().getClientPlayer() != null) { + UUID playerUUID = Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).profile().getUniqueId(); Map values = playerData.computeIfAbsent(playerUUID, k -> new HashMap<>()); values.put(key, value); saveData(); } } - public static Object getValue(String key) { - if(Laby.labyAPI().minecraft().getClientPlayer() != null) { - UUID playerUUID = Laby.labyAPI().minecraft().getClientPlayer().profile().getUniqueId(); + public static Object getPlayerValue(String key) { + if (Laby.labyAPI().minecraft().getClientPlayer() != null) { + UUID playerUUID = Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).profile().getUniqueId(); Map values = playerData.get(playerUUID); return values != null ? values.get(key) : null; } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/IBridge.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/IBridge.java index dc57e4f..99805b9 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/IBridge.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/IBridge.java @@ -13,7 +13,7 @@ public interface IBridge { void startAuswurf(); void startAutocrafterV3(); void openChat(); - boolean isChatGuiOpen(); + boolean isChatGuiClosed(); void resetLines(); boolean allKeysPressed(Key[] keys); } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/CBwheel.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/CBwheel.java new file mode 100644 index 0000000..e3c0c48 --- /dev/null +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/CBwheel.java @@ -0,0 +1,65 @@ +package tmb.randy.tmbgriefergames.core.activities.plotwheel; + +import net.labymod.api.Laby; +import net.labymod.api.client.gui.lss.property.annotation.AutoWidget; +import net.labymod.api.client.gui.screen.Parent; +import net.labymod.api.client.gui.screen.activity.Link; +import net.labymod.api.client.gui.screen.widget.widgets.ComponentWidget; +import net.labymod.api.client.gui.screen.widget.widgets.WheelWidget; +import tmb.randy.tmbgriefergames.core.CBtracker; +import tmb.randy.tmbgriefergames.core.enums.CBs; + +@AutoWidget +@Link("cbwheel.lss") +public class CBwheel extends WheelWidget { + + public void initialize(Parent parent) { + this.refresh(); + super.initialize(parent); + } + + public void refresh() { + this.removeChildIf((widget) -> widget instanceof Segment); + + for (int i = CBs.values().length - 1; i >= 0; i--) { + CBs cb = CBs.values()[i]; + + if(cb == CBs.EVENT) + continue; + + if(!CBtracker.isPlotworldCB(cb)) continue; + + CBsegment segment = new CBsegment(cb); + segment.addId("segment-" + cb, "cb-segment"); + + this.addSegment(segment); + + + if(CBtracker.getCurrentCB() == cb) + segment.setSelected(true); + } + } + + public static class CBsegment extends Segment { + private final CBs cb; + + public CBsegment(CBs cb) { + this.cb = cb; + ComponentWidget display = ComponentWidget.text(cb.getName()); + + display.addId("cb-segment-display"); + this.addChild(display); + + this.setPressable(() -> { + if(cb != CBtracker.getCurrentCB()) { + Laby.references().chatExecutor().chat("/switch " + cb); + } + }); + } + + public CBs getCb() { + return cb; + } + } +} + diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/ISelectableCB.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/ISelectableCB.java new file mode 100644 index 0000000..7b47a4f --- /dev/null +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/ISelectableCB.java @@ -0,0 +1,7 @@ +package tmb.randy.tmbgriefergames.core.activities.plotwheel; + +import tmb.randy.tmbgriefergames.core.enums.CBs; + +public interface ISelectableCB { + void setSelectedCB(CBs cb); +} diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/PlotWheel.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/PlotWheel.java new file mode 100644 index 0000000..ec8e8bf --- /dev/null +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/PlotWheel.java @@ -0,0 +1,113 @@ +package tmb.randy.tmbgriefergames.core.activities.plotwheel; + +import net.labymod.api.Laby; +import net.labymod.api.client.component.Component; +import net.labymod.api.client.gui.lss.property.annotation.AutoWidget; +import net.labymod.api.client.gui.screen.Parent; +import net.labymod.api.client.gui.screen.activity.Link; +import net.labymod.api.client.gui.screen.key.MouseButton; +import net.labymod.api.client.gui.screen.widget.context.ContextMenu; +import net.labymod.api.client.gui.screen.widget.context.ContextMenuEntry; +import net.labymod.api.client.gui.screen.widget.widgets.ComponentWidget; +import net.labymod.api.client.gui.screen.widget.widgets.WheelWidget; +import net.labymod.api.util.Color; +import tmb.randy.tmbgriefergames.core.Addon; +import tmb.randy.tmbgriefergames.core.CBtracker; +import tmb.randy.tmbgriefergames.core.FileManager; +import tmb.randy.tmbgriefergames.core.enums.CBs; +import java.util.ArrayList; + +@AutoWidget +@Link("plotwheel.lss") +public class PlotWheel extends WheelWidget { + private ArrayList plots = new ArrayList<>(); + private static CBs selectedCB; + + public void initialize(Parent parent) { + super.initialize(parent); + this.refresh(); + } + + public void refresh() { + this.removeChildIf((widget) -> widget instanceof Segment); + + //Add placeholder segments to guarantee al least 25 segments. + if(plots.size() < 25) { + for (int i = plots.size(); i < 25; i++) { + this.addSegment(new Segment()); + } + } + + for (int i = plots.size() - 1; i >= 0; i--) { + PlotWheelPlot plot = plots.get(i); + PlotSegment segment = new PlotSegment(plot, this); + segment.addId("plot-segment"); + + this.addSegment(segment); + } + } + + public static class PlotSegment extends Segment { + private final PlotWheelPlot plot; + + public PlotSegment(PlotWheelPlot plot, PlotWheel plotWheel) { + this.plot = plot; + ComponentWidget display = ComponentWidget.text(plot.name() == null ? plot.command() : plot.name()); + + if (plot.command().toLowerCase().startsWith("/p h ")) { + display.textColor().set(Color.ORANGE.getValue()); + } else if(plot.command().toLowerCase().startsWith("/home ")) { + display.textColor().set(Color.YELLOW.getValue()); + } else if(plot.command().toLowerCase().startsWith("/warp ")) { + display.textColor().set(Color.RED.getValue()); + } else { + display.textColor().set(Color.PINK.getValue()); + } + + display.addId("plot-segment-display"); + this.addChild(display); + + ContextMenu contextMenu = new ContextMenu(); + contextMenu.addEntry(ContextMenuEntry.builder().text(Component.translatable("tmbgriefergames.plotWheel.delete")).clickHandler(contextMenuEntry -> { + FileManager.deletePlot(plot); + plotWheel.loadPlots(plot.cb()); + return true; + }).build()); + this.setContextMenu(contextMenu); + + this.setPressable(() -> { + if(Laby.labyAPI().minecraft().isMouseDown(MouseButton.LEFT)) { + if(CBtracker.isPlotworldCB()) { + if(selectedCB == CBtracker.getCurrentCB()) { + Laby.references().chatExecutor().chat(plot.command()); + } else { + Addon.queuedPlot = plot; + Laby.references().chatExecutor().chat("/switch " + selectedCB); + } + } + } else if(Laby.labyAPI().minecraft().isMouseDown(MouseButton.RIGHT)) { + this.openContextMenu(); + } + }); + } + + public PlotWheelPlot getPlot() { + return plot; + } + } + + public void loadPlots(CBs cb) { + selectedCB = cb; + ArrayList allPlots = FileManager.loadPlots(); + ArrayList filteredPlots = new ArrayList<>(); + + for (PlotWheelPlot plot : allPlots) { + if(plot.cb() == cb || plot.cb() == CBs.NONE) + if(plot.account() == null || plot.account().equals(Laby.labyAPI().getUniqueId())) + filteredPlots.add(plot); + } + + plots = filteredPlots; + this.reInitialize(); + } +} \ No newline at end of file diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/PlotWheelActivity.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/PlotWheelActivity.java new file mode 100644 index 0000000..afd9eb1 --- /dev/null +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/PlotWheelActivity.java @@ -0,0 +1,206 @@ +package tmb.randy.tmbgriefergames.core.activities.plotwheel; + +import net.labymod.api.Laby; +import net.labymod.api.client.component.Component; +import net.labymod.api.client.gui.screen.Parent; +import net.labymod.api.client.gui.screen.activity.AutoActivity; +import net.labymod.api.client.gui.screen.activity.Link; +import net.labymod.api.client.gui.screen.activity.types.SimpleActivity; +import net.labymod.api.client.gui.screen.widget.AbstractWidget; +import net.labymod.api.client.gui.screen.widget.Widget; +import net.labymod.api.client.gui.screen.widget.widgets.ComponentWidget; +import net.labymod.api.client.gui.screen.widget.widgets.input.ButtonWidget; +import net.labymod.api.client.gui.screen.widget.widgets.input.CheckBoxWidget; +import net.labymod.api.client.gui.screen.widget.widgets.input.TextFieldWidget; +import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget; +import net.labymod.api.client.gui.screen.widget.widgets.layout.entry.HorizontalListEntry; +import net.labymod.api.client.gui.screen.widget.widgets.layout.list.HorizontalListWidget; +import net.labymod.api.client.gui.screen.widget.widgets.layout.list.VerticalListWidget; +import net.labymod.api.event.Subscribe; +import net.labymod.api.event.client.lifecycle.GameTickEvent; +import net.labymod.api.util.Color; +import net.labymod.api.util.I18n; +import tmb.randy.tmbgriefergames.core.CBtracker; +import tmb.randy.tmbgriefergames.core.FileManager; +import tmb.randy.tmbgriefergames.core.activities.plotwheel.CBwheel.CBsegment; +import tmb.randy.tmbgriefergames.core.activities.plotwheel.PlotWheel.PlotSegment; +import tmb.randy.tmbgriefergames.core.enums.CBs; +import java.util.UUID; + +@AutoActivity +@Link("plotwheelactivity.lss") +public class PlotWheelActivity extends SimpleActivity implements ISelectableCB { + PlotWheel plotWheel = new PlotWheel(); + CBwheel cbWheel = new CBwheel(); + CBs selectedCB = CBs.NONE; + ComponentWidget cbDisplay = ComponentWidget.text("CB"); + ComponentWidget plotDisplay = ComponentWidget.text("Plot"); + TextFieldWidget addNameTextField; + TextFieldWidget addCommandTextField; + CheckBoxWidget accountOnlyWidget; + DropdownWidget cbDropdownWidget; + + @Override + public void initialize(Parent parent) { + super.initialize(parent); + cbWheel.initialize(parent); + + cbDisplay.addId("cb-display"); + plotDisplay.addId("plot-display"); + + cbWheel.addId("cb-wheel"); + this.document().addChild(cbWheel); + + plotWheel.initialize(parent); + plotWheel.addId("plot-wheel"); + this.document().addChild(plotWheel); + + VerticalListWidget centerList = new VerticalListWidget<>(); + centerList.addId("center-container"); + + centerList.addChild(cbDisplay); + centerList.addChild(plotDisplay); + + this.document.addChild(centerList); + + ///////////////////////// + + VerticalListWidget addContainer = new VerticalListWidget<>().addId("add-container"); + + HorizontalListWidget addPlotTitle = new HorizontalListWidget().addId("title-list"); + HorizontalListEntry addPlotEntry = new HorizontalListEntry(ComponentWidget.i18n("tmbgriefergames.plotWheel.addPlot")); + addPlotTitle.addChild(addPlotEntry); + addContainer.addChild(addPlotTitle); + addContainer.addChild(addPlotTitle); + + ////////////// + + HorizontalListWidget plotNameList = new HorizontalListWidget(); + HorizontalListEntry plotNameListTag = new HorizontalListEntry(ComponentWidget.i18n("tmbgriefergames.plotWheel.name").addId("label")); + addNameTextField = new TextFieldWidget().placeholder(Component.translatable("tmbgriefergames.plotWheel.optional")).addId("name-textfield"); + HorizontalListEntry plotNameListTextfield = new HorizontalListEntry(addNameTextField); + plotNameList.addChild(plotNameListTag); + plotNameList.addChild(plotNameListTextfield); + addContainer.addChild(plotNameList); + + ////////////// + + HorizontalListWidget CBlist = new HorizontalListWidget(); + cbDropdownWidget = new DropdownWidget<>().addId("cb-dropdown"); + HorizontalListEntry cbListTag = new HorizontalListEntry(ComponentWidget.i18n("tmbgriefergames.plotWheel.cb").addId("label")); + + cbDropdownWidget.add(I18n.translate("tmbgriefergames.plotWheel.all")); + for (CBs cb : CBs.values()) { + if(CBtracker.isPlotworldCB(cb) && cb != CBs.EVENT) { + cbDropdownWidget.add(cb.getName()); + } + } + + if(CBtracker.isPlotworldCB()) + cbDropdownWidget.setSelected(CBtracker.getCurrentCB().getName()); + + + HorizontalListEntry CBlistEntry = new HorizontalListEntry(cbDropdownWidget); + CBlist.addChild(cbListTag); + CBlist.addChild(CBlistEntry); + addContainer.addChild(CBlist); + + ////////////// + + HorizontalListWidget commandList = new HorizontalListWidget(); + HorizontalListEntry commandListTag = new HorizontalListEntry(ComponentWidget.i18n("tmbgriefergames.plotWheel.command").addId("label")); + addCommandTextField = new TextFieldWidget().placeholder(Component.text("/p h Farm")).addId("command-textfield"); + HorizontalListEntry commandListTextfield = new HorizontalListEntry(addCommandTextField); + commandList.addChild(commandListTag); + commandList.addChild(commandListTextfield); + addContainer.addChild(commandList); + + ////////////// + + HorizontalListWidget accountList = new HorizontalListWidget(); + HorizontalListEntry accountListTag = new HorizontalListEntry(ComponentWidget.i18n("tmbgriefergames.plotWheel.thisAccountOnly")); + accountOnlyWidget = new CheckBoxWidget(); + HorizontalListEntry accountListCheckbox = new HorizontalListEntry(accountOnlyWidget); + accountList.addChild(accountListTag); + accountList.addChild(accountListCheckbox); + addContainer.addChild(accountList); + + ////////////// + + HorizontalListWidget addPlotButtonList = new HorizontalListWidget(); + ButtonWidget addButton = ButtonWidget.i18n("tmbgriefergames.plotWheel.add"); + addButton.setPressable(() -> { + if(!addCommandTextField.getText().trim().isEmpty()) { + String plotName = addNameTextField.getText().trim().isEmpty() ? null : addNameTextField.getText().trim(); + CBs selectedCB = (cbDropdownWidget.getSelected() == null ? I18n.translate("tmbgriefergames.plotWheel.all") : cbDropdownWidget.getSelected()).equals(I18n.translate("tmbgriefergames.plotWheel.all")) ? CBs.NONE : CBs.valueOf(cbDropdownWidget.getSelected()); + UUID uuid = accountOnlyWidget.state() == CheckBoxWidget.State.CHECKED ? Laby.labyAPI().getUniqueId() : null; + String command = addCommandTextField.getText().trim(); + + PlotWheelPlot plot = new PlotWheelPlot(selectedCB, plotName, command, uuid); + FileManager.addPlot(plot); + + resetAddWidgets(); + plotWheel.loadPlots(this.selectedCB); + } + }); + + HorizontalListEntry addPlotButtonEntry = new HorizontalListEntry(addButton); + addPlotButtonList.addChild(addPlotButtonEntry); + addContainer.addChild(addPlotButtonList); + + ////////////// + + document.addChild(addContainer); + } + + @Override + public void onOpenScreen() { + super.onOpenScreen(); + setSelectedCB(CBtracker.getCurrentCB()); + } + + @Override + public void setSelectedCB(CBs cb) { + if(isOpen() && cbDisplay != null) { + selectedCB = cb; + cbDisplay.setText(cb.getName()); + cbDisplay.textColor().set(CBtracker.getCurrentCB() == cb ? Color.GREEN.get() : Color.ORANGE.get()); + plotWheel.loadPlots(cb); + } + } + + @Subscribe + public void tick(GameTickEvent event) { + if(isOpen()) { + for (AbstractWidget child : cbWheel.getChildren()) { + if(child instanceof CBsegment segment) { + if(segment.isSegmentSelected()) { + if(segment.getCb() != selectedCB) { + setSelectedCB(segment.getCb()); + } + break; + } + } + } + + for (AbstractWidget child : plotWheel.getChildren()) { + if(child instanceof PlotSegment segment) { + if(segment.isSegmentSelected()) { + plotDisplay.setText(segment.getPlot().command()); + return; + } + } + } + + if(plotDisplay != null) + plotDisplay.setText(""); + } + } + + private void resetAddWidgets() { + addCommandTextField.setText(""); + addNameTextField.setText(""); + accountOnlyWidget.setState(CheckBoxWidget.State.UNCHECKED); + cbDropdownWidget.setSelected(CBtracker.getCurrentCB().getName()); + } +} \ No newline at end of file diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/PlotWheelPlot.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/PlotWheelPlot.java new file mode 100644 index 0000000..df6013b --- /dev/null +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/activities/plotwheel/PlotWheelPlot.java @@ -0,0 +1,12 @@ +package tmb.randy.tmbgriefergames.core.activities.plotwheel; + +import tmb.randy.tmbgriefergames.core.enums.CBs; +import java.util.UUID; + +public record PlotWheelPlot(CBs cb, String name, String command, UUID account) { + + @Override + public String toString() { + return cb.getName() + ";" + name + ";" + command + ";" + account; + } +} diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/config/AutoCrafterSubConfig.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/config/AutoCrafterSubConfig.java index 33a422a..3e46c43 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/config/AutoCrafterSubConfig.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/config/AutoCrafterSubConfig.java @@ -4,6 +4,7 @@ import net.labymod.api.client.gui.screen.widget.widgets.input.MultiKeybindWidget.MultiKeyBindSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; +import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget.DropdownEntryTranslationPrefix; import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget.DropdownSetting; import net.labymod.api.configuration.loader.Config; import net.labymod.api.configuration.loader.property.ConfigProperty; @@ -15,6 +16,7 @@ public class AutoCrafterSubConfig extends Config { @SettingSection("v1") + @DropdownEntryTranslationPrefix("tmbgriefergames.settings.autoCrafterConfig.autoCraftSpeed.entries") @DropdownSetting private final ConfigProperty autoCraftSpeed = new ConfigProperty<>(QueueType.FAST); @@ -29,16 +31,18 @@ public class AutoCrafterSubConfig extends Config { @SettingSection("v2") + @DropdownEntryTranslationPrefix("tmbgriefergames.settings.autoCrafterConfig.finalActionV2.entries") @DropdownSetting private final ConfigProperty finalActionV2 = new ConfigProperty<>(AutoCrafterNewFinalAction.COMP); @SettingSection("v3") + @DropdownEntryTranslationPrefix("tmbgriefergames.settings.autoCrafterConfig.finalActionV3.entries") @DropdownSetting private final ConfigProperty finalActionV3 = new ConfigProperty<>(AutoCrafterNewFinalAction.COMP); @SliderSetting(min = 0, max = 80) - private final ConfigProperty delay = new ConfigProperty(0); + private final ConfigProperty delay = new ConfigProperty<>(0); @SettingSection("autocomp") diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/config/ChatSubConfig.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/config/ChatSubConfig.java index 974f2e9..19eb1c0 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/config/ChatSubConfig.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/config/ChatSubConfig.java @@ -39,6 +39,14 @@ public class ChatSubConfig extends Config { @SpriteSlot(size = 21, x = 1, y = 2) private final ConfigProperty muteStreamer = new ConfigProperty<>(false); + @SwitchSetting + @SpriteSlot(size = 21, x = 4, y = 3) + private final ConfigProperty muteCaseOpening = new ConfigProperty<>(false); + + @SwitchSetting + @SpriteSlot(size = 21, x = 5, y = 3) + private final ConfigProperty muteLuckyBlocks = new ConfigProperty<>(false); + @SpriteSlot(size = 21, y = 3) @SwitchSetting private final ConfigProperty msgTabMode = new ConfigProperty<>(true); @@ -59,5 +67,7 @@ public ConfigProperty getHideNews() { public ConfigProperty getCleanChat() {return this.cleanChat;} public ConfigProperty getHideEmptyLines() {return this.hideEmptyLines;} public ConfigProperty getMuteStreamer() {return this.muteStreamer;} + public ConfigProperty getMuteCaseOpening() {return muteCaseOpening;} + public ConfigProperty getMuteLuckyBlocks() {return muteLuckyBlocks;} public ConfigProperty getMsgTabMode() {return msgTabMode;} } \ No newline at end of file diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/config/Configuration.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/config/Configuration.java index 42e2808..987e7bc 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/config/Configuration.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/config/Configuration.java @@ -2,6 +2,7 @@ import net.labymod.api.addon.AddonConfig; import net.labymod.api.client.gui.screen.key.Key; +import net.labymod.api.client.gui.screen.widget.widgets.input.KeybindWidget.KeyBindSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.MultiKeybindWidget.MultiKeyBindSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; import net.labymod.api.configuration.loader.annotation.ConfigName; @@ -39,18 +40,18 @@ public Configuration() { @SpriteSlot(size = SPRITE_SIZE, x = 1) private final ChatSubConfig chatConfig; - @SpriteSlot(size = SPRITE_SIZE, x = 3, y = 2) - private final NatureSubConfig natureSubConfig; - @SpriteSlot(size = SPRITE_SIZE, x = 3, y = 1) private final TooltipSubConfig tooltipConfig; - @SpriteSlot(size = SPRITE_SIZE, x = 2, y = 2) - private final HopperSubConfig hopperSubConfig; - @SpriteSlot(size = SPRITE_SIZE, x = 1, y = 3) private final SwordsSubConfig swordsSubConfig; + @SpriteSlot(size = SPRITE_SIZE, x = 3, y = 2) + private final NatureSubConfig natureSubConfig; + + @SpriteSlot(size = SPRITE_SIZE, x = 2, y = 2) + private final HopperSubConfig hopperSubConfig; + @SwitchSetting @SpriteSlot(size = SPRITE_SIZE, x = 4, y = 2) private final ConfigProperty skipHub = new ConfigProperty<>(true); @@ -61,6 +62,10 @@ public Configuration() { @SettingSection("plotSwitch") + @SpriteSlot(size = SPRITE_SIZE, x = 3, y = 3) + @KeyBindSetting + private final ConfigProperty plotWheelHotkey = new ConfigProperty<>(Key.GRAVE); + @MultiKeyBindSetting private final ConfigProperty nextPlot = new ConfigProperty<>(new Key[]{Key.L_SHIFT, Key.ARROW_RIGHT}); @MultiKeyBindSetting @@ -77,12 +82,13 @@ public ConfigProperty getItemProtection() { } public ChatSubConfig getChatConfig() {return this.chatConfig; } public TooltipSubConfig getTooltipConfig() {return this.tooltipConfig; } - public ConfigProperty getNextPlot() {return nextPlot;} - public ConfigProperty getPreviousPlot() {return previousPlot;} public ConfigProperty getSkipHub() {return skipHub;} public HopperSubConfig getHopperSubConfig() {return hopperSubConfig;} public NatureSubConfig getNatureSubConfig() {return natureSubConfig;} public AutoCrafterSubConfig getAutoCrafterConfig() {return autoCrafterConfig;} public SwordsSubConfig getSwordsSubConfig() {return swordsSubConfig;} public ConfigProperty getAutoLoot() {return autoLoot;} + public ConfigProperty getPlotWheelHotkey() {return plotWheelHotkey;} + public ConfigProperty getNextPlot() {return nextPlot;} + public ConfigProperty getPreviousPlot() {return previousPlot;} } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/config/HopperSubConfig.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/config/HopperSubConfig.java index 11dc383..84bf82f 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/config/HopperSubConfig.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/config/HopperSubConfig.java @@ -3,6 +3,7 @@ import net.labymod.api.client.gui.screen.widget.widgets.input.ButtonWidget.ButtonSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; +import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget.DropdownEntryTranslationPrefix; import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget.DropdownSetting; import net.labymod.api.configuration.loader.Config; import net.labymod.api.configuration.loader.annotation.ShowSettingInParent; @@ -24,8 +25,10 @@ public class HopperSubConfig extends Config { private final ConfigProperty filterItem = new ConfigProperty<>(false); @SliderSetting(min = -1, max = 15, steps = 1) private final ConfigProperty radius = new ConfigProperty<>(-1); + @DropdownEntryTranslationPrefix("tmbgriefergames.settings.hopperSubConfig.stackSize.entries") @DropdownSetting private final ConfigProperty stackSize = new ConfigProperty<>(HopperItemStackSizeEnum.NONE); + @DropdownEntryTranslationPrefix("tmbgriefergames.settings.hopperSubConfig.finalAction.entries") @DropdownSetting private final ConfigProperty finalAction = new ConfigProperty<>(HopperFinalAction.NONE); @SwitchSetting diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/CBs.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/CBs.java index 34713e9..68b7b0b 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/CBs.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/CBs.java @@ -3,9 +3,6 @@ public enum CBs { LOBBY("LOBBY"), PORTAL("PORTAL"), - EXTREME("EXTREME"), - CBE("CBE"), - NATURE("NATURE"), CB1("CB1"), CB2("CB2"), CB3("CB3"), @@ -28,6 +25,9 @@ public enum CBs { CB20("CB20"), CB21("CB21"), CB22("CB22"), + NATURE("NATURE"), + EXTREME("EXTREME"), + CBE("CBE"), LAVA("LAVA"), WASSER("WASSER"), EVENT("EVENT"), diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperFinalAction.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperFinalAction.java index 501c5e7..52ad83a 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperFinalAction.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperFinalAction.java @@ -1,5 +1,5 @@ package tmb.randy.tmbgriefergames.core.enums; public enum HopperFinalAction { - NONE , CLOSE, CONNECT, MULTI_CONNECTION; + NONE , CLOSE, CONNECT, MULTICONNECTION } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperItemStackSizeEnum.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperItemStackSizeEnum.java index 0d9eadf..5dcc478 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperItemStackSizeEnum.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperItemStackSizeEnum.java @@ -1,6 +1,6 @@ package tmb.randy.tmbgriefergames.core.enums; public enum HopperItemStackSizeEnum { - NONE, SINGLE_ITEM, TWELVE, FULL_STACK + NONE, SINGLEITEM, TWELVE, FULLSTACK } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperState.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperState.java index e84ef58..57e5aed 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperState.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/enums/HopperState.java @@ -1,5 +1,5 @@ package tmb.randy.tmbgriefergames.core.enums; public enum HopperState { - NONE, CONNECT, MULTI_CONNECT + NONE, CONNECT, MULTICONNECT } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/HopperTracker.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/HopperTracker.java index 2f2fb7e..361e996 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/HopperTracker.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/HopperTracker.java @@ -24,7 +24,7 @@ public void messageReceived(ChatReceiveEvent event) { String message = event.chatMessage().getPlainText(); setCurrentHopperState(switch (message) { - case "[Trichter] Das Multi-Verbinden wurde aktiviert. Klicke mit dem gewünschten Item auf den gewünschten Endpunkt." -> HopperState.MULTI_CONNECT; + case "[Trichter] Das Multi-Verbinden wurde aktiviert. Klicke mit dem gewünschten Item auf den gewünschten Endpunkt." -> HopperState.MULTICONNECT; case "[Trichter] Das Verbinden wurde aktiviert. Klicke auf den gewünschten Endpunkt." -> HopperState.CONNECT; case "[Trichter] Der Trichter wurde erfolgreich verbunden.", "[Trichter] Der Verbindungsmodus wurde beendet.", diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/ItemSaver.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/ItemSaver.java index 115d59a..a9d2152 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/ItemSaver.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/ItemSaver.java @@ -8,6 +8,7 @@ import net.labymod.api.event.client.input.MouseButtonEvent.Action; import net.labymod.api.util.I18n; import tmb.randy.tmbgriefergames.core.Addon; +import java.util.Objects; public class ItemSaver { @@ -23,8 +24,8 @@ public void mouseButtonEvent(MouseButtonEvent event) { if(Addon.getSharedInstance().configuration().getItemProtection().get()) { if(Laby.labyAPI().minecraft().getClientPlayer() != null) { - if(Laby.labyAPI().minecraft().getClientPlayer().getMainHandItemStack() != null) { - ItemStack stack = Laby.labyAPI().minecraft().getClientPlayer().getMainHandItemStack(); + if(Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).getMainHandItemStack() != null) { + ItemStack stack = Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).getMainHandItemStack(); if(stack.hasDataComponentContainer()) { if(stack.getDataComponentContainer().has(DataComponentKey.simple("ench"))) { String enchantments = stack.getDataComponentContainer().get(DataComponentKey.simple("ench")).toString(); @@ -53,7 +54,7 @@ public void mouseButtonEvent(MouseButtonEvent event) { public static int findHotbarSlotforBlock() { for (int i = 0; i < 9; i++) { - ItemStack stack = Laby.labyAPI().minecraft().getClientPlayer().inventory().itemStackAt(i); + ItemStack stack = Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().itemStackAt(i); if (stack.isAir()) { return i; @@ -61,7 +62,7 @@ public static int findHotbarSlotforBlock() { } for (int i = 0; i < 9; i++) { - ItemStack stack = Laby.labyAPI().minecraft().getClientPlayer().inventory().itemStackAt(i); + ItemStack stack = Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().itemStackAt(i); if(stack.isItem()) { return i; @@ -69,19 +70,19 @@ public static int findHotbarSlotforBlock() { } for (int i = 0; i < 9; i++) { - ItemStack stack = Laby.labyAPI().minecraft().getClientPlayer().inventory().itemStackAt(i); + ItemStack stack = Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().itemStackAt(i); if(stack.isBlock() && !stack.hasDataComponentContainer()) { return i; } } - return Laby.labyAPI().minecraft().getClientPlayer().inventory().getSelectedIndex() == 8 ? 0 : Laby.labyAPI().minecraft().getClientPlayer().inventory().getSelectedIndex() + 1; + return Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().getSelectedIndex() == 8 ? 0 : Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().getSelectedIndex() + 1; } public static int findHotbarSlotforItem() { for (int i = 0; i < 9; i++) { - ItemStack stack = Laby.labyAPI().minecraft().getClientPlayer().inventory().itemStackAt(i); + ItemStack stack = Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().itemStackAt(i); if (stack.isAir()) { return i; @@ -89,7 +90,7 @@ public static int findHotbarSlotforItem() { } for (int i = 0; i < 9; i++) { - ItemStack stack = Laby.labyAPI().minecraft().getClientPlayer().inventory().itemStackAt(i); + ItemStack stack = Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().itemStackAt(i); if(stack.isBlock()) { return i; @@ -97,14 +98,14 @@ public static int findHotbarSlotforItem() { } for (int i = 0; i < 9; i++) { - ItemStack stack = Laby.labyAPI().minecraft().getClientPlayer().inventory().itemStackAt(i); + ItemStack stack = Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().itemStackAt(i); if(stack.isItem() && !stack.hasDataComponentContainer()) { return i; } } - return Laby.labyAPI().minecraft().getClientPlayer().inventory().getSelectedIndex() == 8 ? 0 : Laby.labyAPI().minecraft().getClientPlayer().inventory().getSelectedIndex() + 1; + return Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().getSelectedIndex() == 8 ? 0 : Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).inventory().getSelectedIndex() + 1; } } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/PlayerTracer.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/PlayerTracer.java index 6682b5c..97ab191 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/PlayerTracer.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/PlayerTracer.java @@ -116,7 +116,7 @@ private boolean isPlayerOnCB() { return false; } - public boolean isTracerActive() { - return tracerActive; + public boolean isTracerDisabled() { + return !tracerActive; } } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/chat/ChatCleaner.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/chat/ChatCleaner.java index 63ddaa0..3ae16d8 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/chat/ChatCleaner.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/chat/ChatCleaner.java @@ -2,6 +2,8 @@ import java.util.Arrays; import java.util.List; +import net.labymod.api.Laby; +import net.labymod.api.client.component.event.ClickEvent; import net.labymod.api.event.Subscribe; import net.labymod.api.event.client.chat.ChatReceiveEvent; import tmb.randy.tmbgriefergames.core.Addon; @@ -43,16 +45,40 @@ public void messageReceived(ChatReceiveEvent event) { event.setCancelled(true); } - if(!Addon.getSharedInstance().configuration().getChatConfig().getCleanChat().get()) - return; + if(plotEnterCoordinates(message) instanceof String coordinates) + event.chatMessage().component().clickEvent(ClickEvent.runCommand("/p h " + coordinates)); + if(Addon.getSharedInstance().configuration().getChatConfig().getMuteCaseOpening().get() && !event.isCancelled()) { + if(message.startsWith("[CaseOpening] Folgender Preis wurde gezogen: ") || (message.startsWith("[CaseOpening] Der Spieler ") && message.endsWith(" hat einen Hauptpreis gewonnen!"))) { + event.setCancelled(true); + } + } - for (String str : cleanupMessages) { - if(str.equals(message)) { + if(Addon.getSharedInstance().configuration().getChatConfig().getMuteLuckyBlocks().get() && !event.isCancelled()) { + if(!message.contains(Laby.labyAPI().getName()) && (message.startsWith("[LuckyBlock] ") || (message.startsWith("[TEAM] Admin ┃ ") && message.endsWith(" » Hey Leute, was geht?")))) { event.setCancelled(true); - break; } } + if(Addon.getSharedInstance().configuration().getChatConfig().getCleanChat().get() && !event.isCancelled()) { + for (String str : cleanupMessages) { + if(str.equals(message)) { + event.setCancelled(true); + break; + } + } + } + } + + public static String plotEnterCoordinates(String text) { + String regex = "^\\[GrieferGames] \\[(-?\\d+);(-?\\d+)] \\w+ betrat dein Grundstück\\.$"; + java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regex); + java.util.regex.Matcher matcher = pattern.matcher(text); + + if (matcher.find()) { + return matcher.group(1) + ";" + matcher.group(2); + } + + return null; } } diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/chat/MsgTabs.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/chat/MsgTabs.java index 40a6a6e..f360554 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/util/chat/MsgTabs.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/util/chat/MsgTabs.java @@ -10,10 +10,15 @@ import net.labymod.api.event.client.chat.ChatMessageSendEvent; import net.labymod.api.event.client.chat.ChatReceiveEvent; import tmb.randy.tmbgriefergames.core.Addon; +import tmb.randy.tmbgriefergames.core.enums.CBs; +import tmb.randy.tmbgriefergames.core.events.CbChangedEvent; +import java.util.ArrayList; +import java.util.List; public class MsgTabs { private static String currentChatPartner = null; + private static boolean clearedMsgTabs = false; @Subscribe public void chatMessageReceived(ChatReceiveEvent event) { @@ -24,7 +29,7 @@ public void chatMessageReceived(ChatReceiveEvent event) { if(currentChatPartner != null) { getTabForName(event.chatMessage().getPlainText()); - if(!Addon.getSharedInstance().getBridge().isChatGuiOpen() && event.chatMessage().getPlainText().contains("[mir -> ")) { + if(Addon.getSharedInstance().getBridge().isChatGuiClosed() && event.chatMessage().getPlainText().contains("[mir -> ")) { reloadChat(); Addon.getSharedInstance().getBridge().openChat(); } @@ -67,6 +72,15 @@ public void messageSend(ChatMessageSendEvent event) { } } + @Subscribe + public void cbChanged(CbChangedEvent event) { + //Clear all /msg tabs on first start as they are empty + if(Addon.isGG() && !clearedMsgTabs && event.CB() == CBs.PORTAL && Addon.getSharedInstance().configuration().getChatConfig().getMsgTabMode().get()) { + clearedMsgTabs = true; + clearAllMsgTabs(); + } + } + public ChatTab createTabForPlayer(String message) { ChatWindow mainWindow = getChatWindow(); if(mainWindow != null) { @@ -121,6 +135,24 @@ private ChatTab getTabForName(String message) { return output; } + private void clearAllMsgTabs() { + ChatWindow mainWindow = getChatWindow(); + if(mainWindow != null) { + List tabsToRemove = new ArrayList<>(); + for (ChatTab tab : mainWindow.getTabs()) { + if(tab.getName().startsWith("➥ ")) { + tabsToRemove.add(tab); + } + } + + for (ChatTab tab : tabsToRemove) { + mainWindow.deleteTab(tab); + } + } + } + + + private ChatWindow getChatWindow() { if(Addon.getSharedInstance().configuration().getChatConfig().getMsgTabMode().get()) { for (ChatWindow window : Laby.references().advancedChatController().getWindows()) { diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/widgets/HopperModeWidget.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/widgets/HopperModeWidget.java index ffe6393..bbae666 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/widgets/HopperModeWidget.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/widgets/HopperModeWidget.java @@ -34,7 +34,7 @@ public void render(Stack stack, MutableMouse mouse, float partialTicks, boolean Laby.references().renderPipeline().resourceRenderer().render(stack); size.setHeight((float)32); size.setWidth((float)32); - } else if (HopperTracker.getCurrentHopperState() == HopperState.MULTI_CONNECT) { + } else if (HopperTracker.getCurrentHopperState() == HopperState.MULTICONNECT) { HOPPER_MULTI_CONNECT_ICON.render(stack, 0, 0, 32); Laby.references().renderPipeline().resourceRenderer().render(stack); size.setHeight((float)32); diff --git a/core/src/main/java/tmb/randy/tmbgriefergames/core/widgets/NearbyWidget.java b/core/src/main/java/tmb/randy/tmbgriefergames/core/widgets/NearbyWidget.java index d001d8c..29d2955 100644 --- a/core/src/main/java/tmb/randy/tmbgriefergames/core/widgets/NearbyWidget.java +++ b/core/src/main/java/tmb/randy/tmbgriefergames/core/widgets/NearbyWidget.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; public class NearbyWidget extends TextHudWidget { @@ -101,7 +102,7 @@ public static List getPlayersList() { if(entity instanceof Player player) { if(Laby.labyAPI().minecraft().getClientPlayer() != null) { - if(player.getName().equals(Laby.labyAPI().minecraft().getClientPlayer().getName())) { + if(player.getName().equals(Objects.requireNonNull(Laby.labyAPI().minecraft().getClientPlayer()).getName())) { continue; } } @@ -200,7 +201,7 @@ public static MobType fromString(String mobName) { case "pferd", "horse" -> HORSE; case "esel", "donkey" -> DONKEY; case "mule" -> MULE; - case "ocelot" -> OCELOT; + case "ozelot", "ocelot" -> OCELOT; case "wolf" -> WOLF; case "spinne", "spider" -> SPIDER; case "höhlenspinne", "cave spider" -> CAVE_SPIDER; @@ -224,7 +225,7 @@ public static MobType fromString(String mobName) { case "magmawürfel", "magma cube" -> MAGMA_CUBE; case "eisengolem", "iron golem" -> IRON_GOLEM; case "zombie pigman", "pigman", "pig zombie", "schweinezombie" -> PIGMAN; - case "snowman", "snow golem" -> SNOW_GOLEM; + case "schneegolem", "snowman", "snow golem" -> SNOW_GOLEM; default -> null; }; } @@ -245,15 +246,14 @@ public void addMob(String mobName) { mobType = MobType.fromString(mobName); - if (mobType != null) { + if (mobType != null) mobCountMap.put(mobType, mobCountMap.getOrDefault(mobType, 0) + quantity); - } else { - Addon.getSharedInstance().logger().warn("Unknown mob type: " + mobName); + /* + Uncomment for debugging purposes only as holograms will trigger this and spam the logs + else { + //Addon.getSharedInstance().logger().warn("Unknown mob type: " + mobName); } - } - - public int getMobCount(MobType mobType) { - return mobCountMap.getOrDefault(mobType, 0); + */ } public String getFormattedMobCounts() { diff --git a/core/src/main/resources/assets/tmbgriefergames/i18n/de_de.json b/core/src/main/resources/assets/tmbgriefergames/i18n/de_de.json index 5c43b9d..2a555d1 100644 --- a/core/src/main/resources/assets/tmbgriefergames/i18n/de_de.json +++ b/core/src/main/resources/assets/tmbgriefergames/i18n/de_de.json @@ -53,11 +53,23 @@ }, "finalAction": { "name": "Schlussaktion", - "description": "Legt fest, was nach Einstellung der restlichen Einstellungen passieren soll." + "description": "Legt fest, was nach Einstellung der restlichen Einstellungen passieren soll.", + "entries": { + "none": "NICHT ÄNDERN", + "close": "MENÜ SCHLIEßEN", + "connect": "VERDINDEN", + "multiconnection": "MULTI-VERBINDUNG" + } }, "stackSize": { "name": "Stackgröße", - "description": "Legt fest, welche Menge an Items der Trichter pro Tick verarbeiten soll." + "description": "Legt fest, welche Menge an Items der Trichter pro Tick verarbeiten soll.", + "entries": { + "none": "NICHT ÄNDERN", + "singleitem": "1", + "twelve": "12", + "fullstack": "64" + } }, "autoSneak": { "name": "Automatisch sneaken bei Rechtsklick" @@ -148,6 +160,12 @@ }, "msgTabMode": { "name": "/msg in Tabs" + }, + "muteCaseOpening": { + "name": "Hauptgewinne im Case Opening verbergen" + }, + "muteLuckyBlocks": { + "name": "Lucky Block Nachrichten verbergen" } }, "itemProtection": { @@ -180,7 +198,12 @@ "name": "Autocrafter & Auto(de)komprimierer", "description": "Es gibt 2 verschiedene Autocrafter:\\n\\nV1 nutzt das Vanilla Crafting Menü (Werkbank). Lege dein Rezept in die Werkbank und speichere mit SHIFT + ENTER. Drücke anschließend ENTER, um das Rezept zu craften.\\n\\nV2 nutzt das /rezepte Menü. Lege das Item, welches du craften willst in deinen ersten Hotbar Slot. Gib anschließend /autocraft in den Chat ein. Das /rezepte Menü öffnet sich automatisch und craftet deine Items.", "autoCraftSpeed": { - "name": "Geschwindigkeit" + "name": "Geschwindigkeit", + "entries": { + "slow": "LANGSAM", + "medium": "MITTEL", + "fast": "SCHNELL" + } }, "autoDrop": { "name": "Automatisch droppen" @@ -194,11 +217,19 @@ }, "finalActionV2": { "name": "Schlussaktion", - "description": "Legt fest, ob bei Nutzung des Autocrafters V2 (/autocraft) die gecrafteten Items aus dem Inventar geworfen oder komprimiert werden sollen." + "description": "Legt fest, ob bei Nutzung des Autocrafters V2 (/autocraft) die gecrafteten Items aus dem Inventar geworfen oder komprimiert werden sollen.", + "entries": { + "comp": "KOMPRIMIEREN", + "drop": "DROPPEN" + } }, "finalActionV3": { "name": "Schlussaktion", - "description": "Legt fest, ob bei Nutzung des Autocrafters V3 (/craftV3) die gecrafteten Items aus dem Inventar geworfen oder komprimiert werden sollen." + "description": "Legt fest, ob bei Nutzung des Autocrafters V3 (/craftV3) die gecrafteten Items aus dem Inventar geworfen oder komprimiert werden sollen.", + "entries": { + "comp": "KOMPRIMIEREN", + "drop": "DROPPEN" + } }, "autoCompHotkey": { "name": "Hotkey für Autokomprimierer" @@ -228,6 +259,9 @@ "autoLoot": { "name": "Auto Loot", "description": "Holt automatisch deine /freekiste und deinen /grieferboost ab." + }, + "plotWheelHotkey": { + "name": "PlotWheel öffnen" } }, "chat": { @@ -371,6 +405,17 @@ }, "autoLoot": { "skullAvailable": "Du hast wieder /kopf frei!" + }, + "plotWheel": { + "addPlot": "Plot hinzufügen", + "name": "Name", + "optional": "optional", + "cb": "CB", + "all": "[ALLE]", + "command": "Befehl", + "thisAccountOnly": "Nur dieser Account", + "add": "Hinzufügen", + "delete": "löschen" } }, "labymod": { diff --git a/core/src/main/resources/assets/tmbgriefergames/i18n/en_us.json b/core/src/main/resources/assets/tmbgriefergames/i18n/en_us.json index 21626d2..5b0ace0 100644 --- a/core/src/main/resources/assets/tmbgriefergames/i18n/en_us.json +++ b/core/src/main/resources/assets/tmbgriefergames/i18n/en_us.json @@ -53,11 +53,23 @@ }, "finalAction": { "name": "final action", - "description": "Sets the last action to execute." + "description": "Sets the last action to execute.", + "entries": { + "none": "DON'T CHANGE", + "close": "CLOSE MENU", + "connect": "CONNECT", + "multiconnection": "MULTI CONNECTION" + } }, "stackSize": { "name": "stack size", - "description": "Which stack size should the hopper pass each tick." + "description": "Which stack size should the hopper pass each tick.", + "entries": { + "none": "DON'T CHANGE", + "singleitem": "1", + "twelve": "12", + "fullstack": "64" + } }, "autoSneak": { "name": "Auto sneak when right clicking." @@ -151,6 +163,12 @@ }, "msgTabMode": { "name": "/msg in tabs" + }, + "muteCaseOpening": { + "name": "Hide Case Opening messages" + }, + "muteLuckyBlocks": { + "name": "Hide Lucky Block messages" } }, "itemProtection": { @@ -180,7 +198,12 @@ "name": "Auto-crafter & auto-(de)compressor", "description": "There are 2 different Autocrafters:\n\nV1 uses the Vanilla Crafting menu (Workbench). Place your recipe in the Workbench and save with SHIFT + ENTER. Then press ENTER to craft the recipe.\n\nV2 uses the /recipes menu. Place the item you want to craft in your first hotbar slot. Then type /autocraft in the chat. The /recipes menu will open automatically and craft your items.", "autoCraftSpeed": { - "name": "Speed" + "name": "Speed", + "entries": { + "slow": "SLOW", + "medium": "MEDIUM", + "fast": "FAST" + } }, "autoDrop": { "name": "Auto-drop" @@ -194,11 +217,19 @@ }, "finalActionV2": { "name": "Final action", - "description": "Specifies whether, when using Autocrafter V2 (/autocraft), the crafted items should be dropped or compressed in the inventory." + "description": "Specifies whether, when using Autocrafter V2 (/autocraft), the crafted items should be dropped or compressed in the inventory.", + "entries": { + "comp": "COMPRESS", + "drop": "DROP" + } }, "finalActionV3": { "name": "Final action", - "description": "Specifies whether, when using Autocrafter V3 (/craftV3), the crafted items should be dropped or compressed in the inventory." + "description": "Specifies whether, when using Autocrafter V3 (/craftV3), the crafted items should be dropped or compressed in the inventory.", + "entries": { + "comp": "COMPRESS", + "drop": "DROP" + } }, "autoCompHotkey": { "name": "Hotkey for auto-compressor" @@ -228,6 +259,9 @@ "autoLoot": { "name": "Auto Loot", "description": "Automatically gets your /freekiste and /grieferboost." + }, + "plotWheelHotkey": { + "name": "Open PlotWheel" } }, "chat": { @@ -367,6 +401,17 @@ }, "autoLoot": { "skullAvailable": "/kopf is available!" + }, + "plotWheel": { + "addPlot": "Add plot", + "name": "Name", + "optional": "optional", + "cb": "CB", + "all": "[ALL]", + "command": "Command", + "thisAccountOnly": "This account only", + "add": "Add", + "delete": "delete" } }, "labymod": { diff --git a/core/src/main/resources/assets/tmbgriefergames/textures/icon.png b/core/src/main/resources/assets/tmbgriefergames/textures/icon.png index 075778a..ed19a46 100644 Binary files a/core/src/main/resources/assets/tmbgriefergames/textures/icon.png and b/core/src/main/resources/assets/tmbgriefergames/textures/icon.png differ diff --git a/core/src/main/resources/assets/tmbgriefergames/textures/settings.png b/core/src/main/resources/assets/tmbgriefergames/textures/settings.png index cb57f36..e909dba 100644 Binary files a/core/src/main/resources/assets/tmbgriefergames/textures/settings.png and b/core/src/main/resources/assets/tmbgriefergames/textures/settings.png differ diff --git a/core/src/main/resources/assets/tmbgriefergames/themes/fancy/textures/settings.png b/core/src/main/resources/assets/tmbgriefergames/themes/fancy/textures/settings.png index cb57f36..e909dba 100644 Binary files a/core/src/main/resources/assets/tmbgriefergames/themes/fancy/textures/settings.png and b/core/src/main/resources/assets/tmbgriefergames/themes/fancy/textures/settings.png differ diff --git a/core/src/main/resources/assets/tmbgriefergames/themes/vanilla/lss/plotwheelactivity.lss b/core/src/main/resources/assets/tmbgriefergames/themes/vanilla/lss/plotwheelactivity.lss new file mode 100644 index 0000000..cae9356 --- /dev/null +++ b/core/src/main/resources/assets/tmbgriefergames/themes/vanilla/lss/plotwheelactivity.lss @@ -0,0 +1,108 @@ +.cb-wheel { + left: 50%; + top: 50%; + height: 100%; + width: 50%; + alignment-x: center; + alignment-y: center; + inner-radius: 20%; + outer-radius: 50%; + segment-distance-degrees: 0; + renderer: "Wheel"; +} + +.plot-wheel { + left: 50%; + top: 50%; + height: 100%; + width: 39%; + alignment-x: center; + alignment-y: center; + inner-radius: 10%; + outer-radius: 25%; + segment-distance-degrees: 0; + renderer: "Wheel"; +} + +.center-container { + left: 50%; + top: 50%; + width: 100; + height: fit-content; + alignment-x: center; + alignment-y: center; + border-color: white; + //border-width: 2; + + .go-button { + text: "Los!"; + } +} + +.cb-segment { + .cb-segment-display { + alignment-x: center; + alignment-y: center; + text-color: white; + } +} + +.plot-segment { + .plot-segment-display { + alignment-x: center; + alignment-y: center; + + } +} + +.cb-display { + text-color: red; + font-size: 1.3; + alignment-x: center; + alignment-y: center; +} + +.plot-display { + text-color: yellow; + font-size: 1.3; + alignment-x: center; + alignment-y: center; +} + +.add-container { + height: fit-content; + width: 150; + right: 2; + bottom: 2; + padding: 2; + background-color: rgba(10, 10, 10, 150); + border-radius: 4; + + HorizontalList { + height: fit-content; + alignment-x: center; + width: 100%; + margin: 2; + padding: 2; + border-radius: 4; + background-color: rgba(110, 110, 110, 100); + + .label { + width: 30%; + + } + + } + + .title-list { + background-color: rgba(110, 110, 110, 0); + } + + .name-textfield, .command-textfield { + width: 69%; + } + + Button { + width: 100%; + } +} \ No newline at end of file diff --git a/core/src/main/resources/assets/tmbgriefergames/themes/vanilla/textures/settings.png b/core/src/main/resources/assets/tmbgriefergames/themes/vanilla/textures/settings.png index cb57f36..e909dba 100644 Binary files a/core/src/main/resources/assets/tmbgriefergames/themes/vanilla/textures/settings.png and b/core/src/main/resources/assets/tmbgriefergames/themes/vanilla/textures/settings.png differ diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoComp.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoComp.java index 9f450de..dfc0f05 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoComp.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoComp.java @@ -3,13 +3,8 @@ import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.input.KeyEvent.State; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.gui.inventory.GuiCrafting; -import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.inventory.ClickType; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerChest; @@ -79,7 +74,7 @@ public void stopComp() { compActive = false; } - public void onTickEvent(GameTickEvent event) { + public void onTickEvent() { if(compState == CompressorState.NONE) { return; @@ -235,14 +230,6 @@ private void click(int slot) { this.toSend.clear(); } - private boolean isGUIOpen() { - GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen; - - // Check if a GUI is open and if it is a chest GUI - return currentScreen instanceof GuiChest || currentScreen instanceof GuiInventory - || currentScreen instanceof GuiCrafting; - } - public boolean isCompActive() { return compActive; } diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV1.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV1.java index b150a6f..9c69c1c 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV1.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV1.java @@ -3,13 +3,11 @@ import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.input.KeyEvent.State; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiCrafting; import net.minecraft.inventory.ClickType; import net.minecraft.inventory.ContainerWorkbench; -import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import org.apache.commons.lang3.ArrayUtils; @@ -20,8 +18,7 @@ import java.util.HashMap; import java.util.LinkedList; -public class AutoCrafterV1 -{ +public class AutoCrafterV1 { private ContainerWorkbench inv; private final int[] stored; private final int[] meta; @@ -33,8 +30,7 @@ public class AutoCrafterV1 private Simulator simulator; private boolean endlessModeToggle = false; - public AutoCrafterV1() - { + public AutoCrafterV1() { this.stored = new int[9]; this.meta = new int[9]; this.names = new String[9]; @@ -42,11 +38,9 @@ public AutoCrafterV1() this.toSend = new LinkedList<>(); } - public void onKeyEvent(KeyEvent event) { - if(Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.openContainer != null && Minecraft.getMinecraft().currentScreen instanceof GuiCrafting) { - if(event.key() == Key.ENTER) { + if(event.key() == Key.ENTER && event.state() == State.PRESS) { if(Key.L_SHIFT.isPressed()) { storeCrafting(); Addon.getSharedInstance().displayNotification(I18n.getTranslation("tmbgriefergames.autoCrafter.recipeSaved")); @@ -59,13 +53,12 @@ public void onKeyEvent(KeyEvent event) { } } - public void onTickEvent(GameTickEvent event) { + public void onTickEvent() { if(endlessModeToggle && ClickManager.getSharedInstance().isClickQueueEmpty(getCraftingSpeed())) craft(); } - public void storeCrafting() - { + public void storeCrafting() { this.inv = (ContainerWorkbench)Minecraft.getMinecraft().player.openContainer; if (!(this.inv.inventorySlots.getFirst()).getHasStack()) @@ -138,8 +131,7 @@ else if (stored[i] == 0) if (stored[i] == 0) continue; boolean found = false; - for (int j = 45; j >= 10; j--) - { + for (int j = 45; j >= 10; j--) { ItemStack curr = this.simulator.stackAt(j); String name = curr.getDisplayName(); boolean isFullStack = curr.getCount() == curr.getMaxStackSize() || !Addon.getSharedInstance().configuration().getAutoCrafterConfig().getOnlyFullStacks().get(); @@ -150,36 +142,11 @@ else if (stored[i] == 0) break; } } - if (!found) - { - int amount = 0; - int slot = -1; - for (int j = 1; j <=9; j++) - { - ItemStack curr = this.simulator.stackAt(j); - - if (curr != null && Item.getIdFromItem(curr.getItem()) == stored[i] && curr.getItemDamage() == meta[i] && curr.getCount() > amount) - { - String name = curr.getDisplayName(); - if(name.equals(names.equals(names[i]))) { - amount = curr.getCount(); - slot = j; - found = true; - } - } - } - if (found) - { - this.rightClick(slot); - this.click(i+1); - } - if (!found) - { - ItemStack displayStack = new ItemStack(Item.getItemById(stored[i])); - displayStack.setItemDamage(meta[i]); - this.sendQueue(); - return; - } + if (!found) { + ItemStack displayStack = new ItemStack(Item.getItemById(stored[i])); + displayStack.setItemDamage(meta[i]); + this.sendQueue(); + return; } } @@ -191,24 +158,21 @@ else if (stored[i] == 0) private void depositHeld() { for (int i = 10; i < 46; i++) { - if (!((Slot)this.inv.inventorySlots.get(i)).getHasStack()) + if (!(this.inv.inventorySlots.get(i)).getHasStack()) { Minecraft.getMinecraft().playerController.windowClick(this.inv.windowId, i, 0, ClickType.PICKUP, Minecraft.getMinecraft().player); return; } } - for (int i = 1; i < 10; i++) { - if (!((Slot)this.inv.inventorySlots.get(i)).getHasStack()) + if (!(this.inv.inventorySlots.get(i)).getHasStack()) { - Minecraft.getMinecraft().playerController.windowClick(this.inv.windowId, - i, 0, ClickType.PICKUP, Minecraft.getMinecraft().player); + Minecraft.getMinecraft().playerController.windowClick(this.inv.windowId, i, 0, ClickType.PICKUP, Minecraft.getMinecraft().player); return; } } - for (int i = 10; i < 46; i++) { if (ArrayUtils.contains(stored, Item.getIdFromItem(this.inv.inventorySlots.get(i).getStack().getItem()))) { @@ -217,20 +181,13 @@ private void depositHeld() { return; } } - - } - private boolean checkMaterials() - { - HashMap needed = new HashMap(); + private boolean checkMaterials() { + HashMap needed = new HashMap<>(); for (int i = 0; i < 9; i++) { if (this.stored[i] != 0) { - Integer count = needed.get(stored[i] + ":" + meta[i]); - if (count == null) - needed.put(stored[i] + ":" + meta[i], 1); - else - needed.put(stored[i] + ":" + meta[i], count + 1); + needed.merge(stored[i] + ":" + meta[i], 1, Integer::sum); } } for (int i = 1; i <= 45; i++) { @@ -251,11 +208,11 @@ private boolean checkMaterials() else needed.put(item, count - stack.getCount()); } - if (needed.size() == 0) + if (needed.isEmpty()) break; } - if (needed.size() > 0) { + if (!needed.isEmpty()) { String item = needed.keySet().iterator().next(); ItemStack displayStack = new ItemStack(Item.getItemById(Integer.parseInt(item.split(":")[0]))); displayStack.setItemDamage(Integer.parseInt(item.split(":")[1])); @@ -298,11 +255,6 @@ private void click(int slot) { this.simulator.leftClick(slot); } - private void rightClick(int slot) { - this.toSend.addLast(new Click(this.inv.windowId, slot, 1, ClickType.PICKUP)); - this.simulator.rightClick(slot); - } - private void sendQueue() { ClickManager.getSharedInstance().queueClicks(getCraftingSpeed(), toSend); this.toSend.clear(); diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV2.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV2.java index 34557b4..0b12a6e 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV2.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV2.java @@ -1,5 +1,6 @@ package tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter; +import java.util.LinkedList; import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.Phase; import net.labymod.api.event.client.input.KeyEvent; @@ -16,10 +17,8 @@ import net.minecraft.item.ItemStack; import tmb.randy.tmbgriefergames.core.Addon; import tmb.randy.tmbgriefergames.core.enums.QueueType; -import tmb.randy.tmbgriefergames.v1_12_2.util.VersionisedBridge; import tmb.randy.tmbgriefergames.v1_12_2.util.click.Click; import tmb.randy.tmbgriefergames.v1_12_2.util.click.ClickManager; -import java.util.LinkedList; public class AutoCrafterV2 { @@ -55,7 +54,7 @@ public void onTickEvent(GameTickEvent event) { currentState = STATE.OPEN_CRAFT_PAGE; } } else { - VersionisedBridge.sendCommand("/rezepte"); + Addon.sendCommand("/rezepte"); } } case OPEN_CRAFT_PAGE -> { @@ -90,9 +89,7 @@ public void onTickEvent(GameTickEvent event) { if(getSlotCountOfItemInInventory() >= 27) { switch (Addon.getSharedInstance().configuration().getAutoCrafterConfig().getFinalActionV2().get()) { - case COMP -> { - currentState = STATE.GO_BACK; - } + case COMP -> currentState = STATE.GO_BACK; case DROP -> { Minecraft.getMinecraft().player.closeScreen(); currentState = STATE.OPEN_INVENTORY; @@ -154,8 +151,7 @@ public void onTickEvent(GameTickEvent event) { } case COMP1, COMP2, COMP3, COMP4, COMP5, COMP6 -> { if(ClickManager.getSharedInstance().isClickQueueEmpty(QueueType.MEDIUM)) { - if(cont instanceof ContainerChest chest) { - IInventory inv = chest.getLowerChestInventory(); + if(cont instanceof ContainerChest) { String headName = Minecraft.getMinecraft().player.openContainer.getSlot(49).getStack().getDisplayName(); if(headName.contains("§6Komprimierungsstufe")) { int step = Integer.parseInt(headName.replace("§6Komprimierungsstufe ", "")); @@ -176,7 +172,7 @@ public void onTickEvent(GameTickEvent event) { } else if (step < 2) increaseStep(); - else if(step > 2) + else decreaseStep(); } case COMP3 -> { @@ -186,7 +182,7 @@ else if(step > 2) } else if (step < 3) increaseStep(); - else if(step > 3) + else decreaseStep(); } case COMP4 -> { @@ -196,7 +192,7 @@ else if(step > 3) } else if (step < 4) increaseStep(); - else if(step > 4) + else decreaseStep(); } case COMP5 -> { @@ -206,7 +202,7 @@ else if(step > 4) } else if (step < 5) increaseStep(); - else if(step > 5) + else decreaseStep(); } case COMP6 -> { @@ -216,7 +212,7 @@ else if(step > 5) } else if (step < 6) increaseStep(); - else if(step > 6) + else decreaseStep(); } } diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV3.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV3.java index 1324eb0..63bf46f 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV3.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/AutoCrafterV3.java @@ -1,10 +1,22 @@ package tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter; +import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP1; +import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP2; +import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP3; +import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP4; +import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP5; +import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP6; +import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.FINISHED; +import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.IDLE; +import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.OPEN_COMP; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.chat.ChatReceiveEvent; import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.input.KeyEvent.State; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiInventory; @@ -26,13 +38,8 @@ import tmb.randy.tmbgriefergames.core.Addon; import tmb.randy.tmbgriefergames.core.enums.AutoCrafterNewFinalAction; import tmb.randy.tmbgriefergames.core.enums.QueueType; -import tmb.randy.tmbgriefergames.v1_12_2.util.VersionisedBridge; import tmb.randy.tmbgriefergames.v1_12_2.util.click.Click; import tmb.randy.tmbgriefergames.v1_12_2.util.click.ClickManager; -import java.util.HashMap; -import java.util.Map; - -import static tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3.COMP_STATE.*; public class AutoCrafterV3 { private int tickCounter = 0; @@ -63,7 +70,7 @@ public void chatMessageReceived(ChatReceiveEvent event) { event.setCancelled(true); } - public void onTick(GameTickEvent event) { + public void onTick() { if(active) { if(Addon.getSharedInstance().configuration().getAutoCrafterConfig().getDelay().get() > 0) { @@ -126,7 +133,7 @@ public void onTick(GameTickEvent event) { } } } else { - VersionisedBridge.sendCommand("/rezepte"); + Addon.sendCommand("/rezepte"); } } else { Addon.getSharedInstance().displayNotification(I18n.getTranslation("tmbgriefergames.autoCrafter.noItemFound")); @@ -208,7 +215,7 @@ private void craft() { if(!isContainerOpen()) { if(nextItem == null) { - VersionisedBridge.sendCommand("/rezepte"); + Addon.sendCommand("/rezepte"); } else { BlockPos lookingAtBlock = getBlockLookingAt(); BlockPos neededBlock = sourceChests.get(nextItem); @@ -218,7 +225,9 @@ private void craft() { if(lookingAtBlock.equals(neededBlock)) { if(!Minecraft.getMinecraft().player.isSneaking()) { RayTraceResult trace = Minecraft.getMinecraft().player.rayTrace(5, 1.0F); - Minecraft.getMinecraft().playerController.processRightClickBlock(Minecraft.getMinecraft().player, Minecraft.getMinecraft().world, lookingAtBlock, trace.sideHit, trace.hitVec, EnumHand.MAIN_HAND); + if(trace != null) { + Minecraft.getMinecraft().playerController.processRightClickBlock(Minecraft.getMinecraft().player, Minecraft.getMinecraft().world, lookingAtBlock, trace.sideHit, trace.hitVec, EnumHand.MAIN_HAND); + } } } else { lookAtBlockPos(neededBlock); @@ -415,7 +424,7 @@ private static boolean areItemStacksEqual(ItemStack stack1, ItemStack stack2) { } private static String getItemKey(ItemStack stack) { - return Item.REGISTRY.getNameForObject(stack.getItem()).toString() + ":" + stack.getMetadata(); + return Objects.requireNonNull(Item.REGISTRY.getNameForObject(stack.getItem())) + ":" + stack.getMetadata(); } public static boolean isStainedGlassPane(ItemStack stack) { @@ -549,7 +558,7 @@ private void comp() { closeChest(); } } else { - VersionisedBridge.sendCommand("/rezepte"); + Addon.sendCommand("/rezepte"); } } case COMP1, COMP2, COMP3, COMP4, COMP5, COMP6, FINISHED -> { @@ -575,7 +584,7 @@ private void comp() { } else if (step < 2) increaseStep(); - else if(step > 2) + else decreaseStep(); } case COMP3 -> { @@ -585,7 +594,7 @@ else if(step > 2) } else if (step < 3) increaseStep(); - else if(step > 3) + else decreaseStep(); } case COMP4 -> { @@ -595,7 +604,7 @@ else if(step > 3) } else if (step < 4) increaseStep(); - else if(step > 4) + else decreaseStep(); } case COMP5 -> { @@ -605,7 +614,7 @@ else if(step > 4) } else if (step < 5) increaseStep(); - else if(step > 5) + else decreaseStep(); } case COMP6 -> { @@ -615,7 +624,7 @@ else if(step > 5) } else if (step < 6) increaseStep(); - else if(step > 6) + else decreaseStep(); } case FINISHED -> closeChest(); diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/Simulator.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/Simulator.java index fff1bc7..1a0ee81 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/Simulator.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoCrafter/Simulator.java @@ -26,22 +26,6 @@ public ItemStack stackAt(int slot) return this.slots[slot]; } - public void rightClick(int slot) - { - if (this.held != null) - return; - - if (this.slots == null) - return; - - ItemStack stack = this.slots[slot]; - int staying = stack.getCount() / 2; - this.held = new ItemStack(stack.getItem(), stack.getCount() - staying); - stack.setCount(staying); - if (stack.getCount() < 1) - this.slots[slot] = null; - } - public void leftClick(int slot) { if (this.held != null) diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoDecomp.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoDecomp.java index 0f0d05d..4359ce1 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoDecomp.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoDecomp.java @@ -2,7 +2,6 @@ import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.Phase; -import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; @@ -24,7 +23,7 @@ public class AutoDecomp { private int compSubID; private int counter; - public void onKeyEvent(KeyEvent event) { + public void onKeyEvent() { if(Key.ESCAPE.isPressed() && autoDecompActive) { stopDecomp(); } else if (VersionisedBridge.getSharedInstance().allKeysPressed(Addon.getSharedInstance().configuration().getAutoCrafterConfig().getAutoDecompHotkey().get())) { @@ -121,8 +120,8 @@ private void decomp() { } } } else { - if (VersionisedBridge.canSendCommand()) { - VersionisedBridge.sendCommand("/craft"); + if (Addon.canSendCommand()) { + Addon.sendCommand("/craft"); } } } diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoHopper.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoHopper.java index c4d62d2..fa969d7 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoHopper.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoHopper.java @@ -3,7 +3,6 @@ import net.labymod.api.event.client.chat.ChatReceiveEvent; import net.labymod.api.event.client.input.MouseButtonEvent; import net.labymod.api.event.client.input.MouseButtonEvent.Action; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.minecraft.block.Block; import net.minecraft.block.BlockHopper; import net.minecraft.client.Minecraft; @@ -32,34 +31,36 @@ public void mouseInput(MouseButtonEvent event) { if(event.button().isRight() && event.action() == Action.CLICK && isLookingAtHopper() && Addon.getSharedInstance().configuration().getHopperSubConfig().getAutoSneak().get()) { RayTraceResult trace = Minecraft.getMinecraft().player.rayTrace(5, 1.0F); - Keyboard.enableRepeatEvents(true); - KeyBinding sneakKey = Minecraft.getMinecraft().gameSettings.keyBindSneak; - KeyBinding jumpKey = Minecraft.getMinecraft().gameSettings.keyBindJump; - KeyBinding.setKeyBindState(sneakKey.getKeyCode(), true); - if(!Minecraft.getMinecraft().player.onGround) { - KeyBinding.setKeyBindState(jumpKey.getKeyCode(), true); - } - Minecraft.getMinecraft().playerController.clickBlock(trace.getBlockPos(), trace.sideHit); - toggeledSneak = true; - - new java.util.Timer().schedule( - new java.util.TimerTask() { - @Override - public void run() { - if(toggeledSneak) { - KeyBinding sneakKey = Minecraft.getMinecraft().gameSettings.keyBindSneak; - KeyBinding jumpKey = Minecraft.getMinecraft().gameSettings.keyBindJump; - KeyBinding.setKeyBindState(sneakKey.getKeyCode(), false); - KeyBinding.setKeyBindState(jumpKey.getKeyCode(), false); - Keyboard.enableRepeatEvents(false); - toggeledSneak = false; + if(trace != null) { + Keyboard.enableRepeatEvents(true); + KeyBinding sneakKey = Minecraft.getMinecraft().gameSettings.keyBindSneak; + KeyBinding jumpKey = Minecraft.getMinecraft().gameSettings.keyBindJump; + KeyBinding.setKeyBindState(sneakKey.getKeyCode(), true); + if(!Minecraft.getMinecraft().player.onGround) { + KeyBinding.setKeyBindState(jumpKey.getKeyCode(), true); + } + Minecraft.getMinecraft().playerController.clickBlock(trace.getBlockPos(), trace.sideHit); + toggeledSneak = true; + + new java.util.Timer().schedule( + new java.util.TimerTask() { + @Override + public void run() { + if(toggeledSneak) { + KeyBinding sneakKey = Minecraft.getMinecraft().gameSettings.keyBindSneak; + KeyBinding jumpKey = Minecraft.getMinecraft().gameSettings.keyBindJump; + KeyBinding.setKeyBindState(sneakKey.getKeyCode(), false); + KeyBinding.setKeyBindState(jumpKey.getKeyCode(), false); + Keyboard.enableRepeatEvents(false); + toggeledSneak = false; + } } - } - }, 10 - ); + }, 10 + ); + } } } - public void tick(GameTickEvent event) { + public void tick() { if(Addon.getSharedInstance().configuration().getHopperSubConfig().getEnabled().get()) { Container cont = Minecraft.getMinecraft().player.openContainer; if (cont instanceof ContainerChest chest) { @@ -106,7 +107,7 @@ public void tick(GameTickEvent event) { if(!clicked && Addon.getSharedInstance().configuration().getHopperSubConfig().getStackSize().get() != HopperItemStackSizeEnum.NONE && chest.inventorySlots.get(10).getHasStack()) { int currentStackSize = chest.getSlot(10).getStack().getCount(); switch (Addon.getSharedInstance().configuration().getHopperSubConfig().getStackSize().get()) { - case SINGLE_ITEM: + case SINGLEITEM: if(currentStackSize != 1) { ClickManager.getSharedInstance().addClick(QueueType.MEDIUM, new Click(chest.windowId, 10, 0, ClickType.QUICK_MOVE)); clicked = true; @@ -118,7 +119,7 @@ public void tick(GameTickEvent event) { clicked = true; } break; - case FULL_STACK: + case FULLSTACK: if(currentStackSize != 64) { ClickManager.getSharedInstance().addClick(QueueType.MEDIUM, new Click(chest.windowId, 10, 0, ClickType.QUICK_MOVE)); clicked = true; @@ -132,13 +133,13 @@ public void tick(GameTickEvent event) { Minecraft.getMinecraft().player.closeScreen(); } else if (Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.CONNECT) { ClickManager.getSharedInstance().addClick(QueueType.MEDIUM, new Click(chest.windowId, 16, 0, ClickType.PICKUP)); - } else if (Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.MULTI_CONNECTION) { + } else if (Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.MULTICONNECTION) { ClickManager.getSharedInstance().addClick(QueueType.MEDIUM, new Click(chest.windowId, 15, 0, ClickType.PICKUP)); } } } - } else if (inv.getName().equalsIgnoreCase("§6Trichter-Mehrfach-Verbindungen") && ClickManager.getSharedInstance().isClickQueueEmpty(QueueType.MEDIUM) && Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.MULTI_CONNECTION) { + } else if (inv.getName().equalsIgnoreCase("§6Trichter-Mehrfach-Verbindungen") && ClickManager.getSharedInstance().isClickQueueEmpty(QueueType.MEDIUM) && Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.MULTICONNECTION) { ClickManager.getSharedInstance().addClick( QueueType.MEDIUM, new Click(chest.windowId, 53, 0, ClickType.PICKUP)); } diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoLoot.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoLoot.java index 0724b29..c32e25d 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoLoot.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/AutoLoot.java @@ -19,7 +19,8 @@ public void chatMessageReceived(ChatReceiveEvent event) { String message = event.chatMessage().getPlainText(); if(Addon.getSharedInstance().configuration().getAutoLoot().get()) { - if(CBtracker.getCurrentCB() != CBs.NONE && message.equals("[Switcher] Daten heruntergeladen!") && !Addon.getSharedInstance().getPlayerTracer().isTracerActive()) { + if(CBtracker.getCurrentCB() != CBs.NONE && message.equals("[Switcher] Daten heruntergeladen!") && Addon.getSharedInstance() + .getPlayerTracer().isTracerDisabled()) { String rank = getPlayerRank(Laby.labyAPI().getName()); int periodSkull = getTimePeriodForFreeSkull(rank); @@ -37,13 +38,13 @@ public void run() { if(CBtracker.isPlotworldCB() && Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().world != null) { - Object freeBooster = FileManager.getValue("freeBooster"); + Object freeBooster = FileManager.getPlayerValue("freeBooster"); String freeBoosterString = freeBooster instanceof String ? (String) freeBooster : ""; - Object freeChest = FileManager.getValue("freeChest"); + Object freeChest = FileManager.getPlayerValue("freeChest"); String freeChestString = freeChest instanceof String ? (String) freeChest : ""; - Object freeSkull = FileManager.getValue("freeSkull"); + Object freeSkull = FileManager.getPlayerValue("freeSkull"); String freeSkullString = freeSkull instanceof String ? (String) freeSkull : ""; if(periodChest > -1) { @@ -85,26 +86,26 @@ public void run() { if(message.startsWith("[CaseOpening] Du kannst erst am ") && message.endsWith(" wieder Free-Kisten abholen.")) { event.setCancelled(true); String isolatedDate = message.replace("[CaseOpening] Du kannst erst am ", "").replace(" wieder Free-Kisten abholen.", ""); - FileManager.setValue("freeChest", stringToDate(isolatedDate).toString()); + FileManager.setPlayerValue("freeChest", stringToDate(isolatedDate).toString()); } else if(message.startsWith("Du kannst erst am ") && message.endsWith(" wieder einen Free-Booster abholen.")) { event.setCancelled(true); String isolatedDate = message.replace("Du kannst erst am ", "").replace(" wieder einen Free-Booster abholen.", ""); - FileManager.setValue("freeBooster", stringToDate(isolatedDate).toString()); + FileManager.setPlayerValue("freeBooster", stringToDate(isolatedDate).toString()); } else if(message.equals("[CaseOpening] Du hast 2 Kisten erhalten.")) { String rank = getPlayerRank(Laby.labyAPI().getName()); int periodChest = getTimePeriodForFreeChest(rank); if(periodChest > -1) - FileManager.setValue("freeChest", LocalDateTime.now().plusDays(periodChest).toString()); + FileManager.setPlayerValue("freeChest", LocalDateTime.now().plusDays(periodChest).toString()); } else if(message.startsWith("Du hast 1 ") && message.endsWith("-Booster erhalten. Danke für deine Unterstützung von GrieferGames!")) { String rank = getPlayerRank(Laby.labyAPI().getName()); int periodChest = getTimePeriodForFreeChest(rank); if(periodChest > -1) - FileManager.setValue("freeBooster", LocalDateTime.now().plusDays(periodChest).toString()); + FileManager.setPlayerValue("freeBooster", LocalDateTime.now().plusDays(periodChest).toString()); } else if(message.startsWith("[Kopf] Du hast einen ") && message.endsWith("-Kopf erhalten!")) { String rank = getPlayerRank(Laby.labyAPI().getName()); int periodSkull = getTimePeriodForFreeSkull(rank); if(periodSkull > -1) - FileManager.setValue("freeSkull", LocalDateTime.now().plusDays(periodSkull).toString()); + FileManager.setPlayerValue("freeSkull", LocalDateTime.now().plusDays(periodSkull).toString()); } } } diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/Auswurf.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/Eject.java similarity index 87% rename from game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/Auswurf.java rename to game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/Eject.java index 857a019..aa1bcc3 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/Auswurf.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/Eject.java @@ -3,13 +3,10 @@ import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.input.KeyEvent.State; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.block.BlockChest; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; @@ -21,11 +18,11 @@ import tmb.randy.tmbgriefergames.core.enums.QueueType; import tmb.randy.tmbgriefergames.v1_12_2.util.click.ClickManager; -public class Auswurf { +public class Eject { private boolean active; private BlockPos chestPos; - public void onTickEvent(GameTickEvent event) { + public void onTickEvent() { if(active && Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().world != null) { if(Minecraft.getMinecraft().player.openContainer instanceof ContainerChest chest) { IInventory inv = chest.getLowerChestInventory(); @@ -88,14 +85,4 @@ private static BlockPos getChestPos() { return null; } - - private static Entity getEntityInBlockPos(BlockPos pos) { - Minecraft mc = Minecraft.getMinecraft(); - for (Entity entity : mc.world.loadedEntityList) { - if (entity instanceof EntityLivingBase && entity.getDistanceSq(pos) < 2) { - return entity; - } - } - return null; - } } diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/FlyTimer.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/FlyTimer.java index 2a613a0..0017649 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/FlyTimer.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/FlyTimer.java @@ -4,7 +4,6 @@ import net.labymod.api.client.world.item.ItemStack; import net.labymod.api.event.client.input.MouseButtonEvent; import net.labymod.api.event.client.input.MouseButtonEvent.Action; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.event.client.world.ItemStackTooltipEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; @@ -19,7 +18,7 @@ public class FlyTimer { Date totalDurationTime; - public void tick(GameTickEvent event) { + public void tick() { if (totalDurationTime != null) { if (getRemainingTotalTimeSeconds() < 0L) { totalDurationTime = null; diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/HopperConnections.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/HopperConnections.java index ae8ee20..4eb2f2d 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/HopperConnections.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/HopperConnections.java @@ -1,7 +1,10 @@ package tmb.randy.tmbgriefergames.v1_12_2.util; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; import net.labymod.api.event.client.chat.ChatReceiveEvent; -import net.labymod.api.event.client.render.world.RenderWorldEvent; import net.labymod.api.nbt.NBTTagType; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -19,13 +22,7 @@ import tmb.randy.tmbgriefergames.core.CBtracker; import tmb.randy.tmbgriefergames.core.enums.CBs; import tmb.randy.tmbgriefergames.core.enums.HopperState; -import tmb.randy.tmbgriefergames.core.events.CbChangedEvent; import tmb.randy.tmbgriefergames.core.events.HopperStateChangedEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; public class HopperConnections { @@ -177,35 +174,33 @@ public void messageReceived(ChatReceiveEvent event) { } } - public void cbChanged(CbChangedEvent event) { + public void cbChanged() { currentConnectingHopper = null; } - public void renderWorld(RenderWorldEvent event) { - Iterator> iterator = conntections.entrySet().iterator(); + public void renderWorld() { - while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); + for (Entry entry : conntections.entrySet()) { HopperConnection conntection = entry.getValue(); - double distance = conntection.pos1.distanceSq(Minecraft.getMinecraft().player.posX, Minecraft.getMinecraft().player.posY, Minecraft.getMinecraft().player.posZ); + double distance = conntection.pos1.distanceSq(Minecraft.getMinecraft().player.posX, + Minecraft.getMinecraft().player.posY, Minecraft.getMinecraft().player.posZ); double actualDistance = Math.sqrt(distance); - if(actualDistance > 30) + if (actualDistance > 30) continue; if (conntection.cb == CBtracker.getCurrentCB()) { - if (Minecraft.getMinecraft().world.getBlockState(conntection.pos1()).getBlock() == Blocks.HOPPER) { + if (Minecraft.getMinecraft().world.getBlockState(conntection.pos1()).getBlock() + == Blocks.HOPPER) { drawLineBetween(conntection); - } else { - iterator.remove(); } } } if(currentConnectingHopper != null) { - drawSphere(currentConnectingHopper, 30.0d, event.getPartialTicks()); + drawSphere(currentConnectingHopper); } } @@ -292,7 +287,7 @@ private void renderItemStackAt(ItemStack stack, double x, double y, double z) { GlStateManager.popMatrix(); } - private void drawSphere(BlockPos center, double radius, float partialTicks) { + private void drawSphere(BlockPos center) { if(!Addon.getSharedInstance().configuration().getHopperSubConfig().getShowRadius().get()) return; @@ -319,13 +314,13 @@ private void drawSphere(BlockPos center, double radius, float partialTicks) { for (double theta = 0; theta < Math.PI * 2; theta += step) { for (double phi = 0; phi < Math.PI; phi += step) { - double x1 = radius * Math.sin(phi) * Math.cos(theta); - double z1 = radius * Math.sin(phi) * Math.sin(theta); - double y1 = radius * Math.cos(phi); + double x1 = 30.0 * Math.sin(phi) * Math.cos(theta); + double z1 = 30.0 * Math.sin(phi) * Math.sin(theta); + double y1 = 30.0 * Math.cos(phi); - double x2 = radius * Math.sin(phi + step) * Math.cos(theta); - double z2 = radius * Math.sin(phi + step) * Math.sin(theta); - double y2 = radius * Math.cos(phi + step); + double x2 = 30.0 * Math.sin(phi + step) * Math.cos(theta); + double z2 = 30.0 * Math.sin(phi + step) * Math.sin(theta); + double y2 = 30.0 * Math.cos(phi + step); GL11.glVertex3d(x1, y1, z1); GL11.glVertex3d(x2, y2, z2); @@ -334,13 +329,13 @@ private void drawSphere(BlockPos center, double radius, float partialTicks) { for (double theta = 0; theta < Math.PI * 2; theta += step) { for (double phi = 0; phi < Math.PI; phi += step) { - double y1 = radius * Math.sin(phi) * Math.cos(theta); - double z1 = radius * Math.sin(phi) * Math.sin(theta); - double x1 = radius * Math.cos(phi); + double y1 = 30.0 * Math.sin(phi) * Math.cos(theta); + double z1 = 30.0 * Math.sin(phi) * Math.sin(theta); + double x1 = 30.0 * Math.cos(phi); - double y2 = radius * Math.sin(phi + step) * Math.cos(theta); - double z2 = radius * Math.sin(phi + step) * Math.sin(theta); - double x2 = radius * Math.cos(phi + step); + double y2 = 30.0 * Math.sin(phi + step) * Math.cos(theta); + double z2 = 30.0 * Math.sin(phi + step) * Math.sin(theta); + double x2 = 30.0 * Math.cos(phi + step); GL11.glVertex3d(x1, y1, z1); GL11.glVertex3d(x2, y2, z2); diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/ItemShifter.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/ItemShifter.java index 5c4c7db..6e5a8ed 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/ItemShifter.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/ItemShifter.java @@ -2,7 +2,6 @@ import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.input.KeyEvent; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiInventory; @@ -88,7 +87,6 @@ public void startShifting() { int availableSlots = getEmptySlotsInRange(destMin, destMax); boolean isSpawner = this.checkIfContainerIsSpawner(); - for(int from = fromMin; from <= fromMax; from++) { Slot fromSlot = this.currentChest.inventorySlots.get(from); @@ -111,11 +109,11 @@ public void startShifting() { this.sendQueue(); } - public void tick(GameTickEvent event) { + public void tick() { if((Keyboard.isKeyDown(Key.ARROW_LEFT.getId()) && Keyboard.isKeyDown(Key.ARROW_UP.getId()) && Keyboard.isKeyDown(Key.ARROW_RIGHT.getId())) || !(Minecraft.getMinecraft().player.openContainer instanceof ContainerChest)) return; - if (Minecraft.getMinecraft().player != null && Minecraft.getMinecraft().player.openContainer != null && Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { ContainerChest chest = ((ContainerChest) Minecraft.getMinecraft().player.openContainer); IInventory inv = chest.getLowerChestInventory(); @@ -208,11 +206,7 @@ public void setTopToBottom(boolean topToBottom) { } private void sendQueue() { - if(checkIfContainerIsSpawner()) { - ClickManager.getSharedInstance().queueClicks(QueueType.SLOW, toSend); - } else { - ClickManager.getSharedInstance().queueClicks(QueueType.SLOW, toSend); - } + ClickManager.getSharedInstance().queueClicks(QueueType.SLOW, toSend); this.toSend.clear(); } diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/NatureBordersRenderer.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/NatureBordersRenderer.java index 80a897c..b2e9cb0 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/NatureBordersRenderer.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/NatureBordersRenderer.java @@ -1,6 +1,5 @@ package tmb.randy.tmbgriefergames.v1_12_2.util; -import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.render.world.RenderWorldEvent; import net.labymod.api.util.Color; import net.labymod.api.util.I18n; @@ -34,7 +33,7 @@ public static double getDistanceSq(double x1, double z1, double x2, double z2) private float lineGreen = 0.0F; private float lineBlue = 0.0F; - public void onKey(KeyEvent event) { + public void onKey() { if(VersionisedBridge.getSharedInstance().allKeysPressed(Addon.getSharedInstance().configuration().getNatureSubConfig().getHotkey().get()) && !Addon.isChatGuiOpen() && CBtracker.isNatureWorldCB()) { Addon.getSharedInstance().configuration().getNatureSubConfig().getShowBorders().set(!Addon.getSharedInstance().configuration().getNatureSubConfig().getShowBorders().get()); diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/TooltipExtension.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/TooltipExtension.java index 42315da..88a130c 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/TooltipExtension.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/TooltipExtension.java @@ -10,7 +10,6 @@ public class TooltipExtension { - public void renderTooltip(ItemStackTooltipEvent event) { if(!Addon.isGG()) { return; diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/VABK.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/VABK.java index 90bc749..7a0e9c8 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/VABK.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/VABK.java @@ -37,7 +37,8 @@ public void onTickEvent(GameTickEvent event) { } public void onKeyEvent(KeyEvent event) { - if(event.state() == State.PRESS && VersionisedBridge.getSharedInstance().allKeysPressed(Addon.getSharedInstance().configuration().getSwordsSubConfig().getVABKhotkey().get()) && !VersionisedBridge.getSharedInstance().isChatGuiOpen()) { + if(event.state() == State.PRESS && VersionisedBridge.getSharedInstance().allKeysPressed(Addon.getSharedInstance().configuration().getSwordsSubConfig().getVABKhotkey().get()) && VersionisedBridge.getSharedInstance() + .isChatGuiClosed()) { toggleActive(); } } @@ -47,12 +48,6 @@ public void toggleActive() { Addon.getSharedInstance().displayNotification(I18n.getTranslation(active ? "tmbgriefergames.autoSword.enabled" : "tmbgriefergames.autoSword.disabled")); } - public void stop() { - if(active) { - toggleActive(); - } - } - private void startUsingBow() { if(Minecraft.getMinecraft().player == null || Minecraft.getMinecraft().world == null) return; diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/VersionisedBridge.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/VersionisedBridge.java index 565392a..693265d 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/VersionisedBridge.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/VersionisedBridge.java @@ -1,5 +1,6 @@ package tmb.randy.tmbgriefergames.v1_12_2.util; +import javax.inject.Singleton; import net.labymod.api.Laby; import net.labymod.api.client.gui.screen.activity.types.IngameOverlayActivity; import net.labymod.api.client.gui.screen.key.Key; @@ -24,14 +25,12 @@ import org.lwjgl.input.Keyboard; import tmb.randy.tmbgriefergames.core.Addon; import tmb.randy.tmbgriefergames.core.IBridge; -import tmb.randy.tmbgriefergames.core.enums.CBs; import tmb.randy.tmbgriefergames.core.events.CbChangedEvent; import tmb.randy.tmbgriefergames.core.events.HopperStateChangedEvent; import tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV1; import tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV2; import tmb.randy.tmbgriefergames.v1_12_2.util.AutoCrafter.AutoCrafterV3; import tmb.randy.tmbgriefergames.v1_12_2.util.click.ClickManager; -import javax.inject.Singleton; @Singleton @Implements(IBridge.class) @@ -48,7 +47,7 @@ public class VersionisedBridge implements IBridge { private final AutoCrafterV2 autoCrafterV2 = new AutoCrafterV2(); private final AutoCrafterV3 autoCrafterV3 = new AutoCrafterV3(); private final AutoDecomp autoDecomp = new AutoDecomp(); - private final Auswurf auswurf = new Auswurf(); + private final Eject auswurf = new Eject(); private final HABK habk = new HABK(); private final VABK vabk = new VABK(); private final HopperConnections hopperConnections = new HopperConnections(); @@ -56,23 +55,19 @@ public class VersionisedBridge implements IBridge { private GuiScreen lastGui; - private static final int commandCountdownLimit = 80; - private static int commandCountdown = 0; - public VersionisedBridge() { sharedInstance = this; } @Subscribe public void cbChanged(CbChangedEvent event) { + if(!Addon.isGG()) + return; + autoComp.stopComp(); autoCrafterV2.stopCrafter(); autoCrafterV3.stop(); - hopperConnections.cbChanged(event); - - if(event.CB() == CBs.LOBBY && Addon.getSharedInstance().configuration().getSkipHub().get()) { - VersionisedBridge.sendCommand("/portal"); - } + hopperConnections.cbChanged(); } @Subscribe @@ -108,7 +103,7 @@ public void onScoreboardRender(IngameOverlayElementRenderEvent event) { @Subscribe public void tick(GameTickEvent event) { - if(!Laby.labyAPI().minecraft().isIngame() || Minecraft.getMinecraft().player == null || Minecraft.getMinecraft().world == null) + if(!Laby.labyAPI().minecraft().isIngame() || Minecraft.getMinecraft().player == null || Minecraft.getMinecraft().world == null || !Addon.isGG()) return; GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen; @@ -126,22 +121,24 @@ public void tick(GameTickEvent event) { lastGui = currentScreen; } - ClickManager.getSharedInstance().tick(event); - autoComp.onTickEvent(event); - autoCrafterV1.onTickEvent(event); - autoHopper.tick(event); - itemShifter.tick(event); + ClickManager.getSharedInstance().tick(); + autoComp.onTickEvent(); + autoCrafterV1.onTickEvent(); + autoHopper.tick(); + itemShifter.tick(); autoCrafterV2.onTickEvent(event); autoDecomp.onTickEvent(event); - auswurf.onTickEvent(event); - autoCrafterV3.onTick(event); + auswurf.onTickEvent(); + autoCrafterV3.onTick(); vabk.onTickEvent(event); - - commandCountdown(); + flyTimer.tick(); } @Subscribe public void hopperStateChanged(HopperStateChangedEvent event) { + if(!Addon.isGG()) + return; + hopperConnections.hopperStateChanged(event); } @@ -151,11 +148,11 @@ public void keyDown(KeyEvent event) { return; itemShifter.onKey(event); - natureBordersRenderer.onKey(event); + natureBordersRenderer.onKey(); autoComp.onKeyEvent(event); autoCrafterV1.onKeyEvent(event); autoCrafterV2.onKeyEvent(event); - autoDecomp.onKeyEvent(event); + autoDecomp.onKeyEvent(); auswurf.onKeyEvent(event); autoCrafterV3.onKey(event); vabk.onKeyEvent(event); @@ -167,7 +164,7 @@ public void onRenderEvent(RenderWorldEvent event) { return; natureBordersRenderer.onRender(event); - hopperConnections.renderWorld(event); + hopperConnections.renderWorld(); } @Subscribe @@ -217,31 +214,15 @@ public void startAutocrafterV3() { autoCrafterV3.toggle(); } - private static void commandCountdown() { - if (commandCountdown > 0) { - commandCountdown--; - } - } - - public static boolean canSendCommand() { return commandCountdown <= 0; } - public static boolean sendCommand(String command) { - if(canSendCommand()) { - Laby.references().chatExecutor().chat(command); - commandCountdown = commandCountdownLimit; - return true; - } - return false; - } - @Override - public boolean isChatGuiOpen() { + public boolean isChatGuiClosed() { for (IngameOverlayActivity activity : Laby.labyAPI().ingameOverlay().getActivities()) { if(activity.isAcceptingInput()) { - return true; + return false; } } - return false; + return true; } public static boolean isGUIOpen() { diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/Click.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/Click.java index c64a56e..5ead5f5 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/Click.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/Click.java @@ -8,4 +8,4 @@ public record Click(int windowID, int slot, int data, ClickType action) { public String toString() { return "window: " + windowID + " slot: " + slot; } -} +} \ No newline at end of file diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/ClickManager.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/ClickManager.java index f23f3e5..b308ed6 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/ClickManager.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/ClickManager.java @@ -1,12 +1,9 @@ package tmb.randy.tmbgriefergames.v1_12_2.util.click; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.minecraft.client.Minecraft; import net.minecraft.inventory.ClickType; import net.minecraft.inventory.Container; import net.minecraft.item.Item; -import net.minecraft.util.EnumHand; -import net.minecraft.world.World; import tmb.randy.tmbgriefergames.core.enums.QueueType; import java.util.HashMap; import java.util.LinkedList; @@ -23,9 +20,9 @@ private ClickManager() { queues.put(QueueType.FAST, new ClickQueue(QueueType.FAST)); } - public void tick(GameTickEvent event) { + public void tick() { for (Map.Entry entry : queues.entrySet()) { - entry.getValue().tick(event); + entry.getValue().tick(); } } @@ -36,10 +33,6 @@ public static ClickManager getSharedInstance() { return SharedInstance; } - public void rightClick(World world, EnumHand hand) { - Minecraft.getMinecraft().player.getHeldItemMainhand().useItemRightClick(world, Minecraft.getMinecraft().player, hand); - } - public void dropInventory() { Container container = Minecraft.getMinecraft().player.openContainer; int size = container.inventorySlots.size(); @@ -51,21 +44,6 @@ public void dropInventory() { } } - public void dropItemsFromInventory(Item item, boolean skipFirst) { - Container container = Minecraft.getMinecraft().player.openContainer; - int size = container.inventorySlots.size(); - for(int i = 9; i < size; i++) { - if(container.getSlot(i).getHasStack()) { - if(container.getSlot(i).getStack().getItem().equals(item)) { - if(skipFirst && i == 36) { - continue; - } - dropClick(i); - } - } - } - } - public void dropItemsFromInventory(Item item, int metadata, boolean skipFirst) { Container container = Minecraft.getMinecraft().player.openContainer; int size = container.inventorySlots.size(); @@ -86,10 +64,6 @@ public void queueClicks(QueueType queueType, LinkedList queue) queues.get(queueType).queueClicks(queue); } - public void clearQueue(QueueType queue) { - queues.get(queue).clearQueue(); - } - public void clearAllQueues() { for (Map.Entry entry : queues.entrySet()) { entry.getValue().clearQueue(); diff --git a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/ClickQueue.java b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/ClickQueue.java index 83240df..908e052 100644 --- a/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/ClickQueue.java +++ b/game-runner/src/v1_12_2/java/tmb/randy/tmbgriefergames/v1_12_2/util/click/ClickQueue.java @@ -1,20 +1,16 @@ package tmb.randy.tmbgriefergames.v1_12_2.util.click; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiCrafting; import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.inventory.ClickType; import tmb.randy.tmbgriefergames.core.enums.QueueType; import java.util.LinkedList; public class ClickQueue { private final LinkedList clickQueue = new LinkedList<>(); private int clickCooldownCounter = 0; - private int clickSpeed; - - private ClickQueue() {} + private final int clickSpeed; public ClickQueue(QueueType type) { clickSpeed = switch (type) { @@ -24,7 +20,7 @@ public ClickQueue(QueueType type) { }; } - public void tick(GameTickEvent event) { + public void tick() { while (!this.clickQueue.isEmpty() && this.clickCooldownCounter <= 0) { if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest @@ -46,16 +42,6 @@ public void tick(GameTickEvent event) { } } - private void dropClick(int slot) - { - this.clickQueue.addLast(new Click(Minecraft.getMinecraft().player.openContainer.windowId, slot, 0, ClickType.PICKUP)); - this.clickQueue.addLast(new Click(Minecraft.getMinecraft().player.openContainer.windowId, -999, 0, ClickType.PICKUP)); - } - - private void shiftClick(int slot) { - this.clickQueue.add(new Click(Minecraft.getMinecraft().player.openContainer.windowId, slot, 0, ClickType.QUICK_MOVE)); - } - public void add(Click click) { this.clickQueue.add(click); } diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoComp.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoComp.java index e936c94..581ea68 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoComp.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoComp.java @@ -3,7 +3,6 @@ import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.input.KeyEvent.State; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; import net.minecraft.inventory.Container; @@ -74,7 +73,7 @@ public void stopComp() { compActive = false; } - public void onTickEvent(GameTickEvent event) { + public void onTickEvent() { if(compState == CompressorState.NONE) { return; diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV1.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV1.java index 3c5f563..6a9ff31 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV1.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV1.java @@ -3,12 +3,10 @@ import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.input.KeyEvent.State; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiCrafting; import net.minecraft.inventory.ContainerWorkbench; -import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import org.apache.commons.lang3.ArrayUtils; @@ -43,9 +41,8 @@ public AutoCrafterV1() public void onKeyEvent(KeyEvent event) { - if(Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.openContainer != null && Minecraft.getMinecraft().currentScreen instanceof GuiCrafting) { - if(event.key() == Key.ENTER) { + if(event.key() == Key.ENTER && event.state() == State.PRESS) { if(Key.L_SHIFT.isPressed()) { storeCrafting(); Addon.getSharedInstance().displayNotification(I18n.getTranslation("tmbgriefergames.autoCrafter.recipeSaved")); @@ -58,23 +55,20 @@ public void onKeyEvent(KeyEvent event) { } } - public void onTickEvent(GameTickEvent event) { + public void onTickEvent() { if(endlessModeToggle && ClickManager.getSharedInstance().isClickQueueEmpty(getCraftingSpeed())) { craft(); } } - public void storeCrafting() - { + public void storeCrafting() { this.inv = (ContainerWorkbench)Minecraft.getMinecraft().thePlayer.openContainer; - if (!(this.inv.inventorySlots.get(0)).getHasStack()) - { + if (!(this.inv.inventorySlots.getFirst()).getHasStack()) { return; } ItemStack result = (this.inv.inventorySlots.getFirst()).getStack(); - for (int i = 0; i < 9; i++) - { + for (int i = 0; i < 9; i++) { if (this.inv.inventorySlots.get(i+1) != null) { ItemStack stack = (this.inv.inventorySlots.get(i+1)).getStack(); @@ -93,8 +87,7 @@ public void storeCrafting() this.outputItem = result.getItem(); } - public void craft() - { + public void craft() { if(!(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerWorkbench)) { return; } @@ -148,43 +141,18 @@ else if (stored[i] == 0) String name = curr.getDisplayName(); boolean isFullStack = curr.stackSize == curr.getMaxStackSize() || !Addon.getSharedInstance().configuration().getAutoCrafterConfig().getOnlyFullStacks().get(); - if (curr != null && Item.getIdFromItem(curr.getItem()) == stored[i] && curr.getItemDamage() == meta[i] && name.equals(names[i]) && isFullStack) { + if (Item.getIdFromItem(curr.getItem()) == stored[i] && curr.getItemDamage() == meta[i] && name.equals(names[i]) && isFullStack) { this.click(j); this.click(i+1); found = true; break; } } - if (!found) - { - int amount = 0; - int slot = -1; - for (int j = 1; j <=9; j++) - { - ItemStack curr = this.simulator.stackAt(j); - - if (curr != null && Item.getIdFromItem(curr.getItem()) == stored[i] && curr.getItemDamage() == meta[i] && curr.stackSize > amount) - { - String name = curr.getDisplayName(); - if(name.equals(names.equals(names[i]))) { - amount = curr.stackSize; - slot = j; - found = true; - } - } - } - if (found) - { - this.rightClick(slot); - this.click(i+1); - } - if (!found) - { - ItemStack displayStack = new ItemStack(Item.getItemById(stored[i])); - displayStack.setItemDamage(meta[i]); - this.sendQueue(); - return; - } + if (!found) { + ItemStack displayStack = new ItemStack(Item.getItemById(stored[i])); + displayStack.setItemDamage(meta[i]); + this.sendQueue(); + return; } } @@ -303,11 +271,6 @@ private void click(int slot) { this.simulator.leftClick(slot); } - private void rightClick(int slot) { - this.toSend.addLast(new Click(this.inv.windowId, slot, 1, 0)); - this.simulator.rightClick(slot); - } - private void sendQueue() { ClickManager.getSharedInstance().queueClicks(getCraftingSpeed(), toSend); this.toSend.clear(); diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV2.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV2.java index 5fa4306..4a97790 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV2.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV2.java @@ -15,7 +15,6 @@ import net.minecraft.item.ItemStack; import tmb.randy.tmbgriefergames.core.Addon; import tmb.randy.tmbgriefergames.core.enums.QueueType; -import tmb.randy.tmbgriefergames.v1_8_9.util.VersionisedBridge; import tmb.randy.tmbgriefergames.v1_8_9.util.click.Click; import tmb.randy.tmbgriefergames.v1_8_9.util.click.ClickManager; import java.util.LinkedList; @@ -54,7 +53,7 @@ public void onTickEvent(GameTickEvent event) { currentState = STATE.OPEN_CRAFT_PAGE; } } else { - VersionisedBridge.sendCommand("/rezepte"); + Addon.sendCommand("/rezepte"); } } case OPEN_CRAFT_PAGE -> { @@ -89,9 +88,7 @@ public void onTickEvent(GameTickEvent event) { if(getSlotCountOfItemInInventory() >= 27) { switch (Addon.getSharedInstance().configuration().getAutoCrafterConfig().getFinalActionV2().get()) { - case COMP -> { - currentState = STATE.GO_BACK; - } + case COMP -> currentState = STATE.GO_BACK; case DROP -> { Minecraft.getMinecraft().thePlayer.closeScreen(); currentState = STATE.OPEN_INVENTORY; @@ -153,7 +150,7 @@ public void onTickEvent(GameTickEvent event) { } case COMP1, COMP2, COMP3, COMP4, COMP5, COMP6 -> { if(ClickManager.getSharedInstance().isClickQueueEmpty(QueueType.MEDIUM)) { - if(cont instanceof ContainerChest chest) { + if(cont instanceof ContainerChest) { if(Minecraft.getMinecraft().thePlayer.openContainer.getSlot(49).getStack() == null) break; @@ -178,7 +175,7 @@ public void onTickEvent(GameTickEvent event) { } else if (step < 2) increaseStep(); - else if(step > 2) + else decreaseStep(); } case COMP3 -> { @@ -188,7 +185,7 @@ else if(step > 2) } else if (step < 3) increaseStep(); - else if(step > 3) + else decreaseStep(); } case COMP4 -> { @@ -198,7 +195,7 @@ else if(step > 3) } else if (step < 4) increaseStep(); - else if(step > 4) + else decreaseStep(); } case COMP5 -> { @@ -208,7 +205,7 @@ else if(step > 4) } else if (step < 5) increaseStep(); - else if(step > 5) + else decreaseStep(); } case COMP6 -> { @@ -218,7 +215,7 @@ else if(step > 5) } else if (step < 6) increaseStep(); - else if(step > 6) + else decreaseStep(); } } diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV3.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV3.java index f956d2e..e7d4a1c 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV3.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/AutoCrafterV3.java @@ -1,10 +1,21 @@ package tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter; +import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP1; +import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP2; +import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP3; +import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP4; +import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP5; +import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.COMP6; +import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.FINISHED; +import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.IDLE; +import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.OPEN_COMP; + +import java.util.HashMap; +import java.util.Map; import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.chat.ChatReceiveEvent; import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.input.KeyEvent.State; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiInventory; @@ -25,13 +36,8 @@ import tmb.randy.tmbgriefergames.core.Addon; import tmb.randy.tmbgriefergames.core.enums.AutoCrafterNewFinalAction; import tmb.randy.tmbgriefergames.core.enums.QueueType; -import tmb.randy.tmbgriefergames.v1_8_9.util.VersionisedBridge; import tmb.randy.tmbgriefergames.v1_8_9.util.click.Click; import tmb.randy.tmbgriefergames.v1_8_9.util.click.ClickManager; -import java.util.HashMap; -import java.util.Map; - -import static tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3.COMP_STATE.*; public class AutoCrafterV3 { private int tickCounter = 0; @@ -62,7 +68,7 @@ public void chatMessageReceived(ChatReceiveEvent event) { event.setCancelled(true); } - public void onTick(GameTickEvent event) { + public void onTick() { if(active) { if(Addon.getSharedInstance().configuration().getAutoCrafterConfig().getDelay().get() > 0) { @@ -126,7 +132,7 @@ public void onTick(GameTickEvent event) { } } } else { - VersionisedBridge.sendCommand("/rezepte"); + Addon.sendCommand("/rezepte"); } } else { Addon.getSharedInstance().displayNotification(I18n.getTranslation("tmbgriefergames.autoCrafter.noItemFound")); @@ -208,7 +214,7 @@ private void craft() { if(!isContainerOpen()) { if(nextItem == null) { - VersionisedBridge.sendCommand("/rezepte"); + Addon.sendCommand("/rezepte"); } else { BlockPos lookingAtBlock = getBlockLookingAt(); BlockPos neededBlock = sourceChests.get(nextItem); @@ -554,7 +560,7 @@ private void comp() { closeChest(); } } else { - VersionisedBridge.sendCommand("/rezepte"); + Addon.sendCommand("/rezepte"); } } case COMP1, COMP2, COMP3, COMP4, COMP5, COMP6, FINISHED -> { @@ -580,7 +586,7 @@ private void comp() { } else if (step < 2) increaseStep(); - else if(step > 2) + else decreaseStep(); } case COMP3 -> { @@ -590,7 +596,7 @@ else if(step > 2) } else if (step < 3) increaseStep(); - else if(step > 3) + else decreaseStep(); } case COMP4 -> { @@ -600,7 +606,7 @@ else if(step > 3) } else if (step < 4) increaseStep(); - else if(step > 4) + else decreaseStep(); } case COMP5 -> { @@ -610,7 +616,7 @@ else if(step > 4) } else if (step < 5) increaseStep(); - else if(step > 5) + else decreaseStep(); } case COMP6 -> { @@ -620,7 +626,7 @@ else if(step > 5) } else if (step < 6) increaseStep(); - else if(step > 6) + else decreaseStep(); } case FINISHED -> closeChest(); diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/Simulator.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/Simulator.java index 508a659..169de57 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/Simulator.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoCrafter/Simulator.java @@ -10,8 +10,7 @@ public class Simulator private final ItemStack[] slots; private ItemStack held; - public Simulator(List inventorySlots, int size) - { + public Simulator(List inventorySlots, int size) { this.size = size; this.slots = new ItemStack[size]; for (int i = 0; i < size; i++) @@ -25,24 +24,7 @@ public ItemStack stackAt(int slot) return this.slots[slot]; } - - public void rightClick(int slot) { - if (this.held != null) - return; - - if (this.slots == null) - return; - - ItemStack stack = this.slots[slot]; - int staying = stack.stackSize / 2; - this.held = new ItemStack(stack.getItem(), stack.stackSize - staying); - stack.stackSize = staying; - if (stack.stackSize < 1) - this.slots[slot] = null; - } - - public void leftClick(int slot) - { + public void leftClick(int slot) { if (this.held != null) { if (this.slots[slot] != null) return; @@ -67,8 +49,7 @@ public void shiftClick(int slot) { this.slots[slot] = null; } - private int findFirstFreeSlot() - { + private int findFirstFreeSlot() { for (int i = this.size - 36; i < this.size; i++) { if (this.slots[i] == null) @@ -76,4 +57,4 @@ private int findFirstFreeSlot() } return 0; } -} +} \ No newline at end of file diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoDecomp.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoDecomp.java index b49fb04..5c629ab 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoDecomp.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoDecomp.java @@ -2,7 +2,6 @@ import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.Phase; -import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; @@ -23,7 +22,7 @@ public class AutoDecomp { private int compSubID; private int counter; - public void onKeyEvent(KeyEvent event) { + public void onKeyEvent() { if(Key.ESCAPE.isPressed() && autoDecompActive) { stopDecomp(); } else if (VersionisedBridge.getSharedInstance().allKeysPressed(Addon.getSharedInstance().configuration().getAutoCrafterConfig().getAutoDecompHotkey().get())) { @@ -120,8 +119,8 @@ private void decomp() { } } } else { - if (VersionisedBridge.canSendCommand()) { - VersionisedBridge.sendCommand("/craft"); + if (Addon.canSendCommand()) { + Addon.sendCommand("/craft"); } } } diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoHopper.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoHopper.java index 7982dfc..368d394 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoHopper.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoHopper.java @@ -3,7 +3,6 @@ import net.labymod.api.event.client.chat.ChatReceiveEvent; import net.labymod.api.event.client.input.MouseButtonEvent; import net.labymod.api.event.client.input.MouseButtonEvent.Action; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.minecraft.block.Block; import net.minecraft.block.BlockHopper; import net.minecraft.client.Minecraft; @@ -59,7 +58,7 @@ public void run() { ); } } - public void tick(GameTickEvent event) { + public void tick() { if(Addon.getSharedInstance().configuration().getHopperSubConfig().getEnabled().get()) { Container cont = Minecraft.getMinecraft().thePlayer.openContainer; if (cont instanceof ContainerChest chest) { @@ -112,7 +111,7 @@ public void tick(GameTickEvent event) { if(!clicked && Addon.getSharedInstance().configuration().getHopperSubConfig().getStackSize().get() != HopperItemStackSizeEnum.NONE && chest.inventorySlots.get(10).getHasStack()) { int currentStackSize = chest.getSlot(10).getStack().stackSize; switch (Addon.getSharedInstance().configuration().getHopperSubConfig().getStackSize().get()) { - case SINGLE_ITEM: + case SINGLEITEM: if(currentStackSize != 1) { ClickManager.getSharedInstance().addClick(QueueType.MEDIUM, new Click(chest.windowId, 10, 0, 1)); clicked = true; @@ -124,7 +123,7 @@ public void tick(GameTickEvent event) { clicked = true; } break; - case FULL_STACK: + case FULLSTACK: if(currentStackSize != 64) { ClickManager.getSharedInstance().addClick(QueueType.MEDIUM, new Click(chest.windowId, 10, 0, 1)); clicked = true; @@ -138,13 +137,13 @@ public void tick(GameTickEvent event) { Minecraft.getMinecraft().thePlayer.closeScreen(); } else if (Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.CONNECT) { ClickManager.getSharedInstance().addClick(QueueType.MEDIUM, new Click(chest.windowId, 16, 0, 0)); - } else if (Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.MULTI_CONNECTION) { + } else if (Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.MULTICONNECTION) { ClickManager.getSharedInstance().addClick(QueueType.MEDIUM, new Click(chest.windowId, 15, 0, 0)); } } } - } else if (inv.getName().equalsIgnoreCase("§6Trichter-Mehrfach-Verbindungen") && ClickManager.getSharedInstance().isClickQueueEmpty(QueueType.MEDIUM) && Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.MULTI_CONNECTION) { + } else if (inv.getName().equalsIgnoreCase("§6Trichter-Mehrfach-Verbindungen") && ClickManager.getSharedInstance().isClickQueueEmpty(QueueType.MEDIUM) && Addon.getSharedInstance().configuration().getHopperSubConfig().getFinalAction().get() == HopperFinalAction.MULTICONNECTION) { ClickManager.getSharedInstance().addClick( QueueType.MEDIUM, new Click(chest.windowId, 53, 0, 0)); } diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoLoot.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoLoot.java index cc728eb..cf504da 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoLoot.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/AutoLoot.java @@ -19,7 +19,8 @@ public void chatMessageReceived(ChatReceiveEvent event) { String message = event.chatMessage().getPlainText(); if(Addon.getSharedInstance().configuration().getAutoLoot().get()) { - if(CBtracker.getCurrentCB() != CBs.NONE && message.equals("[Switcher] Daten heruntergeladen!") && !Addon.getSharedInstance().getPlayerTracer().isTracerActive()) { + if(CBtracker.getCurrentCB() != CBs.NONE && message.equals("[Switcher] Daten heruntergeladen!") && Addon.getSharedInstance() + .getPlayerTracer().isTracerDisabled()) { String rank = getPlayerRank(Laby.labyAPI().getName()); int periodSkull = getTimePeriodForFreeSkull(rank); @@ -37,13 +38,13 @@ public void run() { if(CBtracker.isPlotworldCB() && Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().theWorld != null) { - Object freeBooster = FileManager.getValue("freeBooster"); + Object freeBooster = FileManager.getPlayerValue("freeBooster"); String freeBoosterString = freeBooster instanceof String ? (String) freeBooster : ""; - Object freeChest = FileManager.getValue("freeChest"); + Object freeChest = FileManager.getPlayerValue("freeChest"); String freeChestString = freeChest instanceof String ? (String) freeChest : ""; - Object freeSkull = FileManager.getValue("freeSkull"); + Object freeSkull = FileManager.getPlayerValue("freeSkull"); String freeSkullString = freeSkull instanceof String ? (String) freeSkull : ""; if(periodChest > -1) { @@ -85,26 +86,26 @@ public void run() { if(message.startsWith("[CaseOpening] Du kannst erst am ") && message.endsWith(" wieder Free-Kisten abholen.")) { event.setCancelled(true); String isolatedDate = message.replace("[CaseOpening] Du kannst erst am ", "").replace(" wieder Free-Kisten abholen.", ""); - FileManager.setValue("freeChest", stringToDate(isolatedDate).toString()); + FileManager.setPlayerValue("freeChest", stringToDate(isolatedDate).toString()); } else if(message.startsWith("Du kannst erst am ") && message.endsWith(" wieder einen Free-Booster abholen.")) { event.setCancelled(true); String isolatedDate = message.replace("Du kannst erst am ", "").replace(" wieder einen Free-Booster abholen.", ""); - FileManager.setValue("freeBooster", stringToDate(isolatedDate).toString()); + FileManager.setPlayerValue("freeBooster", stringToDate(isolatedDate).toString()); } else if(message.equals("[CaseOpening] Du hast 2 Kisten erhalten.")) { String rank = getPlayerRank(Laby.labyAPI().getName()); int periodChest = getTimePeriodForFreeChest(rank); if(periodChest > -1) - FileManager.setValue("freeChest", LocalDateTime.now().plusDays(periodChest).toString()); + FileManager.setPlayerValue("freeChest", LocalDateTime.now().plusDays(periodChest).toString()); } else if(message.startsWith("Du hast 1 ") && message.endsWith("-Booster erhalten. Danke für deine Unterstützung von GrieferGames!")) { String rank = getPlayerRank(Laby.labyAPI().getName()); int periodChest = getTimePeriodForFreeChest(rank); if(periodChest > -1) - FileManager.setValue("freeBooster", LocalDateTime.now().plusDays(periodChest).toString()); + FileManager.setPlayerValue("freeBooster", LocalDateTime.now().plusDays(periodChest).toString()); } else if(message.startsWith("[Kopf] Du hast einen ") && message.endsWith("-Kopf erhalten!")) { String rank = getPlayerRank(Laby.labyAPI().getName()); int periodSkull = getTimePeriodForFreeSkull(rank); if(periodSkull > -1) - FileManager.setValue("freeSkull", LocalDateTime.now().plusDays(periodSkull).toString()); + FileManager.setPlayerValue("freeSkull", LocalDateTime.now().plusDays(periodSkull).toString()); } } } diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/Auswurf.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/Eject.java similarity index 87% rename from game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/Auswurf.java rename to game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/Eject.java index 7b6c03e..b221e0e 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/Auswurf.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/Eject.java @@ -3,13 +3,10 @@ import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.input.KeyEvent.State; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.util.I18n; import net.minecraft.block.BlockChest; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; @@ -20,11 +17,11 @@ import tmb.randy.tmbgriefergames.core.enums.QueueType; import tmb.randy.tmbgriefergames.v1_8_9.util.click.ClickManager; -public class Auswurf { +public class Eject { private boolean active; private BlockPos chestPos; - public void onTickEvent(GameTickEvent event) { + public void onTickEvent() { if(active && Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().theWorld != null) { if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest chest) { IInventory inv = chest.getLowerChestInventory(); @@ -87,14 +84,4 @@ private static BlockPos getChestPos() { return null; } - - private static Entity getEntityInBlockPos(BlockPos pos) { - Minecraft mc = Minecraft.getMinecraft(); - for (Entity entity : mc.theWorld.loadedEntityList) { - if (entity instanceof EntityLivingBase && entity.getDistanceSq(pos) < 2) { - return entity; - } - } - return null; - } } diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/FlyTimer.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/FlyTimer.java index d0df337..a142920 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/FlyTimer.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/FlyTimer.java @@ -5,7 +5,6 @@ import net.labymod.api.client.world.item.ItemStack; import net.labymod.api.event.client.input.MouseButtonEvent; import net.labymod.api.event.client.input.MouseButtonEvent.Action; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.labymod.api.event.client.world.ItemStackTooltipEvent; import net.labymod.api.util.I18n; import net.minecraft.client.Minecraft; @@ -19,7 +18,7 @@ public class FlyTimer { Date totalDurationTime; - public void tick(GameTickEvent event) { + public void tick() { if (totalDurationTime != null) { if (getRemainingTotalTimeSeconds() < 0L) { totalDurationTime = null; diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/HopperConnections.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/HopperConnections.java index 147ad0b..8b138ef 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/HopperConnections.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/HopperConnections.java @@ -1,7 +1,10 @@ package tmb.randy.tmbgriefergames.v1_8_9.util; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; import net.labymod.api.event.client.chat.ChatReceiveEvent; -import net.labymod.api.event.client.render.world.RenderWorldEvent; import net.labymod.api.nbt.NBTTagType; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -19,13 +22,7 @@ import tmb.randy.tmbgriefergames.core.CBtracker; import tmb.randy.tmbgriefergames.core.enums.CBs; import tmb.randy.tmbgriefergames.core.enums.HopperState; -import tmb.randy.tmbgriefergames.core.events.CbChangedEvent; import tmb.randy.tmbgriefergames.core.events.HopperStateChangedEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; public class HopperConnections { @@ -177,35 +174,32 @@ public void messageReceived(ChatReceiveEvent event) { } } - public void cbChanged(CbChangedEvent event) { + public void cbChanged() { currentConnectingHopper = null; } - public void renderWorld(RenderWorldEvent event) { - Iterator> iterator = conntections.entrySet().iterator(); + public void renderWorld() { - while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); + for (Entry entry : conntections.entrySet()) { HopperConnection conntection = entry.getValue(); - double distance = conntection.pos1.distanceSq(Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posY, Minecraft.getMinecraft().thePlayer.posZ); + double distance = conntection.pos1.distanceSq(Minecraft.getMinecraft().thePlayer.posX, + Minecraft.getMinecraft().thePlayer.posY, Minecraft.getMinecraft().thePlayer.posZ); double actualDistance = Math.sqrt(distance); - if(actualDistance > 30) + if (actualDistance > 30) continue; if (conntection.cb == CBtracker.getCurrentCB()) { - if (Minecraft.getMinecraft().theWorld.getBlockState(conntection.pos1()).getBlock() == Blocks.hopper) { + if (Minecraft.getMinecraft().theWorld.getBlockState(conntection.pos1()).getBlock() + == Blocks.hopper) { drawLineBetween(conntection); - } else { - iterator.remove(); } } } - if(currentConnectingHopper != null) { - drawSphere(currentConnectingHopper, 30.0d, event.getPartialTicks()); + drawSphere(currentConnectingHopper); } } @@ -292,7 +286,7 @@ private void renderItemStackAt(ItemStack stack, double x, double y, double z) { GlStateManager.popMatrix(); } - private void drawSphere(BlockPos center, double radius, float partialTicks) { + private void drawSphere(BlockPos center) { if(!Addon.getSharedInstance().configuration().getHopperSubConfig().getShowRadius().get()) return; @@ -319,13 +313,13 @@ private void drawSphere(BlockPos center, double radius, float partialTicks) { for (double theta = 0; theta < Math.PI * 2; theta += step) { for (double phi = 0; phi < Math.PI; phi += step) { - double x1 = radius * Math.sin(phi) * Math.cos(theta); - double z1 = radius * Math.sin(phi) * Math.sin(theta); - double y1 = radius * Math.cos(phi); + double x1 = 30.0 * Math.sin(phi) * Math.cos(theta); + double z1 = 30.0 * Math.sin(phi) * Math.sin(theta); + double y1 = 30.0 * Math.cos(phi); - double x2 = radius * Math.sin(phi + step) * Math.cos(theta); - double z2 = radius * Math.sin(phi + step) * Math.sin(theta); - double y2 = radius * Math.cos(phi + step); + double x2 = 30.0 * Math.sin(phi + step) * Math.cos(theta); + double z2 = 30.0 * Math.sin(phi + step) * Math.sin(theta); + double y2 = 30.0 * Math.cos(phi + step); GL11.glVertex3d(x1, y1, z1); GL11.glVertex3d(x2, y2, z2); @@ -334,13 +328,13 @@ private void drawSphere(BlockPos center, double radius, float partialTicks) { for (double theta = 0; theta < Math.PI * 2; theta += step) { for (double phi = 0; phi < Math.PI; phi += step) { - double y1 = radius * Math.sin(phi) * Math.cos(theta); - double z1 = radius * Math.sin(phi) * Math.sin(theta); - double x1 = radius * Math.cos(phi); + double y1 = 30.0 * Math.sin(phi) * Math.cos(theta); + double z1 = 30.0 * Math.sin(phi) * Math.sin(theta); + double x1 = 30.0 * Math.cos(phi); - double y2 = radius * Math.sin(phi + step) * Math.cos(theta); - double z2 = radius * Math.sin(phi + step) * Math.sin(theta); - double x2 = radius * Math.cos(phi + step); + double y2 = 30.0 * Math.sin(phi + step) * Math.cos(theta); + double z2 = 30.0 * Math.sin(phi + step) * Math.sin(theta); + double x2 = 30.0 * Math.cos(phi + step); GL11.glVertex3d(x1, y1, z1); GL11.glVertex3d(x2, y2, z2); diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/ItemShifter.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/ItemShifter.java index c78f8a7..64e3f1a 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/ItemShifter.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/ItemShifter.java @@ -3,7 +3,6 @@ import java.util.LinkedList; import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.event.client.input.KeyEvent; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiInventory; @@ -90,7 +89,7 @@ public void startShifting() { depositHeld(fromMin, fromMax, destMin, destMax); int availableSlots = getEmptySlotsInRange(destMin, destMax); - boolean isSpawner = this.checkIfContainerIsSpawner(); + boolean isSpawner = checkIfContainerIsSpawner(); for(int from = fromMin; from <= fromMax; from++) { @@ -117,11 +116,11 @@ public void startShifting() { this.sendQueue(); } - public void tick(GameTickEvent event) { + public void tick() { if((Keyboard.isKeyDown(Key.ARROW_LEFT.getId()) && Keyboard.isKeyDown(Key.ARROW_UP.getId()) && Keyboard.isKeyDown(Key.ARROW_RIGHT.getId())) || !(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest)) return; - if (Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.openContainer != null && Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { ContainerChest chest = ((ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer); IInventory inv = chest.getLowerChestInventory(); @@ -217,11 +216,7 @@ public void setTopToBottom(boolean topToBottom) { } private void sendQueue() { - if(checkIfContainerIsSpawner()) { - ClickManager.getSharedInstance().queueClicks(QueueType.SLOW, toSend); - } else { - ClickManager.getSharedInstance().queueClicks(QueueType.SLOW, toSend); - } + ClickManager.getSharedInstance().queueClicks(QueueType.SLOW, toSend); this.toSend.clear(); } diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/NatureBordersRenderer.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/NatureBordersRenderer.java index 74af761..152e1e0 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/NatureBordersRenderer.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/NatureBordersRenderer.java @@ -1,6 +1,5 @@ package tmb.randy.tmbgriefergames.v1_8_9.util; -import net.labymod.api.event.client.input.KeyEvent; import net.labymod.api.event.client.render.world.RenderWorldEvent; import net.labymod.api.util.Color; import net.labymod.api.util.I18n; @@ -34,8 +33,9 @@ public static double getDistanceSq(double x1, double z1, double x2, double z2) private float lineGreen = 0.0F; private float lineBlue = 0.0F; - public void onKey(KeyEvent event) { - if(VersionisedBridge.getSharedInstance().allKeysPressed(Addon.getSharedInstance().configuration().getNatureSubConfig().getHotkey().get()) && !VersionisedBridge.getSharedInstance().isChatGuiOpen() && CBtracker.isNatureWorldCB()) { + public void onKey() { + if(VersionisedBridge.getSharedInstance().allKeysPressed(Addon.getSharedInstance().configuration().getNatureSubConfig().getHotkey().get()) && VersionisedBridge.getSharedInstance() + .isChatGuiClosed() && CBtracker.isNatureWorldCB()) { Addon.getSharedInstance().configuration().getNatureSubConfig().getShowBorders().set(!Addon.getSharedInstance().configuration().getNatureSubConfig().getShowBorders().get()); String activeString = Addon.getSharedInstance().configuration().getNatureSubConfig().getShowBorders().get() ? I18n.getTranslation("tmbgriefergames.natureBorders.plotBordersVisible") : I18n.getTranslation("tmbgriefergames.natureBorders.plotBordersInvisible"); diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/VABK.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/VABK.java index d2ae370..c8b85fe 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/VABK.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/VABK.java @@ -33,7 +33,8 @@ public void onTickEvent(GameTickEvent event) { } public void onKeyEvent(KeyEvent event) { - if(event.state() == State.PRESS && VersionisedBridge.getSharedInstance().allKeysPressed(Addon.getSharedInstance().configuration().getSwordsSubConfig().getVABKhotkey().get()) && !VersionisedBridge.getSharedInstance().isChatGuiOpen()) { + if(event.state() == State.PRESS && VersionisedBridge.getSharedInstance().allKeysPressed(Addon.getSharedInstance().configuration().getSwordsSubConfig().getVABKhotkey().get()) && VersionisedBridge.getSharedInstance() + .isChatGuiClosed()) { toggleActive(); } } @@ -44,12 +45,6 @@ public void toggleActive() { I18n.getTranslation(active ? "tmbgriefergames.autoSword.enabled" : "tmbgriefergames.autoSword.disabled")); } - public void stop() { - if(active) { - toggleActive(); - } - } - private void startUsingBow() { if(Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().theWorld == null) return; diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/VersionisedBridge.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/VersionisedBridge.java index 1d0f25f..441e23e 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/VersionisedBridge.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/VersionisedBridge.java @@ -1,5 +1,6 @@ package tmb.randy.tmbgriefergames.v1_8_9.util; +import javax.inject.Singleton; import net.labymod.api.Laby; import net.labymod.api.client.gui.screen.activity.types.IngameOverlayActivity; import net.labymod.api.client.gui.screen.key.Key; @@ -23,14 +24,12 @@ import org.lwjgl.input.Keyboard; import tmb.randy.tmbgriefergames.core.Addon; import tmb.randy.tmbgriefergames.core.IBridge; -import tmb.randy.tmbgriefergames.core.enums.CBs; import tmb.randy.tmbgriefergames.core.events.CbChangedEvent; import tmb.randy.tmbgriefergames.core.events.HopperStateChangedEvent; import tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV1; import tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV2; import tmb.randy.tmbgriefergames.v1_8_9.util.AutoCrafter.AutoCrafterV3; import tmb.randy.tmbgriefergames.v1_8_9.util.click.ClickManager; -import javax.inject.Singleton; @Singleton @Implements(IBridge.class) @@ -46,7 +45,7 @@ public class VersionisedBridge implements IBridge { private final AutoCrafterV3 autoCrafterV3 = new AutoCrafterV3(); private final AutoDecomp autoDecomp = new AutoDecomp(); private final AutoComp autoComp = new AutoComp(); - private final Auswurf auswurf = new Auswurf(); + private final Eject auswurf = new Eject(); private final HABK habk = new HABK(); private final VABK vabk = new VABK(); private final HopperConnections hopperConnections = new HopperConnections(); @@ -54,23 +53,19 @@ public class VersionisedBridge implements IBridge { private GuiScreen lastGui; - private static final int commandCountdownLimit = 80; - private static int commandCountdown = 0; - public VersionisedBridge() { sharedInstance = this; } @Subscribe public void cbChanged(CbChangedEvent event) { + if(!Addon.isGG()) + return; + autoComp.stopComp(); autoCrafterV2.stopCrafter(); autoCrafterV3.stop(); - hopperConnections.cbChanged(event); - - if(event.CB() == CBs.LOBBY && Addon.getSharedInstance().configuration().getSkipHub().get()) { - VersionisedBridge.sendCommand("/portal"); - } + hopperConnections.cbChanged(); } @Subscribe @@ -106,7 +101,7 @@ public void onScoreboardRender(IngameOverlayElementRenderEvent event) { @Subscribe public void tick(GameTickEvent event) { - if(!Laby.labyAPI().minecraft().isIngame() || Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().theWorld == null) + if(!Laby.labyAPI().minecraft().isIngame() || Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().theWorld == null || !Addon.isGG()) return; GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen; @@ -124,22 +119,24 @@ public void tick(GameTickEvent event) { lastGui = currentScreen; } - ClickManager.getSharedInstance().tick(event); - autoComp.onTickEvent(event); - autoCrafterV1.onTickEvent(event); - autoHopper.tick(event); - itemShifter.tick(event); + ClickManager.getSharedInstance().tick(); + autoComp.onTickEvent(); + autoCrafterV1.onTickEvent(); + autoHopper.tick(); + itemShifter.tick(); autoCrafterV2.onTickEvent(event); autoDecomp.onTickEvent(event); - auswurf.onTickEvent(event); - autoCrafterV3.onTick(event); + auswurf.onTickEvent(); + autoCrafterV3.onTick(); vabk.onTickEvent(event); - - commandCountdown(); + flyTimer.tick(); } @Subscribe public void hopperStateChanged(HopperStateChangedEvent event) { + if(!Addon.isGG()) + return; + hopperConnections.hopperStateChanged(event); } @@ -149,11 +146,11 @@ public void keyDown(KeyEvent event) { return; itemShifter.onKey(event); - natureBordersRenderer.onKey(event); + natureBordersRenderer.onKey(); autoComp.onKeyEvent(event); autoCrafterV1.onKeyEvent(event); autoCrafterV2.onKeyEvent(event); - autoDecomp.onKeyEvent(event); + autoDecomp.onKeyEvent(); auswurf.onKeyEvent(event); autoCrafterV3.onKey(event); vabk.onKeyEvent(event); @@ -165,7 +162,7 @@ public void onRenderEvent(RenderWorldEvent event) { return; natureBordersRenderer.onRender(event); - hopperConnections.renderWorld(event); + hopperConnections.renderWorld(); } @Subscribe @@ -183,9 +180,8 @@ public void onGuiOpenEvent(GuiScreen screen) { if(screen == null) { autoComp.stopComp(); itemShifter.stopShifting(); - } else { + } else hopperConnections.onGuiOpenEvent(); - } } @Override @@ -216,31 +212,15 @@ public void startAutocrafterV3() { autoCrafterV3.toggle(); } - private static void commandCountdown() { - if (commandCountdown > 0) { - commandCountdown--; - } - } - - public static boolean canSendCommand() { return commandCountdown <= 0; } - public static boolean sendCommand(String command) { - if(canSendCommand()) { - Laby.references().chatExecutor().chat(command); - commandCountdown = commandCountdownLimit; - return true; - } - return false; - } - @Override - public boolean isChatGuiOpen() { + public boolean isChatGuiClosed() { for (IngameOverlayActivity activity : Laby.labyAPI().ingameOverlay().getActivities()) { if(activity.isAcceptingInput()) { - return true; + return false; } } - return false; + return true; } public static boolean isGUIOpen() { diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/click/ClickManager.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/click/ClickManager.java index 824bbb3..6dcffeb 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/click/ClickManager.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/click/ClickManager.java @@ -3,11 +3,9 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.minecraft.client.Minecraft; import net.minecraft.inventory.Container; import net.minecraft.item.Item; -import net.minecraft.world.World; import tmb.randy.tmbgriefergames.core.enums.QueueType; public class ClickManager { @@ -21,9 +19,9 @@ private ClickManager() { queues.put(QueueType.FAST, new ClickQueue(QueueType.FAST)); } - public void tick(GameTickEvent event) { + public void tick() { for (Map.Entry entry : queues.entrySet()) { - entry.getValue().tick(event); + entry.getValue().tick(); } } @@ -34,10 +32,6 @@ public static ClickManager getSharedInstance() { return SharedInstance; } - public void rightClick(World world) { - Minecraft.getMinecraft().thePlayer.getHeldItem().useItemRightClick(world, Minecraft.getMinecraft().thePlayer); - } - public void dropInventory() { Container container = Minecraft.getMinecraft().thePlayer.openContainer; int size = container.inventorySlots.size(); @@ -49,21 +43,6 @@ public void dropInventory() { } } - public void dropItemsFromInventory(Item item, boolean skipFirst) { - Container container = Minecraft.getMinecraft().thePlayer.openContainer; - int size = container.inventorySlots.size(); - for(int i = 9; i < size; i++) { - if(container.getSlot(i).getHasStack()) { - if(container.getSlot(i).getStack().getItem().equals(item)) { - if(skipFirst && i == 36) { - continue; - } - dropClick(i); - } - } - } - } - public void dropItemsFromInventory(Item item, int metadata, boolean skipFirst) { Container container = Minecraft.getMinecraft().thePlayer.openContainer; int size = container.inventorySlots.size(); @@ -84,10 +63,6 @@ public void queueClicks(QueueType queueType, LinkedList queue) queues.get(queueType).queueClicks(queue); } - public void clearQueue(QueueType queue) { - queues.get(queue).clearQueue(); - } - public void clearAllQueues() { for (Map.Entry entry : queues.entrySet()) { entry.getValue().clearQueue(); diff --git a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/click/ClickQueue.java b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/click/ClickQueue.java index feddf24..c3614a4 100644 --- a/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/click/ClickQueue.java +++ b/game-runner/src/v1_8_9/java/tmb/randy/tmbgriefergames/v1_8_9/util/click/ClickQueue.java @@ -1,7 +1,6 @@ package tmb.randy.tmbgriefergames.v1_8_9.util.click; import java.util.LinkedList; -import net.labymod.api.event.client.lifecycle.GameTickEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiCrafting; @@ -11,9 +10,7 @@ public class ClickQueue { private final LinkedList clickQueue = new LinkedList<>(); private int clickCooldownCounter = 0; - private int clickSpeed; - - private ClickQueue() {} + private final int clickSpeed; public ClickQueue(QueueType type) { clickSpeed = switch (type) { @@ -23,7 +20,7 @@ public ClickQueue(QueueType type) { }; } - public void tick(GameTickEvent event) { + public void tick() { while (!this.clickQueue.isEmpty() && this.clickCooldownCounter <= 0) { if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest @@ -45,16 +42,6 @@ public void tick(GameTickEvent event) { } } - private void dropClick(int slot) - { - this.clickQueue.addLast(new Click(Minecraft.getMinecraft().thePlayer.openContainer.windowId, slot, 0, 0)); - this.clickQueue.addLast(new Click(Minecraft.getMinecraft().thePlayer.openContainer.windowId, -999, 0, 0)); - } - - private void shiftClick(int slot) { - this.clickQueue.add(new Click(Minecraft.getMinecraft().thePlayer.openContainer.windowId, slot, 0, 1)); - } - public void add(Click click) { this.clickQueue.add(click); }