diff --git a/Changelog.md b/Changelog.md index 3bf788d..79658c7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Changelog +## Version 0.33 +* [NEW] Warning in log and GUI if Storage Drawers version differs from the one targeted +* [FIXED] Compatibility with Storage Drawers 3.4.4 (Belgabor/DrawersBits#6) + ## Version 0.32 * [FIXED] Compatibility with Storage Drawers 3.3.0 (Belgabor/DrawersBits#5) diff --git a/build.properties b/build.properties index 51f77e1..c4db751 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ minecraft_version = 1.10.2 -forge_version = 12.18.1.2065 -mod_version = 0.32 +forge_version = 12.18.2.2122 +mod_version = 0.33 release_type = alpha diff --git a/src/main/java/mods/belgabor/bitdrawers/BitDrawers.java b/src/main/java/mods/belgabor/bitdrawers/BitDrawers.java index 51a4a3c..33d7752 100644 --- a/src/main/java/mods/belgabor/bitdrawers/BitDrawers.java +++ b/src/main/java/mods/belgabor/bitdrawers/BitDrawers.java @@ -12,24 +12,29 @@ import mods.belgabor.bitdrawers.core.BlockRegistry; import mods.belgabor.bitdrawers.core.CommonProxy; import mods.belgabor.bitdrawers.core.RecipeRegistry; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Mod; +import mods.belgabor.bitdrawers.gui.GuiScreenStartup; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.*; import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; -@Mod(modid = BitDrawers.MODID, version = BitDrawers.VERSION, name = BitDrawers.MODNAME, dependencies = "required-after:chiselsandbits@[11.6,);required-after:StorageDrawers@[1.10.2-3.3.0,);required-after:Chameleon") +@Mod(modid = BitDrawers.MODID, version = BitDrawers.VERSION, name = BitDrawers.MODNAME, dependencies = "required-after:chiselsandbits@[11.6,);required-after:StorageDrawers@[1.10.2-"+BitDrawers.SD_VERSION+",);required-after:Chameleon") @ChiselsAndBitsAddon public class BitDrawers implements IChiselsAndBitsAddon { public static final String MODNAME = "Drawers & Bits"; public static final String MODID = "bitdrawers"; - public static final String VERSION = "0.32"; + public static final String VERSION = "0.33"; + public static final String SD_VERSION = "3.4.4"; + public static final int[] SD_VERSIONS = {3, 4, 4}; @SidedProxy( clientSide = "mods.belgabor.bitdrawers.client.ClientProxy", @@ -41,6 +46,11 @@ public class BitDrawers implements IChiselsAndBitsAddon public static IChiselAndBitsAPI cnb_api; public static SimpleNetworkWrapper network; + + public static boolean sdVersionCheckFailed = true; + public static boolean sdMajorMismatch = false; + public static boolean sdMinorMismatch = false; + public static String detectedSdVersion = ""; public static BlockRegistry blocks = new BlockRegistry(); public static RecipeRegistry recipes = new RecipeRegistry(); @@ -53,6 +63,8 @@ public void preInit(FMLPreInitializationEvent event) network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID); blocks.init(); proxy.initClient(); + + MinecraftForge.EVENT_BUS.register(this); if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { network.registerMessage(CountUpdateMessage.Handler.class, CountUpdateMessage.class, 1, Side.CLIENT); @@ -60,6 +72,34 @@ public void preInit(FMLPreInitializationEvent event) else { network.registerMessage(CountUpdateMessage.HandlerStub.class, CountUpdateMessage.class, 1, Side.CLIENT); } + + ModContainer testContainer = Loader.instance().getIndexedModList().get("StorageDrawers"); + if (testContainer != null) { + String[] testVersion = testContainer.getDisplayVersion().split("-"); + if (testVersion.length == 2) { + String[] testVersionParts = testVersion[1].split("\\."); + detectedSdVersion = testVersion[1]; + if (testVersionParts.length == 3) { + sdVersionCheckFailed = false; + try { + if ((Integer.parseInt(testVersionParts[0]) != SD_VERSIONS[0]) || (Integer.parseInt(testVersionParts[1]) != SD_VERSIONS[1])) { + sdMajorMismatch = true; + BDLogger.warn("Your version of Storage Drawers (%s) differs majorly from the one Drawers & Bits was compiled with (%s). Use at your own discretion, in case of issues please open an issue on GitHub and revert the version of Storage Drawers to the one known working until I can fix compatibility.", detectedSdVersion, SD_VERSION); + } else if (Integer.parseInt(testVersionParts[2]) != SD_VERSIONS[2]) { + sdMinorMismatch = true; + BDLogger.warn("Your version of Storage Drawers (%s) differs from the one Drawers & Bits was compiled with (%s). The difference is minor so issues are unlikely, but if one occurs, please open an issue on GitHub and revert the version of Storage Drawers to the one known working until I can fix compatibility.", detectedSdVersion, SD_VERSION); + } else if (config.debugTrace) { + BDLogger.info("Drawers & Bits: Storage Drawers version check OK (%s).", detectedSdVersion); + } + } catch (NumberFormatException e) { + sdVersionCheckFailed = true; + } + } + } + } + if (sdVersionCheckFailed) { + BDLogger.error("Drawers & Bits: Unable to verify StorageDrawers version. This probably isn't going to end well..."); + } } @EventHandler @@ -67,6 +107,15 @@ public void postInit(FMLPostInitializationEvent event) { recipes.init(); } + @SubscribeEvent + @SideOnly( Side.CLIENT ) + public void openMainMenu(final GuiOpenEvent event ) { + // if the max shades has changed in form the user of the new usage. + if ((!detectedSdVersion.equals(config.lastSDVersionWarned)) && (sdMajorMismatch || sdMinorMismatch || sdVersionCheckFailed)) { + event.setGui(new GuiScreenStartup()); + } + } + @Override public void onReadyChiselsAndBits(IChiselAndBitsAPI api) { cnb_api = api; diff --git a/src/main/java/mods/belgabor/bitdrawers/block/tile/TileBitController.java b/src/main/java/mods/belgabor/bitdrawers/block/tile/TileBitController.java index e3d2dbf..835ddd4 100644 --- a/src/main/java/mods/belgabor/bitdrawers/block/tile/TileBitController.java +++ b/src/main/java/mods/belgabor/bitdrawers/block/tile/TileBitController.java @@ -222,7 +222,7 @@ protected void rebuildBitLookup (Map> lookup, List> lookup, List info = fontRendererObj.listFormattedStringToWidth( s, width - 40 ); + for ( final String infoCut : info ) + { + drawCenteredString( fontRendererObj, infoCut, width / 2, height / 2 - heightLoc, 0xFFFFFF ); + heightLoc = heightLoc - 12; + } + } + + super.drawScreen( mouseX, mouseY, partialTicks ); + } + + @Override + public void actionPerformed(final GuiButton button ) { + switch (button.id) { + case 0: { + for (final GuiButton b : buttonList) { + b.enabled = false; + } + + if (!BitDrawers.detectedSdVersion.equals("")) + BitDrawers.config.updateSDVersion(); + + mc.displayGuiScreen( null ); + + break; + } + } + } + + @Override + public boolean doesGuiPauseGame() + { + return false; + } +} diff --git a/src/main/resources/assets/bitdrawers/lang/en_US.lang b/src/main/resources/assets/bitdrawers/lang/en_US.lang index 003927f..0e4965a 100644 --- a/src/main/resources/assets/bitdrawers/lang/en_US.lang +++ b/src/main/resources/assets/bitdrawers/lang/en_US.lang @@ -7,3 +7,13 @@ bitDrawers.config.prop.enableDebugLogging.tooltip=Prints extra information to th bitDrawers.config.prop.bitdrawerBaseStorage=Bit Drawer Base Storage bitDrawers.config.prop.bitdrawerBaseStorage.tooltip=Base storage of a bit drawer (stacks). chat.notEnough=Not enough bits available: %s +bitDrawers.startup_a=Due to it's internal workings, Drawers & Bits highly depends on the version of Storage Drawers. +bitDrawers.startup_b=This version was developed for version %s, you have installed version %s. +bitDrawers.startup_min=That's a minor difference, so it is unlikely to cause an issue. +bitDrawers.startup_maj=The numbers indicate a possibly breaking change, so crashes may occur. +bitDrawers.startup_fubar=The version check failed, so things will probably fall apart. +bitDrawers.startup_c=In any case it is highly recommended to make a backup before loading any world. +bitDrawers.startup_d=If any problem occurs, please open an issue on the GitHub issue tracker (linked on the Curse project page). +bitDrawers.startup_e=Note: This warning will not show up again until the version of Storage Drawers changes. + +