some changes i dont remember

This commit is contained in:
Christoph J. Scherr 2023-04-16 17:37:52 +02:00
parent fb7a320d02
commit c2d643ae95
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
8 changed files with 78 additions and 32 deletions

View File

@ -78,3 +78,7 @@ publishing {
// retrieving dependencies. // retrieving dependencies.
} }
} }
loom {
log4jConfigs.from(file("log4j-dev.xml"))
}

11
log4j-dev.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration name="Dev">
<Loggers>
<Logger name="de.cscherr.plextool" level="trace" additivity="false">
<AppenderRef ref="DebugFile" level="${sys:fabric.log.debug.level:-debug}" />
<AppenderRef ref="SysOut" />
<AppenderRef ref="LatestFile" level="${sys:fabric.log.level:-info}" />
<AppenderRef ref="ServerGuiConsole" />
</Logger>
</Loggers>
</Configuration>

View File

@ -3,13 +3,16 @@ package de.cscherr.plextool;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactoryFriend;
import org.slf4j.event.Level;
import org.slf4j.spi.LoggingEventBuilder;
public class PlexTool implements ModInitializer { public class PlexTool implements ModInitializer {
// This logger is used to write text to the console and the log file. // This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name. // It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors. // That way, it's clear which mod wrote info, warnings, and errors.
public static final String MOD_ID = "PlexTool"; public static final String MOD_ID = "PlexTool";
public static final String VERSION_NUMBER = "0.1.0"; public static final String VERSION_NUMBER = "0.1.1";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
@Override @Override
@ -18,6 +21,7 @@ public class PlexTool implements ModInitializer {
// However, some things (like resources) may still be uninitialized. // However, some things (like resources) may still be uninitialized.
// Proceed with mild caution. // Proceed with mild caution.
LOGGER.debug("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
LOGGER.info("Initializing PlexTool"); LOGGER.info("Initializing PlexTool");
} }
} }

View File

@ -9,35 +9,48 @@ import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import net.minecraft.client.gui.widget.ButtonWidget;
import org.slf4j.event.Level;
public class PlexToolUiScreen extends Screen { public class PlexToolUiScreen extends Screen {
private static final Logger LOGGER = LoggerFactory.getLogger(PlexToolUiScreen.class.getSimpleName()); private static final Logger LOGGER = PlexTool.LOGGER;
private static final Text INFO_TEXT = Text.literal("Hello world"); private static final Text INFO_TEXT = Text.literal("Hello world");
private final Screen parent; private final Screen parent;
private ButtonWidget doneButton;
private ButtonWidget dummyButton;
public PlexToolUiScreen(String name, Screen parent) { public PlexToolUiScreen(Text name, Screen parent) {
super(Text.literal(name)); super(name);
LOGGER.trace("Constructing the UI, call to super is done");
this.parent = parent; this.parent = parent;
LOGGER.info("Constructed the UI"); LOGGER.info("Constructed the UI Screen");
}
public PlexToolUiScreen(Text name) {
super(name);
LOGGER.trace("Constructing the UI, call to super is done");
this.parent = null;
LOGGER.info("Constructed the UI Screen without a parent");
} }
@Override @Override
protected void init() { protected void init() {
//assert this.client != null; LOGGER.trace(PlexToolUiScreen.class.getSimpleName() + " init started");
//Window window = this.client.getWindow();
//Monitor monitor = window.getMonitor();
this.addDrawable(ButtonWidget.builder(INFO_TEXT, button -> { dummyButton = ButtonWidget.builder(Text.literal("Dummy"), b -> apply()).build();
LOGGER.info("Pressed dummy button"); doneButton = ButtonWidget.builder(Text.literal("Done"), b -> apply()).build();
}).dimensions(this.width / 2 - 100, this.height - 10, 200, 20).build());
//this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, button -> { this.addDrawableChild(doneButton);
// this.client.options.write();
// this.apply(); LOGGER.info(PlexToolUiScreen.class.getSimpleName() + " init finished");
// this.client.setScreen(this.parent);
//}).dimensions(this.width / 2 - 100, this.height - 27, 200, 20).build());
} }
private void apply() { private void apply() {
LOGGER.trace("applying PlexToolUI Options, not implemented");
// return to the parent screen, should be OptionsScreen
assert client != null;
client.setScreen(parent);
this.close();
} }
} }

View File

@ -1,5 +1,6 @@
package de.cscherr.plextool.mixin; package de.cscherr.plextool.mixin;
import de.cscherr.plextool.PlexTool;
import net.minecraft.network.ClientConnection; import net.minecraft.network.ClientConnection;
import net.minecraft.network.PacketCallbacks; import net.minecraft.network.PacketCallbacks;
import net.minecraft.network.listener.PacketListener; import net.minecraft.network.listener.PacketListener;
@ -42,7 +43,7 @@ public class PlexToolMixin {
@Mixin(ClientConnection.class) @Mixin(ClientConnection.class)
public class PlexToolPackets { public class PlexToolPackets {
private static final Logger LOGGER = LoggerFactory.getLogger("PlexToolMixin"); private static final Logger LOGGER = PlexTool.LOGGER;
private static boolean logSent = true; private static boolean logSent = true;
private static boolean logReceived = false; private static boolean logReceived = false;

View File

@ -1,23 +1,22 @@
package de.cscherr.plextool.mixin; package de.cscherr.plextool.mixin;
import de.cscherr.plextool.PlexTool;
import de.cscherr.plextool.PlexToolUiScreen; import de.cscherr.plextool.PlexToolUiScreen;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen; import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.Monitor;
import net.minecraft.client.util.Window;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(OptionsScreen.class) @Mixin(OptionsScreen.class)
public abstract class PlexToolUIMixin extends Screen { public abstract class PlexToolUIMixin extends Screen {
private static final Text PLEXTOOL_TEXT = Text.literal("PlexTool"); private static final Text PLEXTOOL_TEXT = Text.literal("PlexTool");
private static final Logger LOGGER = LoggerFactory.getLogger(PlexToolUIMixin.class.getSimpleName()); private static final Logger LOGGER = PlexTool.LOGGER;
protected PlexToolUIMixin(Text title) { protected PlexToolUIMixin(Text title) {
super(title); super(title);
@ -25,9 +24,14 @@ public abstract class PlexToolUIMixin extends Screen {
@Inject(method = "init", at = @At("RETURN")) @Inject(method = "init", at = @At("RETURN"))
private void init(CallbackInfo callback) { private void init(CallbackInfo callback) {
addDrawable(ButtonWidget.builder(Text.literal("PT"), button -> { ButtonWidget plexToolButton = ButtonWidget.builder(PLEXTOOL_TEXT, button -> {
LOGGER.info("Opening PlexToolUiScreen");
assert client != null; assert client != null;
client.setScreen(new PlexToolUiScreen(PLEXTOOL_TEXT.getString(), (OptionsScreen)(Object)this)); PlexToolUiScreen plexToolUiScreen = new PlexToolUiScreen(PLEXTOOL_TEXT, (OptionsScreen)(Object)this);
}).position(this.width / 2 - 180, this.height / 6 + 120 - 6).size(20, 20).build()); client.setScreen(plexToolUiScreen);
}).build();
this.addDrawable(plexToolButton);
LOGGER.info(PlexToolUIMixin.class.getSimpleName() + " init finished");
} }
} }

View File

@ -1,19 +1,28 @@
{ {
"schemaVersion": 1, "schemaVersion": 1,
"id": "plextool", "id": "plextool",
"version": "0.1.0", "version": "0.1.1",
"name": "PlexSheeps tool mod", "name": "PlexSheep Utilities mod",
"description": "Some of these might be considered hacking tools.", "description": "This mod contains some technical tools used by PlexSheep while playing Minecraft. Some of these might be considered hacking tools.",
"authors": [ "authors": [
"Plexsheep <software@cscherr.de>" {
"name": "Christoph J. Scherr",
"contact": {
"email": "software@cscherr.de",
"homepage": "https://www.cscherr.de",
"issues": "https://github.com/PlexSheep/PlexTool/issues",
"sources": "https://hithub.com/PlexSheep/PlexTool"
}
}
], ],
"contact": { "contact": {
"homepage": "https://www.cscherr.de/", "email": "software@cscherr.de",
"sources": "https://github.com/FabricMC/fabric-example-mod" "homepage": "https://www.cscherr.de",
"issues": "https://github.com/PlexSheep/PlexTool/issues",
"sources": "https://hithub.com/PlexSheep/PlexTool"
}, },
"license": "MIT",
"license": "CC0-1.0",
"icon": "assets/modid/icon.png", "icon": "assets/modid/icon.png",
"environment": "*", "environment": "*",

View File