Skip to content

Commit

Permalink
Upgrade Inventory Preview to attach to Servux, and exclusively use NB…
Browse files Browse the repository at this point in the history
…T tags for it.
  • Loading branch information
sakura-ryoko committed Oct 1, 2024
1 parent 432a5a9 commit db78a21
Show file tree
Hide file tree
Showing 19 changed files with 1,679 additions and 322 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ mod_version = 0.21.999-snap

# Required malilib version
malilib_version = 0.20.999-snap
malilib_id = 17ed6556a7
malilib_id = 0b26b0633e

# Minecraft, Fabric Loader and API and mappings versions
minecraft_version_out = 24w39a
minecraft_version = 24w39a
mappings_version = 24w39a+build.6
mappings_version = 24w39a+build.8

fabric_loader_version = 0.16.5
mod_menu_version = 12.0.0-alpha.1
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/fi/dy/masa/tweakeroo/InitHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import net.minecraft.client.MinecraftClient;
import fi.dy.masa.malilib.config.ConfigManager;
import fi.dy.masa.malilib.event.InputEventHandler;
import fi.dy.masa.malilib.event.RenderEventHandler;
import fi.dy.masa.malilib.event.TickHandler;
import fi.dy.masa.malilib.event.WorldLoadHandler;
import fi.dy.masa.malilib.event.*;
import fi.dy.masa.malilib.interfaces.IInitializationHandler;
import fi.dy.masa.malilib.interfaces.IRenderer;
import fi.dy.masa.malilib.interfaces.IWorldLoadListener;
import fi.dy.masa.tweakeroo.config.Callbacks;
import fi.dy.masa.tweakeroo.config.Configs;
import fi.dy.masa.tweakeroo.data.DataManager;
import fi.dy.masa.tweakeroo.data.ServerDataSyncer;
import fi.dy.masa.tweakeroo.event.ClientTickHandler;
import fi.dy.masa.tweakeroo.event.InputHandler;
import fi.dy.masa.tweakeroo.event.RenderHandler;
Expand All @@ -22,6 +21,7 @@ public class InitHandler implements IInitializationHandler
public void registerModHandlers()
{
ConfigManager.getInstance().registerConfigHandler(Reference.MOD_ID, new Configs());
ServerDataSyncer.getInstance().onGameInit();

InputEventHandler.getKeybindManager().registerKeybindProvider(InputHandler.getInstance());
InputEventHandler.getInputManager().registerKeyboardInputHandler(InputHandler.getInstance());
Expand All @@ -32,12 +32,15 @@ public void registerModHandlers()
RenderEventHandler.getInstance().registerTooltipLastRenderer(renderer);
RenderEventHandler.getInstance().registerWorldLastRenderer(renderer);

TickHandler.getInstance().registerClientTickHandler(new ClientTickHandler());

IWorldLoadListener worldListener = new WorldLoadListener();
WorldLoadHandler.getInstance().registerWorldLoadPreHandler(worldListener);
WorldLoadHandler.getInstance().registerWorldLoadPostHandler(worldListener);

ServerHandler.getInstance().registerServerHandler(DataManager.getInstance());

TickHandler.getInstance().registerClientTickHandler(new ClientTickHandler());
TickHandler.getInstance().registerClientTickHandler(ServerDataSyncer.getInstance());

Callbacks.init(MinecraftClient.getInstance());
}
}
5 changes: 5 additions & 0 deletions src/main/java/fi/dy/masa/tweakeroo/Reference.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package fi.dy.masa.tweakeroo;

import net.minecraft.MinecraftVersion;

import fi.dy.masa.malilib.util.StringUtils;

public class Reference
{
public static final String MOD_ID = "tweakeroo";
public static final String MOD_NAME = "Tweakeroo";
public static final String MOD_VERSION = StringUtils.getModVersionString(MOD_ID);
public static final String MC_VERSION = MinecraftVersion.CURRENT.getName();
public static final String MOD_TYPE = "fabric";
public static final String MOD_STRING = MOD_ID+"-"+MOD_TYPE+"-"+MC_VERSION+"-"+MOD_VERSION;
}
5 changes: 2 additions & 3 deletions src/main/java/fi/dy/masa/tweakeroo/Tweakeroo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import fi.dy.masa.malilib.event.InitializationHandler;
import fi.dy.masa.tweakeroo.config.Configs;

public class Tweakeroo implements ModInitializer
{
Expand All @@ -18,13 +19,11 @@ public void onInitialize()
InitializationHandler.getInstance().registerInitializationHandler(new InitHandler());
}

/*
public static void debugLog(String msg, Object... args)
public static void printDebug(String msg, Object... args)
{
if (Configs.Generic.DEBUG_LOGGING.getBooleanValue())
{
Tweakeroo.logger.info(msg, args);
}
}
*/
}
6 changes: 4 additions & 2 deletions src/main/java/fi/dy/masa/tweakeroo/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static class Generic
public static final ConfigString CHAT_TIME_FORMAT = new ConfigString ("chatTimeFormat", "[HH:mm:ss]").apply(GENERIC_KEY);
public static final ConfigBoolean CLIENT_PLACEMENT_ROTATION = new ConfigBoolean ("clientPlacementRotation", true).apply(GENERIC_KEY);
public static final ConfigInteger CUSTOM_INVENTORY_GUI_SCALE = new ConfigInteger ("customInventoryGuiScale", 2, 1, 10).apply(GENERIC_KEY);
//public static final ConfigBoolean DEBUG_LOGGING = new ConfigBoolean ("debugLogging", false).apply(GENERIC_KEY);
public static final ConfigBoolean DEBUG_LOGGING = new ConfigBoolean ("debugLogging", false).apply(GENERIC_KEY);
public static final ConfigOptionList ELYTRA_CAMERA_INDICATOR = new ConfigOptionList ("elytraCameraIndicator", ActiveMode.WITH_KEY).apply(GENERIC_KEY);
public static final ConfigDouble ENTITY_REACH_DISTANCE = new ConfigDouble ("entityReachDistance", 3.0, 1, 64).apply(GENERIC_KEY);
public static final ConfigOptionList ENTITY_TYPE_ATTACK_RESTRICTION_WARN = new ConfigOptionList ("entityTypeAttackRestrictionWarn", MessageOutputType.MESSAGE).apply(GENERIC_KEY);
Expand Down Expand Up @@ -107,6 +107,7 @@ public static class Generic
public static final ConfigInteger RENDER_LIMIT_ITEM = new ConfigInteger ("renderLimitItem", -1, -1, 10000).apply(GENERIC_KEY);
public static final ConfigInteger RENDER_LIMIT_XP_ORB = new ConfigInteger ("renderLimitXPOrb", -1, -1, 10000).apply(GENERIC_KEY);
public static final ConfigInteger SCULK_SENSOR_PULSE_LENGTH = new ConfigInteger ("sculkSensorPulseLength", 40, 0, 10000).apply(GENERIC_KEY);
public static final ConfigInteger SERVER_NBT_REQUEST_RATE = new ConfigInteger ("serverNbtRequestRate", 2).apply(GENERIC_KEY);
public static final ConfigBoolean SHULKER_DISPLAY_BACKGROUND_COLOR = new ConfigBoolean ("shulkerDisplayBgColor", true).apply(GENERIC_KEY);
public static final ConfigBoolean SHULKER_DISPLAY_REQUIRE_SHIFT = new ConfigBoolean ("shulkerDisplayRequireShift", true).apply(GENERIC_KEY);
public static final ConfigBoolean SLOT_SYNC_WORKAROUND = new ConfigBoolean ("slotSyncWorkaround", true).apply(GENERIC_KEY);
Expand All @@ -133,7 +134,7 @@ public static class Generic
ACCURATE_PLACEMENT_PROTOCOL_MODE,
ACCURATE_PLACEMENT_PROTOCOL,
CLIENT_PLACEMENT_ROTATION,
//DEBUG_LOGGING,
DEBUG_LOGGING,
FAST_LEFT_CLICK_ALLOW_TOOLS,
FAST_PLACEMENT_REMEMBER_ALWAYS,
FREE_CAMERA_PLAYER_INPUTS,
Expand Down Expand Up @@ -207,6 +208,7 @@ public static class Generic
RENDER_LIMIT_ITEM,
RENDER_LIMIT_XP_ORB,
SCULK_SENSOR_PULSE_LENGTH,
SERVER_NBT_REQUEST_RATE,
SNAP_AIM_PITCH_STEP,
SNAP_AIM_THRESHOLD_PITCH,
SNAP_AIM_THRESHOLD_YAW,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public enum FeatureToggle implements IHotkeyTogglable, IConfigNotifiable<IConfig
TWEAK_REPAIR_MODE ("tweakRepairMode", false, ""),
TWEAK_SCULK_PULSE_LENGTH ("tweakSculkPulseLength", false, true, ""),
TWEAK_SERVER_DATA_SYNC ("tweakServerDataSync", false, ""),
TWEAK_SERVER_DATA_SYNC_BACKUP ("tweakServerDataSyncBackup", false, ""),
TWEAK_SHULKERBOX_DISPLAY ("tweakShulkerBoxDisplay", false, ""),
TWEAK_SIGN_COPY ("tweakSignCopy", false, ""),
TWEAK_SNAP_AIM ("tweakSnapAim", false, "", KeybindSettings.INGAME_BOTH),
Expand Down
56 changes: 49 additions & 7 deletions src/main/java/fi/dy/masa/tweakeroo/data/DataManager.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
package fi.dy.masa.tweakeroo.data;

import javax.annotation.Nullable;

import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.util.Identifier;

public class DataManager
import fi.dy.masa.malilib.interfaces.IServerListener;
import fi.dy.masa.tweakeroo.Tweakeroo;

public class DataManager implements IServerListener
{
private static final DataManager INSTANCE = new DataManager();
public static DataManager getInstance() { return INSTANCE; }

private boolean hasCarpetServer;
private boolean hasServuxServer;
public static final Identifier CARPET_HELLO = Identifier.of("carpet", "hello");
public static final Identifier SERVUX_ENTITY_DATA = Identifier.of("servux", "entity_data");
//private IntegratedServer integratedServer;
//private DynamicRegistryManager.Immutable registryManager = DynamicRegistryManager.EMPTY;
private boolean hasIntegratedServer;

private DataManager()
{
}

public static DataManager getInstance() { return INSTANCE; }
private DataManager() { }

public void reset(boolean isLogout)
{
if (isLogout)
{
//Tweakeroo.logger.info("DataManager#reset() - log-out");
Tweakeroo.printDebug("DataManager#reset() - log-out");
this.hasCarpetServer = false;
this.hasServuxServer = false;
//this.registryManager = DynamicRegistryManager.EMPTY;
this.setHasIntegratedServer(false, null);
}
//else
//{
Expand All @@ -49,4 +58,37 @@ public boolean hasServuxServer()
{
return this.hasServuxServer;
}

@Override
public void onServerIntegratedSetup(IntegratedServer server)
{
this.setHasIntegratedServer(true, server);
}

public boolean hasIntegratedServer() { return this.hasIntegratedServer; }

public void setHasIntegratedServer(boolean toggle, @Nullable IntegratedServer server)
{
this.hasIntegratedServer = toggle;
//this.integratedServer = server;
}

/*
public IntegratedServer getIntegratedServer()
{
return this.integratedServer;
}
*/

/*
public void setRegistryManager(DynamicRegistryManager.Immutable immutable)
{
this.registryManager = immutable;
}
public DynamicRegistryManager.Immutable getRegistryManager()
{
return this.registryManager;
}
*/
}
Loading

0 comments on commit db78a21

Please sign in to comment.