diff --git a/gradle.properties b/gradle.properties index b3dcccb..6093577 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,6 +11,6 @@ halplibe_version=2.7.0 prismatic_version=2.1.1 terrain_api_version=1.3.1 # Mod -mod_version=1.6.4 +mod_version=1.6.5 mod_group=baguchan mod_name=better_with_aquatic diff --git a/src/main/java/baguchan/better_with_aquatic/BetterWithAquatic.java b/src/main/java/baguchan/better_with_aquatic/BetterWithAquatic.java index 1dc66f9..cbf24c5 100644 --- a/src/main/java/baguchan/better_with_aquatic/BetterWithAquatic.java +++ b/src/main/java/baguchan/better_with_aquatic/BetterWithAquatic.java @@ -1,7 +1,5 @@ package baguchan.better_with_aquatic; -import baguchan.better_with_aquatic.block.ModBlocks; -import baguchan.better_with_aquatic.compat.SpawnEggCompat; import baguchan.better_with_aquatic.entity.EntityAnglerFish; import baguchan.better_with_aquatic.entity.EntityFish; import baguchan.better_with_aquatic.entity.render.AnglerFishModel; @@ -9,55 +7,20 @@ import baguchan.better_with_aquatic.entity.render.RenderAnglerFish; import baguchan.better_with_aquatic.entity.render.RenderFish; import baguchan.better_with_aquatic.packet.SwimPacket; -import baguchan.better_with_aquatic.util.IDUtils; import net.fabricmc.api.ModInitializer; -import net.minecraft.core.block.Block; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import turniplabs.halplibe.helper.EntityHelper; import turniplabs.halplibe.helper.NetworkHelper; -import turniplabs.halplibe.util.ConfigHandler; -import useless.prismaticlibe.helper.ModCheckHelper; - -import java.util.Properties; public class BetterWithAquatic implements ModInitializer { public static final String MOD_ID = "better_with_aquatic"; - public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - private static boolean enable_swim; - public static final boolean spawnEggsModPresent = ModCheckHelper.checkForMod("spawneggs", ">=1.1.0"); - - - private void handleConfig() { - Properties prop = new Properties(); - prop.setProperty("starting_block_id", "561"); - prop.setProperty("starting_item_id", "2000"); - prop.setProperty("enable_swim", "true"); - ConfigHandler config = new ConfigHandler(MOD_ID, prop); - IDUtils.initIds( - config.getInt("starting_block_id"), - config.getInt("starting_item_id")); - enable_swim = config.getBoolean("enable_swim"); - config.updateConfig(); - } @Override public void onInitialize() { - this.handleConfig(); - Block.lightOpacity[Block.fluidWaterFlowing.id] = 1; - Block.lightOpacity[Block.fluidWaterStill.id] = 1; - ModBlocks.createBlocks(); - if (spawnEggsModPresent) { - SpawnEggCompat.onInitialize(); - } EntityHelper.createEntity(EntityFish.class, new RenderFish(new FishModel(), 0.3F), 600, "Fish"); EntityHelper.createEntity(EntityAnglerFish.class, new RenderAnglerFish(new AnglerFishModel(), 0.4F), 601, "AnglerFish"); NetworkHelper.register(SwimPacket.class, true, false); - } - public static boolean isEnableSwim() { - return enable_swim; } } diff --git a/src/main/java/baguchan/better_with_aquatic/BetterWithAquaticPreLaunch.java b/src/main/java/baguchan/better_with_aquatic/BetterWithAquaticPreLaunch.java new file mode 100644 index 0000000..ed1e570 --- /dev/null +++ b/src/main/java/baguchan/better_with_aquatic/BetterWithAquaticPreLaunch.java @@ -0,0 +1,56 @@ +package baguchan.better_with_aquatic; + +import baguchan.better_with_aquatic.block.ModBlocks; +import baguchan.better_with_aquatic.compat.SpawnEggCompat; +import baguchan.better_with_aquatic.util.IDUtils; +import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; +import net.minecraft.core.block.Block; +import turniplabs.halplibe.util.ConfigHandler; +import useless.prismaticlibe.helper.ModCheckHelper; + +import java.util.Properties; + +public class BetterWithAquaticPreLaunch implements PreLaunchEntrypoint { + static { + // DO NOT TOUCH THIS! It's an error prevention method. Thanks Useless! + try { + Class.forName("turniplabs.halplibe.HalpLibe"); + Class.forName("net.minecraft.core.block.Block"); + Class.forName("net.minecraft.core.item.Item"); + } catch (ClassNotFoundException ignored) { + } + } + + private static boolean enable_swim; + public static final boolean spawnEggsModPresent = ModCheckHelper.checkForMod("spawneggs", ">=1.1.0"); + + + private void handleConfig() { + Properties prop = new Properties(); + prop.setProperty("starting_block_id", "561"); + prop.setProperty("starting_item_id", "2000"); + prop.setProperty("enable_swim", "true"); + ConfigHandler config = new ConfigHandler(BetterWithAquatic.MOD_ID, prop); + IDUtils.initIds( + config.getInt("starting_block_id"), + config.getInt("starting_item_id")); + enable_swim = config.getBoolean("enable_swim"); + config.updateConfig(); + } + + @Override + public void onPreLaunch() { + this.handleConfig(); + Block.lightOpacity[Block.fluidWaterFlowing.id] = 1; + Block.lightOpacity[Block.fluidWaterStill.id] = 1; + ModBlocks.createBlocks(); + if (spawnEggsModPresent) { + SpawnEggCompat.onInitialize(); + } + } + + + public static boolean isEnableSwim() { + return enable_swim; + } +} diff --git a/src/main/java/baguchan/better_with_aquatic/mixin/client/KeyboardInputMixin.java b/src/main/java/baguchan/better_with_aquatic/mixin/client/KeyboardInputMixin.java index 344f9f6..a391ea6 100644 --- a/src/main/java/baguchan/better_with_aquatic/mixin/client/KeyboardInputMixin.java +++ b/src/main/java/baguchan/better_with_aquatic/mixin/client/KeyboardInputMixin.java @@ -1,6 +1,6 @@ package baguchan.better_with_aquatic.mixin.client; -import baguchan.better_with_aquatic.BetterWithAquatic; +import baguchan.better_with_aquatic.BetterWithAquaticPreLaunch; import baguchan.better_with_aquatic.api.ISwiming; import net.minecraft.client.input.KeyboardInput; import net.minecraft.client.option.GameSettings; @@ -32,7 +32,7 @@ public void tick(EntityPlayer entityplayer, CallbackInfo ci) { if (entityplayer.isUnderLiquid(Material.water) && !entityplayer.isSneaking()) { if (keys[0]) { if (this.sprintTime < 9 && !this.pressedSprint) { - if (BetterWithAquatic.isEnableSwim()) { + if (BetterWithAquaticPreLaunch.isEnableSwim()) { ((ISwiming) entityplayer).setSwimming(true); } } else { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index aaadb4b..22c8aaf 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,6 +24,9 @@ ], "terrain-api": [ "baguchan.better_with_aquatic.TerrainAPIPlugin" + ], + "preLaunch": [ + "baguchan.better_with_aquatic.BetterWithAquaticPreLaunch" ] }, "mixins": [