Skip to content

Commit

Permalink
Update some code from DEV
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Nov 5, 2024
1 parent 838e37f commit af6f267
Show file tree
Hide file tree
Showing 25 changed files with 2,118 additions and 357 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ targetCompatibility = JavaVersion.VERSION_21
repositories {
maven { url 'https://masa.dy.fi/maven' }
maven { url 'https://maven.terraformersmc.com/releases/' }
maven { url 'https://jitpack.io' }
}

dependencies {
Expand All @@ -16,8 +17,8 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
implementation "com.google.code.findbugs:jsr305:3.0.2"

modImplementation "fi.dy.masa.malilib:malilib-fabric-${project.minecraft_version_out}:${project.malilib_version}"
//modImplementation "com.github.sakura-ryoko:malilib:${project.malilib_id}"
//modImplementation "fi.dy.masa.malilib:malilib-fabric-${project.minecraft_version_out}:${project.malilib_version}"
modImplementation "com.github.sakura-ryoko:malilib:${project.malilib_id}"

// Fabric API. This is technically optional, but you probably want it anyway.
//include(modApi(fabricApi.module("fabric-api-base", project.fabric_api_version)))
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ author = masa
mod_file_name = tweakeroo-fabric

# Current mod version
mod_version = 0.21.1-sakura.1
mod_version = 0.21.51-sakura.1

# Required malilib version
malilib_version = 0.20.0
malilib_version = 0.21.1-sakura.3
malilib_id = 5eeca46223

# Minecraft, Fabric Loader and API and mappings versions
minecraft_version_out = 1.21
Expand Down
14 changes: 10 additions & 4 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 @@ -38,6 +38,12 @@ public void registerModHandlers()
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);
}
}
*/
}
14 changes: 10 additions & 4 deletions src/main/java/fi/dy/masa/tweakeroo/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ public static class Generic
public static final ConfigOptionList BLOCK_TYPE_BREAK_RESTRICTION_WARN = new ConfigOptionList ("blockTypeBreakRestrictionWarn", MessageOutputType.MESSAGE, "tweakeroo.config.generic.comment.blockTypeBreakRestrictionWarn").translatedName("tweakeroo.config.generic.name.blockTypeBreakRestrictionWarn");
public static final ConfigInteger BREAKING_GRID_SIZE = new ConfigInteger ("breakingGridSize", 3, 1, 1000, "tweakeroo.config.generic.comment.breakingGridSize").translatedName("tweakeroo.config.generic.name.breakingGridSize");
public static final ConfigOptionList BREAKING_RESTRICTION_MODE = new ConfigOptionList ("breakingRestrictionMode", PlacementRestrictionMode.LINE, "tweakeroo.config.generic.comment.breakingRestrictionMode").translatedName("tweakeroo.config.generic.name.breakingRestrictionMode");
public static final ConfigBoolean BUNDLE_DISPLAY_BACKGROUND_COLOR = new ConfigBoolean ("bundleDisplayBgColor", true, "tweakeroo.config.generic.comment.bundleDisplayBgColor").translatedName("tweakeroo.config.generic.name.bundleDisplayBgColor");
public static final ConfigBoolean BUNDLE_DISPLAY_REQUIRE_SHIFT = new ConfigBoolean ("bundleDisplayRequireShift", true, "tweakeroo.config.generic.comment.bundleDisplayRequireShift").translatedName("tweakeroo.config.generic.name.bundleDisplayRequireShift");
public static final ConfigColor CHAT_BACKGROUND_COLOR = new ConfigColor ("chatBackgroundColor", "#80000000", "tweakeroo.config.generic.comment.chatBackgroundColor").translatedName("tweakeroo.config.generic.name.chatBackgroundColor");
public static final ConfigString CHAT_TIME_FORMAT = new ConfigString ("chatTimeFormat", "[HH:mm:ss]", "tweakeroo.config.generic.comment.chatTimeFormat").translatedName("tweakeroo.config.generic.name.chatTimeFormat");
public static final ConfigBoolean CLIENT_PLACEMENT_ROTATION = new ConfigBoolean ("clientPlacementRotation", true, "tweakeroo.config.generic.comment.clientPlacementRotation").translatedName("tweakeroo.config.generic.name.clientPlacementRotation");
public static final ConfigInteger CUSTOM_INVENTORY_GUI_SCALE = new ConfigInteger ("customInventoryGuiScale", 2, 1, 10, "tweakeroo.config.generic.comment.customInventoryGuiScale").translatedName("tweakeroo.config.generic.name.customInventoryGuiScale");
//public static final ConfigBoolean DEBUG_LOGGING = new ConfigBoolean ("debugLogging", false, "tweakeroo.config.generic.comment.debugLogging").translatedName("tweakeroo.config.generic.name.debugLogging");
public static final ConfigBoolean DEBUG_LOGGING = new ConfigBoolean ("debugLogging", false, "tweakeroo.config.generic.comment.debugLogging").translatedName("tweakeroo.config.generic.name.debugLogging");
public static final ConfigOptionList ELYTRA_CAMERA_INDICATOR = new ConfigOptionList ("elytraCameraIndicator", ActiveMode.WITH_KEY, "tweakeroo.config.generic.comment.elytraCameraIndicator").translatedName("tweakeroo.config.generic.name.elytraCameraIndicator");
public static final ConfigDouble ENTITY_REACH_DISTANCE = new ConfigDouble ("entityReachDistance", 3.0, 1, 64, "tweakeroo.config.generic.comment.entityReachDistance").translatedName("tweakeroo.config.generic.name.entityReachDistance");
public static final ConfigOptionList ENTITY_TYPE_ATTACK_RESTRICTION_WARN = new ConfigOptionList ("entityTypeAttackRestrictionWarn", MessageOutputType.MESSAGE, "tweakeroo.config.generic.comment.entityTypeAttackRestrictionWarn").translatedName("tweakeroo.config.generic.name.entityTypeAttackRestrictionWarn");
Expand Down Expand Up @@ -101,6 +103,7 @@ public static class Generic
public static final ConfigInteger RENDER_LIMIT_ITEM = new ConfigInteger ("renderLimitItem", -1, -1, 10000, "tweakeroo.config.generic.comment.renderLimitItem").translatedName("tweakeroo.config.generic.name.renderLimitItem");
public static final ConfigInteger RENDER_LIMIT_XP_ORB = new ConfigInteger ("renderLimitXPOrb", -1, -1, 10000, "tweakeroo.config.generic.comment.renderLimitXPOrb").translatedName("tweakeroo.config.generic.name.renderLimitXPOrb");
public static final ConfigInteger SCULK_SENSOR_PULSE_LENGTH = new ConfigInteger ("sculkSensorPulseLength", 40, 0, 10000, "tweakeroo.config.generic.comment.sculkSensorPulseLength").translatedName("tweakeroo.config.generic.name.sculkSensorPulseLength");
public static final ConfigInteger SERVER_NBT_REQUEST_RATE = new ConfigInteger ("serverNbtRequestRate", 2, "tweakeroo.config.generic.comment.serverNbtRequestRate").translatedName("tweakeroo.config.generic.name.serverNbtRequestRate");
public static final ConfigBoolean SHULKER_DISPLAY_BACKGROUND_COLOR = new ConfigBoolean ("shulkerDisplayBgColor", true, "tweakeroo.config.generic.comment.shulkerDisplayBgColor").translatedName("tweakeroo.config.generic.name.shulkerDisplayBgColor");
public static final ConfigBoolean SHULKER_DISPLAY_REQUIRE_SHIFT = new ConfigBoolean ("shulkerDisplayRequireShift", true, "tweakeroo.config.generic.comment.shulkerDisplayRequireShift").translatedName("tweakeroo.config.generic.name.shulkerDisplayRequireShift");
public static final ConfigBoolean SLOT_SYNC_WORKAROUND = new ConfigBoolean ("slotSyncWorkaround", true, "tweakeroo.config.generic.comment.slotSyncWorkaround").translatedName("tweakeroo.config.generic.name.slotSyncWorkaround");
Expand All @@ -126,8 +129,10 @@ public static class Generic
public static final ImmutableList<IConfigBase> OPTIONS = ImmutableList.of(
ACCURATE_PLACEMENT_PROTOCOL_MODE,
ACCURATE_PLACEMENT_PROTOCOL,
BUNDLE_DISPLAY_BACKGROUND_COLOR,
BUNDLE_DISPLAY_REQUIRE_SHIFT,
CLIENT_PLACEMENT_ROTATION,
//DEBUG_LOGGING,
DEBUG_LOGGING,
FAST_LEFT_CLICK_ALLOW_TOOLS,
FAST_PLACEMENT_REMEMBER_ALWAYS,
FREE_CAMERA_PLAYER_INPUTS,
Expand Down Expand Up @@ -201,6 +206,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 Expand Up @@ -248,7 +254,7 @@ public static class Lists
public static final ConfigOptionList FAST_RIGHT_CLICK_ITEM_LIST_TYPE = new ConfigOptionList("fastRightClickListType", ListType.NONE, "tweakeroo.config.lists.comment.fastRightClickListType").translatedName("tweakeroo.config.lists.name.fastRightClickListType");
public static final ConfigStringList FAST_RIGHT_CLICK_ITEM_BLACKLIST = new ConfigStringList("fastRightClickBlackList", ImmutableList.of("minecraft:firework_rocket"), "tweakeroo.config.lists.comment.fastRightClickBlackList").translatedName("tweakeroo.config.lists.name.fastRightClickBlackList");
public static final ConfigStringList FAST_RIGHT_CLICK_ITEM_WHITELIST = new ConfigStringList("fastRightClickWhiteList", ImmutableList.of("minecraft:bucket", "minecraft:water_bucket", "minecraft:lava_bucket", "minecraft:glass_bottle"), "tweakeroo.config.lists.comment.fastRightClickWhiteList").translatedName("tweakeroo.config.lists.name.fastRightClickWhiteList");
public static final ConfigStringList FLAT_WORLD_PRESETS = new ConfigStringList("flatWorldPresets", ImmutableList.of("White Glass;1*minecraft:white_stained_glass;minecraft:plains;;minecraft:white_stained_glass", "Glass;1*minecraft:glass;minecraft:plains;;minecraft:glass"), "tweakeroo.config.lists.comment.flatWorldPresets").translatedName("tweakeroo.config.lists.name.flatWorldPresets");
//public static final ConfigStringList FLAT_WORLD_PRESETS = new ConfigStringList("flatWorldPresets", ImmutableList.of("White Glass;1*minecraft:white_stained_glass;minecraft:plains;;minecraft:white_stained_glass", "Glass;1*minecraft:glass;minecraft:plains;;minecraft:glass"), "tweakeroo.config.lists.comment.flatWorldPresets").translatedName("tweakeroo.config.lists.name.flatWorldPresets");
public static final ConfigOptionList HAND_RESTOCK_LIST_TYPE = new ConfigOptionList("handRestockListType", ListType.NONE, "tweakeroo.config.lists.comment.handRestockListType").translatedName("tweakeroo.config.lists.name.handRestockListType");
public static final ConfigStringList HAND_RESTOCK_BLACKLIST = new ConfigStringList("handRestockBlackList", ImmutableList.of("minecraft:bucket", "minecraft:lava_bucket", "minecraft:water_bucket"), "tweakeroo.config.lists.comment.handRestockBlackList").translatedName("tweakeroo.config.lists.name.handRestockBlackList");
public static final ConfigStringList HAND_RESTOCK_WHITELIST = new ConfigStringList("handRestockWhiteList", ImmutableList.of(), "tweakeroo.config.lists.comment.handRestockWhiteList").translatedName("tweakeroo.config.lists.name.handRestockWhiteList");
Expand Down Expand Up @@ -278,7 +284,7 @@ public static class Lists
FAST_RIGHT_CLICK_BLOCK_WHITELIST,
FAST_RIGHT_CLICK_ITEM_BLACKLIST,
FAST_RIGHT_CLICK_ITEM_WHITELIST,
FLAT_WORLD_PRESETS,
//FLAT_WORLD_PRESETS,
HAND_RESTOCK_LIST_TYPE,
HAND_RESTOCK_BLACKLIST,
HAND_RESTOCK_WHITELIST,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/fi/dy/masa/tweakeroo/config/FeatureToggle.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum FeatureToggle implements IHotkeyTogglable, IConfigNotifiable<IConfig
TWEAK_BLOCK_TYPE_BREAK_RESTRICTION("tweakBlockTypeBreakRestriction", false, ""),
TWEAK_BREAKING_GRID ("tweakBreakingGrid", false, "", KeybindSettings.INGAME_BOTH),
TWEAK_BREAKING_RESTRICTION ("tweakBreakingRestriction", false, ""),
TWEAK_BUNDLE_DISPLAY ("tweakBundleDisplay", false, ""),
TWEAK_CHAT_BACKGROUND_COLOR ("tweakChatBackgroundColor", false, ""),
TWEAK_CHAT_PERSISTENT_TEXT ("tweakChatPersistentText", false, ""),
TWEAK_CHAT_TIMESTAMP ("tweakChatTimestamp", false, ""),
Expand Down Expand Up @@ -89,6 +90,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
57 changes: 49 additions & 8 deletions src/main/java/fi/dy/masa/tweakeroo/data/DataManager.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
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
//{
//Tweakeroo.logger.info("DataManager#reset() - dimension change or log-in");
//Tweakeroo.logger.info("DataManager#reset() - dimension change or log-in");
//}
}

Expand All @@ -49,4 +58,36 @@ 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 af6f267

Please sign in to comment.