generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
300 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.github.zly2006.reden | ||
|
||
import com.github.zly2006.reden.debugger.breakpoint.breakpoints | ||
import com.github.zly2006.reden.network.Rollback | ||
import com.github.zly2006.reden.network.TagBlockPos | ||
import com.github.zly2006.reden.network.TntSyncPacket | ||
import com.github.zly2006.reden.pearl.pearlTask | ||
import com.github.zly2006.reden.render.BlockBorder | ||
import com.github.zly2006.reden.utils.debugLogger | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking | ||
import net.minecraft.text.Text | ||
|
||
fun init() { | ||
ClientPlayNetworking.registerGlobalReceiver(Rollback.pType) { packet, player, res -> | ||
player.sendMessage( | ||
when (packet.status) { | ||
0 -> Text.literal("[Reden/Undo] Rollback success") | ||
1 -> Text.literal("[Reden/Undo] Restore success") | ||
2 -> Text.literal("[Reden/Undo] No blocks info") | ||
16 -> Text.literal("[Reden/Undo] No permission") | ||
32 -> Text.literal("[Reden/Undo] Not recording") | ||
65536 -> Text.literal("[Reden/Undo] Unknown error") | ||
else -> Text.literal("[Reden/Undo] Unknown status") | ||
} | ||
) | ||
} | ||
|
||
ClientPlayConnectionEvents.DISCONNECT.register { _, _ -> | ||
breakpoints.clear() | ||
} | ||
|
||
ClientPlayNetworking.registerGlobalReceiver(TntSyncPacket.pType) { packet, client, _ -> | ||
pearlTask?.onTntSyncPacket(packet) | ||
debugLogger("TntSyncPacket: TNT${packet.tntPower} @ ${packet.tntPos}") | ||
} | ||
|
||
ClientPlayConnectionEvents.DISCONNECT.register { _, _ -> BlockBorder.tags.clear()} | ||
ClientPlayNetworking.registerGlobalReceiver(TagBlockPos.pType) { packet, _, _ -> | ||
BlockBorder.tags[packet.pos.asLong()] = packet.status | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.github.zly2006.reden; | ||
|
||
import com.github.zly2006.reden.malilib.KeyCallbacksKt; | ||
import com.github.zly2006.reden.malilib.MalilibSettingsKt; | ||
import com.github.zly2006.reden.pearl.PearlTask; | ||
import com.github.zly2006.reden.report.ClientReportKt; | ||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import com.google.gson.JsonObject; | ||
import fi.dy.masa.malilib.config.ConfigManager; | ||
import fi.dy.masa.malilib.config.ConfigUtils; | ||
import fi.dy.masa.malilib.config.IConfigHandler; | ||
import fi.dy.masa.malilib.event.InitializationHandler; | ||
import fi.dy.masa.malilib.event.InputEventHandler; | ||
import fi.dy.masa.malilib.hotkeys.IHotkey; | ||
import fi.dy.masa.malilib.hotkeys.IKeybindManager; | ||
import fi.dy.masa.malilib.hotkeys.IKeybindProvider; | ||
import fi.dy.masa.malilib.util.FileUtils; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.minecraft.client.MinecraftClient; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
import static com.github.zly2006.reden.Reden.MOD_NAME; | ||
|
||
public class RedenClient implements ClientModInitializer { | ||
public static final String CONFIG_FILE = "reden.json"; | ||
public static final Logger LOGGER = LoggerFactory.getLogger("reden"); | ||
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); | ||
@Override | ||
public void onInitializeClient() { | ||
ClientReportKt.initReport(); | ||
PearlTask.Companion.register(); | ||
InitializationHandler.getInstance().registerInitializationHandler(() -> { | ||
ConfigManager.getInstance().registerConfigHandler("reden", new IConfigHandler() { | ||
@Override | ||
public void load() { | ||
try { | ||
File file = new File(FileUtils.getConfigDirectory(), CONFIG_FILE); | ||
if (!file.exists()) { | ||
return; | ||
} | ||
JsonObject jo = GSON.fromJson(Files.readString(file.toPath()), JsonObject.class); | ||
ConfigUtils.readConfigBase(jo, MOD_NAME, MalilibSettingsKt.getAllOptions()); | ||
} catch (IOException e) { | ||
save(); | ||
} | ||
} | ||
|
||
@Override | ||
public void save() { | ||
JsonObject jo = new JsonObject(); | ||
ConfigUtils.writeConfigBase(jo, MOD_NAME, MalilibSettingsKt.getAllOptions()); | ||
try { | ||
Files.writeString(new File(FileUtils.getConfigDirectory(), CONFIG_FILE).toPath(), GSON.toJson(jo)); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
}); | ||
InputEventHandler.getKeybindManager().registerKeybindProvider(new IKeybindProvider() { | ||
@Override | ||
public void addKeysToMap(IKeybindManager iKeybindManager) { | ||
MalilibSettingsKt.HOTKEYS.stream() | ||
.map(IHotkey::getKeybind) | ||
.forEach(iKeybindManager::addKeybindToMap); | ||
} | ||
|
||
@Override | ||
public void addHotkeys(IKeybindManager iKeybindManager) { | ||
iKeybindManager.addHotkeysForCategory("Reden", "reden.hotkeys.category.generic_hotkeys", MalilibSettingsKt.HOTKEYS); | ||
} | ||
}); | ||
KeyCallbacksKt.configureKeyCallbacks(MinecraftClient.getInstance()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ly2006/reden/mixin/chat/ChatHudMixin.java → ...reden/mixin/client/chat/ChatHudMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...n/mixin/chat/VisibleChatHudLineMixin.java → .../client/chat/VisibleChatHudLineMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...orceSyncEntityPos/MixinClientNetwork.java → ...orceSyncEntityPos/MixinClientNetwork.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../fix/forceSyncEntityPos/MixinTracker.java → ...ient/forceSyncEntityPos/MixinTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...orceSyncEntityPos/MixinWorldRenderer.java → ...orceSyncEntityPos/MixinWorldRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mixin/render/MixinBlockModelRenderer.java → ...lient/render/MixinBlockModelRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...eden/mixin/render/MixinWorldRenderer.java → ...xin/client/render/MixinWorldRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
src/client/java/com/github/zly2006/reden/utils/ClientUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.github.zly2006.reden.utils | ||
|
||
import net.minecraft.client.gui.widget.ButtonWidget | ||
import net.minecraft.text.Text | ||
|
||
|
||
fun buttonWidget(x: Int, y: Int, width: Int, height: Int, message: Text, onPress: ButtonWidget.PressAction) = | ||
ButtonWidget(x, y, width, height, message, onPress) { it.get() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "com.github.zly2006.reden.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"client": [ | ||
"client.chat.ChatHudMixin", | ||
"client.chat.ChatScreenMixin", | ||
"client.chat.VisibleChatHudLineMixin", | ||
"client.forceSyncEntityPos.MixinClientNetwork", | ||
"client.forceSyncEntityPos.MixinWorldRenderer", | ||
"client.render.MixinBlockModelRenderer", | ||
"client.render.MixinChunkRebuildTask", | ||
"client.render.MixinWorldRenderer", | ||
"fix.NoTimeOut", | ||
"fix.forceSyncEntityPos.MixinWorldRenderer", | ||
"render.MixinBlockModelRenderer", | ||
"render.MixinChunkRebuildTask", | ||
"render.MixinWorldRenderer" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
}, | ||
"mixins": [ | ||
"client.forceSyncEntityPos.MixinTracker" | ||
] | ||
} |
Oops, something went wrong.