From b738f5bf54db447b350cd019593d0fa5a0f6ed80 Mon Sep 17 00:00:00 2001 From: onebeastchris Date: Fri, 16 Aug 2024 01:36:53 +0200 Subject: [PATCH] 2.1.0: - Removed item steerable workaround - Implemented config version --- CHANGELOG.md | 6 +-- fabric/build.gradle.kts | 5 ++ gradle.properties | 2 +- .../onebeastchris/hurricane/Hurricane.java | 14 ++++-- .../hurricane/config/Config.java | 50 ++++++++++++------- .../config/HurricaneConfiguration.java | 9 ---- .../hurricane/mixin/EntityMixin.java | 27 ---------- .../hurricane/mixin/MixinConfigPlugin.java | 1 - .../src/main/resources/hurricane.mixins.json | 3 +- 9 files changed, 50 insertions(+), 67 deletions(-) delete mode 100644 shared/src/main/java/net/onebeastchris/hurricane/mixin/EntityMixin.java diff --git a/CHANGELOG.md b/CHANGELOG.md index f76b87b..c55a9ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,3 @@ -Hurricane 2.0: -- Added 1.21 support -- Added NeoForge port \ No newline at end of file +Hurricane 2.1: +- Added config version +- Removed the item steerables workaround due to it being implemented natively in Geyser \ No newline at end of file diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index da1f02d..4432f4d 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -33,6 +33,11 @@ dependencies { include(libs.configurate.core) include(libs.geantyref) include(libs.typesafe) + + modLocalRuntime(libs.configurate.hocon) + modLocalRuntime(libs.configurate.core) + modLocalRuntime(libs.geantyref) + modLocalRuntime(libs.typesafe) } modrinth { diff --git a/gradle.properties b/gradle.properties index 45025c3..3d5bfb3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,6 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true # Mod Properties -version=2.0.0 +version=2.1.0 group=net.onebeastchris.hurricane id=hurricane-modded \ No newline at end of file diff --git a/shared/src/main/java/net/onebeastchris/hurricane/Hurricane.java b/shared/src/main/java/net/onebeastchris/hurricane/Hurricane.java index a634301..c9acb59 100644 --- a/shared/src/main/java/net/onebeastchris/hurricane/Hurricane.java +++ b/shared/src/main/java/net/onebeastchris/hurricane/Hurricane.java @@ -11,18 +11,22 @@ public abstract class Hurricane { private final Config config = MixinConfigPlugin.getConfig(); protected void onHurricaneInitialize() { - LOGGER.info("Starting Hurricane..."); - if (config.isItemSteerableFix()) { - if (!BedrockUtils.isGeyserOrFloodgateInstalled()) { - LOGGER.warn("Hurricane's fix for item steerable mobs is enabled, but Geyser or Floodgate is not installed! This will not work."); - } + if (config.isBamboo() && !BedrockUtils.isGeyserOrFloodgateInstalled()) { + LOGGER.warn("Bamboo fix is enabled, but Geyser or Floodgate are not found! Without these mods, Hurricane cannot " + + "fix the bamboo lag-back for Bedrock players."); } if (config.isBamboo() || config.isPointedDripstone()) { registerBlockPlaceEvent(); LOGGER.debug("BlockPlaceEvent registered, as the Bamboo or PointedDripstone fix is enabled."); } + LOGGER.info("Started Hurricane!"); + + if (Config.shouldWarn) { + LOGGER.warn("Removed the item steerable configuration option, as Geyser now supports it natively! " + + "Please update Geyser if you have not done so already!"); + } } public abstract void registerBlockPlaceEvent(); diff --git a/shared/src/main/java/net/onebeastchris/hurricane/config/Config.java b/shared/src/main/java/net/onebeastchris/hurricane/config/Config.java index c242ac8..84b116b 100644 --- a/shared/src/main/java/net/onebeastchris/hurricane/config/Config.java +++ b/shared/src/main/java/net/onebeastchris/hurricane/config/Config.java @@ -1,21 +1,31 @@ package net.onebeastchris.hurricane.config; +import lombok.Getter; import net.onebeastchris.hurricane.util.PlatformUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.ConfigurateException; +import org.spongepowered.configurate.NodePath; import org.spongepowered.configurate.hocon.HoconConfigurationLoader; +import org.spongepowered.configurate.transformation.ConfigurationTransformation; +import org.spongepowered.configurate.transformation.TransformAction; +@Getter public class Config { private static final Logger LOGGER = LoggerFactory.getLogger("Hurricane"); private boolean suppressWarnings; - private boolean itemSteerableFix; private boolean bamboo; private boolean pointedDripstone; + public static boolean shouldWarn = false; + public static HurricaneConfiguration config; + private final ConfigurationTransformation.Versioned transformer = ConfigurationTransformation.versionedBuilder() + .addVersion(1, zeroToOne()) + .build(); + public Config() { if (PlatformUtil.oldConfigPath().toFile().exists()) { @@ -32,34 +42,36 @@ Old Hurricane config found (geyserhacks.conf). .build(); try { - final CommentedConfigurationNode node = loader.load(); - config = node.get(HurricaneConfiguration.class); - loader.save(node); + final CommentedConfigurationNode rootNode = loader.load(); + config = rootNode.get(HurricaneConfiguration.class); + + // Attempt to upgrade our config here if we don't have a version set + var versionNode = rootNode.node("version"); + if (versionNode.virtual()) { + shouldWarn = true; + versionNode.set(0); // Add a version config entry, set it to 1 + versionNode.comment("The version of the config. DO NOT CHANGE!"); + + // Remove item steerable workaround + transformer.apply(rootNode); + } + + rootNode.set(HurricaneConfiguration.class, config); + loader.save(rootNode); } catch (ConfigurateException e) { LOGGER.warn("Could not load config!"); e.printStackTrace(); return; } - this.itemSteerableFix = config.itemSteerableFix(); this.bamboo = config.collisionFixes().bamboo(); this.pointedDripstone = config.collisionFixes().pointedDripstone(); this.suppressWarnings = config.suppressWarnings(); } - public boolean isItemSteerableFix() { - return itemSteerableFix; - } - - public boolean isBamboo() { - return bamboo; - } - - public boolean isPointedDripstone() { - return pointedDripstone; - } - - public boolean isSuppressWarnings() { - return suppressWarnings; + private ConfigurationTransformation zeroToOne() { + return ConfigurationTransformation.builder() + .addAction(NodePath.path("item-steerable-fix"), TransformAction.remove()) + .build(); } } \ No newline at end of file diff --git a/shared/src/main/java/net/onebeastchris/hurricane/config/HurricaneConfiguration.java b/shared/src/main/java/net/onebeastchris/hurricane/config/HurricaneConfiguration.java index 1e01e1e..f270797 100644 --- a/shared/src/main/java/net/onebeastchris/hurricane/config/HurricaneConfiguration.java +++ b/shared/src/main/java/net/onebeastchris/hurricane/config/HurricaneConfiguration.java @@ -11,11 +11,6 @@ public final class HurricaneConfiguration { Caveats: a custom client - Java or Bedrock - could take advantage of no collision and walk right through. Additionally, placement of these blocks on both platforms may be buggier than usual.""") private CollisionFixes collisionFixes = new CollisionFixes(); - @Comment(""" - Fixes Bedrock players being unable to control pigs and striders by controlling their movement serverside. - Java Edition controls pigs and striders on the client end. Bedrock depends on the server. - This option should be relatively safe but does modify server behavior. Geyser or Floodgate must be installed.""") - private boolean itemSteerableFix = true; @Comment(""" Suppresses "Mismatch in destroy block pos" warnings so they don't spam each time e.g. grass is broken.\s @@ -28,10 +23,6 @@ public CollisionFixes collisionFixes() { return collisionFixes; } - public boolean itemSteerableFix() { - return itemSteerableFix; - } - public boolean suppressWarnings() { return suppressWarnings; } diff --git a/shared/src/main/java/net/onebeastchris/hurricane/mixin/EntityMixin.java b/shared/src/main/java/net/onebeastchris/hurricane/mixin/EntityMixin.java deleted file mode 100644 index a3195af..0000000 --- a/shared/src/main/java/net/onebeastchris/hurricane/mixin/EntityMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.onebeastchris.hurricane.mixin; - -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.ItemSteerable; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.player.Player; -import net.onebeastchris.hurricane.util.BedrockUtils; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(Entity.class) -public abstract class EntityMixin { - @Shadow public abstract @Nullable LivingEntity getControllingPassenger(); - - @Inject(method = "isControlledByLocalInstance", at = @At("RETURN"), cancellable = true) - private void isLogicalSideForUpdatingMovement(CallbackInfoReturnable cir) { - if (this.getControllingPassenger() instanceof Player player && this instanceof ItemSteerable) { - if (BedrockUtils.isBedrockPlayer(player.getUUID())) { - cir.setReturnValue(true); - } - } - } -} \ No newline at end of file diff --git a/shared/src/main/java/net/onebeastchris/hurricane/mixin/MixinConfigPlugin.java b/shared/src/main/java/net/onebeastchris/hurricane/mixin/MixinConfigPlugin.java index 406d5ba..bd50150 100644 --- a/shared/src/main/java/net/onebeastchris/hurricane/mixin/MixinConfigPlugin.java +++ b/shared/src/main/java/net/onebeastchris/hurricane/mixin/MixinConfigPlugin.java @@ -26,7 +26,6 @@ public String getRefMapperConfig() { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { return switch (mixinClassName) { - case "net.onebeastchris.hurricane.mixin.EntityMixin" -> config.isItemSteerableFix(); case "net.onebeastchris.hurricane.mixin.BambooBlockMixin" -> config.isBamboo(); case "net.onebeastchris.hurricane.mixin.PointedDripstoneBlockMixin" -> config.isPointedDripstone(); case "net.onebeastchris.hurricane.mixin.ServerPlayerInteractionManagerMixin" -> config.isSuppressWarnings(); diff --git a/shared/src/main/resources/hurricane.mixins.json b/shared/src/main/resources/hurricane.mixins.json index cfb0e5e..beddfba 100644 --- a/shared/src/main/resources/hurricane.mixins.json +++ b/shared/src/main/resources/hurricane.mixins.json @@ -1,10 +1,9 @@ { "required": true, "package": "net.onebeastchris.hurricane.mixin", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_17", "mixins": [ "BambooBlockMixin", - "EntityMixin", "PointedDripstoneBlockMixin", "ServerPlayerInteractionManagerMixin" ],