Skip to content

Commit

Permalink
Support Minecraft 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
vacla committed Nov 11, 2024
1 parent d6df221 commit ce66c1c
Show file tree
Hide file tree
Showing 40 changed files with 1,411 additions and 728 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.15.6+1.20.6] - 2024-11-11

### Added

- Support Minecraft 1.20.6

## [1.15.5+1.20.4] - 2024-06-21

### Added
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import groovy.json.JsonSlurper

plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
id 'com.modrinth.minotaur' version '2.+'
}
Expand Down Expand Up @@ -55,8 +55,8 @@ processResources {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand All @@ -65,7 +65,7 @@ jar {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
it.options.release = 21
}

modrinth {
Expand Down
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ project_slug = watson
modrinth_debug = false

#Current and version
mod_version = 1.15.5
mod_version = 1.15.6

#Required malilib version
malilib_version = 0.18.1
malilib_mod_version = >=0.18.1
malilib_version = 0.19.0
malilib_mod_version = >=0.19.0

# Minecraft, Fabric and mappings versions
minecraft_version_malilib = 1.20.4
minecraft_version_mod = 1.20.4
minecraft_version = 1.20.4
minecraft_version_dependency = 1.20.4
mappings_version = 1.20.4+build.1
minecraft_version_malilib = 1.20.6
minecraft_version_mod = 1.20.6
minecraft_version = 1.20.6
minecraft_version_dependency = 1.20.6
mappings_version = 1.20.6+build.3

fabric_loader_version = 0.15.9
mod_menu_version = 9.0.0
fabric_loader_version = 0.15.11
mod_menu_version = 10.0.0-beta.1
3 changes: 1 addition & 2 deletions src/main/java/eu/minemania/watson/InitHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void registerModHandlers()
KeyCallbacks.init(MinecraftClient.getInstance());

DataManager.getPlayereditsBaseDirectory();
DataManager.registerPayloads();
}


}
95 changes: 95 additions & 0 deletions src/main/java/eu/minemania/watson/data/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,26 @@
import eu.minemania.watson.db.LedgerInfo;
import eu.minemania.watson.db.TimeStamp;
import eu.minemania.watson.gui.GuiConfigs.ConfigGuiTab;
import eu.minemania.watson.network.ledger.action.PluginActionPacket;
import eu.minemania.watson.network.ledger.action.PluginActionPacketHandler;
import eu.minemania.watson.network.ledger.handshake.PluginHandshakePacket;
import eu.minemania.watson.network.ledger.handshake.PluginHandshakePacketHandler;
import eu.minemania.watson.network.ledger.inspect.PluginInspectPacket;
import eu.minemania.watson.network.ledger.inspect.PluginInspectPacketHandler;
import eu.minemania.watson.network.ledger.purge.PluginPurgePacket;
import eu.minemania.watson.network.ledger.purge.PluginPurgePacketHandler;
import eu.minemania.watson.network.ledger.response.PluginResponsePacket;
import eu.minemania.watson.network.ledger.response.PluginResponsePacketHandler;
import eu.minemania.watson.network.ledger.rollback.PluginRollbackPacket;
import eu.minemania.watson.network.ledger.rollback.PluginRollbackPacketHandler;
import eu.minemania.watson.network.ledger.search.PluginSearchPacket;
import eu.minemania.watson.network.ledger.search.PluginSearchPacketHandler;
import eu.minemania.watson.network.watson.world.PluginWorldPacket;
import eu.minemania.watson.network.watson.world.PluginWorldPacketHandler;
import eu.minemania.watson.selection.EditSelection;
import fi.dy.masa.malilib.gui.Message;
import fi.dy.masa.malilib.gui.interfaces.IDirectoryCache;
import fi.dy.masa.malilib.network.ClientPlayHandler;
import fi.dy.masa.malilib.util.FileUtils;
import fi.dy.masa.malilib.util.InfoUtils;
import fi.dy.masa.malilib.util.JsonUtils;
Expand Down Expand Up @@ -57,6 +74,15 @@ public class DataManager implements IDirectoryCache

protected Filters filters = new Filters();

private final static PluginActionPacketHandler<PluginActionPacket.Payload> ACTION = PluginActionPacketHandler.getInstance();
private final static PluginHandshakePacketHandler<PluginHandshakePacket.Payload> HANDSHAKE = PluginHandshakePacketHandler.getInstance();
private final static PluginInspectPacketHandler<PluginInspectPacket> INSPECT = PluginInspectPacketHandler.getInstance();
private final static PluginPurgePacketHandler<PluginPurgePacket> PURGE = PluginPurgePacketHandler.getInstance();
private final static PluginResponsePacketHandler<PluginResponsePacket.Payload> RESPONSE = PluginResponsePacketHandler.getInstance();
private final static PluginRollbackPacketHandler<PluginRollbackPacket> ROLLBACK = PluginRollbackPacketHandler.getInstance();
private final static PluginSearchPacketHandler<PluginSearchPacket> SEARCH = PluginSearchPacketHandler.getInstance();
private final static PluginWorldPacketHandler<PluginWorldPacket.Payload> WORLD = PluginWorldPacketHandler.getInstance();

private DataManager()
{

Expand Down Expand Up @@ -639,4 +665,73 @@ public static LedgerInfo getLedgerInfo()
{
return ledgerInfo;
}

public static void reset(boolean isLogout)
{
if (isLogout)
{
ACTION.reset(ACTION.getPayloadChannel());
HANDSHAKE.reset(HANDSHAKE.getPayloadChannel());
INSPECT.reset(INSPECT.getPayloadChannel());
PURGE.reset(PURGE.getPayloadChannel());
RESPONSE.reset(RESPONSE.getPayloadChannel());
ROLLBACK.reset(ROLLBACK.getPayloadChannel());
SEARCH.reset(SEARCH.getPayloadChannel());
WORLD.reset(WORLD.getPayloadChannel());
}
}

public static void onWorldPre()
{
ACTION.registerPlayReceiver(PluginActionPacket.Payload.ID, ACTION::receivePlayPayload);
HANDSHAKE.registerPlayReceiver(PluginHandshakePacket.Payload.ID, HANDSHAKE::receivePlayPayload);
RESPONSE.registerPlayReceiver(PluginResponsePacket.Payload.ID, RESPONSE::receivePlayPayload);
WORLD.registerPlayReceiver(PluginWorldPacket.Payload.ID, WORLD::receivePlayPayload);
}

public static void onWorldJoin()
{
HANDSHAKE.encodePayload(new PluginHandshakePacket(Reference.LEDGER_PROTOCOL, Reference.MOD_VERSION, Reference.MOD_ID));
}

public static void registerPayloads()
{
ClientPlayHandler.getInstance().registerClientPlayHandler(ACTION);
ClientPlayHandler.getInstance().registerClientPlayHandler(HANDSHAKE);
ClientPlayHandler.getInstance().registerClientPlayHandler(INSPECT);
ClientPlayHandler.getInstance().registerClientPlayHandler(PURGE);
ClientPlayHandler.getInstance().registerClientPlayHandler(RESPONSE);
ClientPlayHandler.getInstance().registerClientPlayHandler(ROLLBACK);
ClientPlayHandler.getInstance().registerClientPlayHandler(SEARCH);
ClientPlayHandler.getInstance().registerClientPlayHandler(WORLD);

ACTION.registerPlayPayload(PluginActionPacket.Payload.ID, PluginActionPacket.Payload.CODEC, PluginActionPacketHandler.TO_CLIENT);
HANDSHAKE.registerPlayPayload(PluginHandshakePacket.Payload.ID, PluginHandshakePacket.Payload.CODEC, PluginHandshakePacketHandler.BOTH_SERVER);
INSPECT.registerPlayPayload(PluginInspectPacket.ID, PluginInspectPacket.CODEC, PluginInspectPacketHandler.TO_SERVER);
PURGE.registerPlayPayload(PluginPurgePacket.ID, PluginPurgePacket.CODEC, PluginPurgePacketHandler.TO_SERVER);
RESPONSE.registerPlayPayload(PluginResponsePacket.Payload.ID, PluginResponsePacket.Payload.CODEC, PluginResponsePacketHandler.TO_CLIENT);
ROLLBACK.registerPlayPayload(PluginRollbackPacket.ID, PluginRollbackPacket.CODEC, PluginRollbackPacketHandler.TO_SERVER);
SEARCH.registerPlayPayload(PluginSearchPacket.ID, PluginSearchPacket.CODEC, PluginSearchPacketHandler.TO_SERVER);
WORLD.registerPlayPayload(PluginWorldPacket.Payload.ID, PluginWorldPacket.Payload.CODEC, PluginWorldPacketHandler.TO_CLIENT);
}

public static PluginInspectPacketHandler<PluginInspectPacket> getInspectHandler()
{
return INSPECT;
}

public static PluginPurgePacketHandler<PluginPurgePacket> getPurgeHandler()
{
return PURGE;
}

public static PluginSearchPacketHandler<PluginSearchPacket> getSearchHandler()
{
return SEARCH;
}

public static PluginRollbackPacketHandler<PluginRollbackPacket> getRollbackHandler()
{
return ROLLBACK;
}
}
7 changes: 3 additions & 4 deletions src/main/java/eu/minemania/watson/db/BlockEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.EntityType;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -60,7 +59,7 @@ public HashMap<String,Object> getAdditional()
return this.additional;
}

public Object drawOutline(BufferBuilder buffer, MatrixStack matrices)
public Object drawOutline(BufferBuilder buffer)
{
Block blocks = Registries.BLOCK.get(Identifier.tryParse(block.getName()));
float lineWidth = block.getLineWidth();
Expand All @@ -71,7 +70,7 @@ public Object drawOutline(BufferBuilder buffer, MatrixStack matrices)
lineWidth = Configs.Outlines.ORE_LINEWIDTH.getIntegerValue();
}
RenderSystem.lineWidth(lineWidth);
renderBlocks(buffer, blocks, matrices);
renderBlocks(buffer, blocks);
}
else
{
Expand All @@ -81,7 +80,7 @@ public Object drawOutline(BufferBuilder buffer, MatrixStack matrices)
return null;
}

private void renderBlocks(BufferBuilder buffer, Block blocks, MatrixStack matrices)
private void renderBlocks(BufferBuilder buffer, Block blocks)
{
Color4f color = block.getOverrideColor() != Color4f.ZERO && block.getOverrideColor() != null ? block.getOverrideColor() : block.getColor();
if (!block.getName().equals("minecraft:grass") && !block.getName().equals("minecraft:water") &&
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/eu/minemania/watson/db/BlockEditSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ public synchronized void removeEdits(String player)
}
}

public synchronized void drawOutlines(MatrixStack matrices)
public synchronized void drawOutlines()
{
if (Configs.Outlines.OUTLINE_SHOWN.getBooleanValue())
{
for (PlayereditSet editsForPlayer : playerEdits.values())
{
editsForPlayer.drawOutlines(matrices);
editsForPlayer.drawOutlines();
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/eu/minemania/watson/db/PlayereditSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import eu.minemania.watson.render.RenderUtils;
import eu.minemania.watson.selection.PlayereditUtils;
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import eu.minemania.watson.config.Configs;
import fi.dy.masa.malilib.util.Color4f;
import net.minecraft.util.math.Vec3d;
Expand Down Expand Up @@ -83,7 +82,7 @@ public boolean isVisible()
return _visible;
}

public synchronized void drawOutlines(MatrixStack matrices)
public synchronized void drawOutlines()
{
if (isVisible())
{
Expand All @@ -95,7 +94,7 @@ public synchronized void drawOutlines(MatrixStack matrices)
BufferBuilder buffer = tessellator.getBuffer();
RenderUtils.startDrawingLines(buffer);

PlayereditUtils.getInstance().getRevertAction(edit, null, edit.drawOutline(buffer, matrices));
PlayereditUtils.getInstance().getRevertAction(edit, null, edit.drawOutline(buffer));

tessellator.draw();
}
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/eu/minemania/watson/event/KeyCallbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import eu.minemania.watson.gui.GuiConfigs;
import eu.minemania.watson.gui.GuiMainMenu;
import eu.minemania.watson.selection.EditSelection;
import fi.dy.masa.malilib.config.options.ConfigOptionList;
import fi.dy.masa.malilib.config.options.ConfigString;
import fi.dy.masa.malilib.config.options.ConfigStringList;
import fi.dy.masa.malilib.gui.GuiBase;
Expand All @@ -32,10 +33,12 @@ public static void init(MinecraftClient mc)
IHotkeyCallback callbackHotkeys = new KeyCallbackHotkeys(mc);
ValueChangeStringCallback valueChangeStringCallback = new ValueChangeStringCallback();
ValueChangeStringListCallback valueChangeStringListCallback = new ValueChangeStringListCallback();
ValueChangeOptionListCallback valueChangeOptionListCallback = new ValueChangeOptionListCallback();

Configs.Generic.WATSON_PREFIX.setValueChangeCallback(valueChangeStringCallback);
Configs.Lists.HIGHLIGHT.setValueChangeCallback(valueChangeStringListCallback);
Configs.Lists.OVERRIDING_ACTIONS.setValueChangeCallback(valueChangeStringListCallback);
Configs.Plugin.PLUGIN.setValueChangeCallback(valueChangeOptionListCallback);

Configs.Analysis.CP_BUSY.setValueChangeCallback(valueChangeStringCallback);
Configs.Analysis.CP_DETAILS.setValueChangeCallback(valueChangeStringCallback);
Expand Down Expand Up @@ -238,7 +241,6 @@ else if (config == Configs.Generic.WATSON_PREFIX)

private static class ValueChangeStringListCallback implements IValueChangeCallback<ConfigStringList>
{

public ValueChangeStringListCallback()
{
}
Expand All @@ -257,6 +259,22 @@ else if (config == Configs.Lists.OVERRIDING_ACTIONS)
}
}

private static class ValueChangeOptionListCallback implements IValueChangeCallback<ConfigOptionList>
{
public ValueChangeOptionListCallback()
{
}

@Override
public void onValueChanged(ConfigOptionList config)
{
if (config == Configs.Plugin.PLUGIN)
{
Configs.Plugin.PLUGIN.setOptionListValue(config.getOptionListValue());
}
}
}

private static class KeyCallbackHotkeys implements IHotkeyCallback
{
private final MinecraftClient mc;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eu/minemania/watson/event/RenderHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static RenderHandler getInstance()
}

@Override
public void onRenderWorldLast(MatrixStack matrixStack, Matrix4f projMatrix)
public void onRenderWorldLast(Matrix4f matrix4f, Matrix4f projMatrix)
{
MinecraftClient mc = MinecraftClient.getInstance();

Expand Down
25 changes: 7 additions & 18 deletions src/main/java/eu/minemania/watson/event/WorldLoadListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
import eu.minemania.watson.analysis.CoreProtectAnalysis;
import eu.minemania.watson.config.Configs;
import eu.minemania.watson.data.DataManager;
import eu.minemania.watson.network.ClientPacketChannelHandler;
import eu.minemania.watson.network.PluginWorldPacketHandler;
import eu.minemania.watson.network.ledger.PluginActionPacketHandler;
import eu.minemania.watson.network.ledger.PluginHandshakePacketHandler;
import eu.minemania.watson.network.ledger.PluginResponsePacketHandler;
import eu.minemania.watson.render.OverlayRenderer;
import fi.dy.masa.malilib.interfaces.IWorldLoadListener;
import net.minecraft.client.MinecraftClient;
Expand All @@ -20,20 +15,17 @@ public class WorldLoadListener implements IWorldLoadListener
@Override
public void onWorldLoadPre(@Nullable ClientWorld worldBefore, @Nullable ClientWorld worldAfter, MinecraftClient mc)
{
if (worldAfter != null)
{
DataManager.onWorldPre();
}
// Save the settings before the integrated server gets shut down
if (worldBefore != null)
{
DataManager.save();
if (worldAfter == null)
{
ClientPacketChannelHandler.getInstance().unregisterClientChannelHandler(PluginWorldPacketHandler.INSTANCE);
ClientPacketChannelHandler.getInstance().unregisterClientChannelHandler(PluginHandshakePacketHandler.INSTANCE);
ClientPacketChannelHandler.getInstance().unregisterClientChannelHandler(PluginActionPacketHandler.INSTANCE);
ClientPacketChannelHandler.getInstance().unregisterClientChannelHandler(PluginResponsePacketHandler.INSTANCE);
PluginWorldPacketHandler.INSTANCE.reset();
PluginHandshakePacketHandler.INSTANCE.reset();
PluginActionPacketHandler.INSTANCE.reset();
PluginResponsePacketHandler.INSTANCE.reset();
DataManager.reset(true);
if (DataManager.getEditSelection().getSelection() != null)
{
DataManager.getEditSelection().clearBlockEditSet();
Expand All @@ -60,15 +52,12 @@ public void onWorldLoadPost(@Nullable ClientWorld worldBefore, @Nullable ClientW
if (worldBefore == null && worldAfter != null && Configs.Generic.ENABLED.getBooleanValue())
{
DataManager.onClientTickStart();
ClientPacketChannelHandler.getInstance().registerClientChannelHandler(PluginWorldPacketHandler.INSTANCE);
ClientPacketChannelHandler.getInstance().registerClientChannelHandler(PluginHandshakePacketHandler.INSTANCE);
ClientPacketChannelHandler.getInstance().registerClientChannelHandler(PluginActionPacketHandler.INSTANCE);
ClientPacketChannelHandler.getInstance().registerClientChannelHandler(PluginResponsePacketHandler.INSTANCE);
((ClientPacketChannelHandler) ClientPacketChannelHandler.getInstance()).processPacketFromClient();
}
if (worldAfter != null)
{
DataManager.load();

DataManager.onWorldJoin();
}
}
}
Loading

0 comments on commit ce66c1c

Please sign in to comment.