diff --git a/README.md b/README.md index 39977e9da..e43375975 100644 --- a/README.md +++ b/README.md @@ -91,5 +91,20 @@ If you want to make some changes to the mod, follow this guide: * Click **Add Standard VM**; in the JRE home, navigate to the directory where the JDK is installed, then click finish and select it. 10. Code! +## Compatibility notice +NTM has certain behaviors intended to fix vanilla code or to increase compatibility in certain cases where it otherwise would not be possible. These behaviors have the potential of not playing well with other mods, and while no such cases are currently known, here's a list of them. + +### Skybox chainloader +NTM adds a few small things to the skybox using a custom skybox renderer. Minecraft can only have a single skybox renderer loaded, so setting the skybox to the NTM custom one would break compatibility with other mods' skyboxes. To mend this, NTM employs a **chainloader**. This chainloader will detect if a different skybox is loaded, save a reference to that skybox and then use NTM's skybox, which when used will also make sure to run the previous modded skybox renderer. In the event that NTM's skybox were to cause trouble, it can be disabled with the config option `1.31_enableSkyboxes`. + +### Custom world provider +A world provider is a piece of code that minecraft can load to determine certain aspects of how the world should be handled, like light levels, sky color, day/night cycle, etc. In order for the Tomp impact effects to work, NTM employs such a world provider, although this is known to cause issues with Hardcore Darkness. The world provider can be disabled with the config option `1.32_enableImpactWorldProvider`. + +### Stat re-registering +An often overlooked aspect of Minecraft is its stats, the game keeps track of how many of an item were crafted, placed, broken, etc. By default, Minecraft can only handle vanilla items, modded items would not show up in the stats window. Forge does little to fix this, and since NTM has to keep track of certain things (such as use of an acidizer for spawning Mask Man) it will run its own code which re-registers all stats for all modded items. In the event that re-registering causes issues, or another mod already does this but better, this behavior can be disabled with the config option `1.33_enableStatReRegistering`. + +### Keybind overlap +An often annoying aspect of modded Minecraft is its keybinds. Even though multiple binds can be assigned the same key, all but one will show up as "conflicting" and only the non-conflicting one will work. Which one this is is usually arbitrary, and there is no reason to have such limitation. Often times keybinds are only applicable in certain scenarios, and a commonly found degree of overlap is within reason. Therefore, NTM will run its own key handling code which allows conflicting keybinds to work. If there should be any issues with this behavior, it can be disabled with the config option `1.34_enableKeybindOverlap`. + # License This software is licensed under the GNU Lesser General Public License version 3. In short: This software is free, you may run the software freely, create modified versions, distribute this software and distribute modified versions, as long as the modified software too has a free software license (with an exception for linking to this software, as stated by the "Lesser" part of the LGPL, where this may not be required). You win this round, Stallman. The full license can be found in the `LICENSE` and `LICENSE.LESSER` files. diff --git a/src/main/java/com/hbm/config/GeneralConfig.java b/src/main/java/com/hbm/config/GeneralConfig.java index 2e4b79920..557ca2a0c 100644 --- a/src/main/java/com/hbm/config/GeneralConfig.java +++ b/src/main/java/com/hbm/config/GeneralConfig.java @@ -31,6 +31,7 @@ public class GeneralConfig { public static boolean enableSkyboxes = true; public static boolean enableImpactWorldProvider = true; public static boolean enableStatReRegistering = true; + public static boolean enableKeybindOverlap = true; public static int hintPos = 0; public static boolean enable528 = false; @@ -89,6 +90,7 @@ public class GeneralConfig { enableSkyboxes = config.get(CATEGORY_GENERAL, "1.31_enableSkyboxes", true, "If enabled, will try to use NTM's custom skyboxes.").getBoolean(true); enableImpactWorldProvider = config.get(CATEGORY_GENERAL, "1.32_enableImpactWorldProvider", true, "If enabled, registers custom world provider which modifies lighting and sky colors for post impact effects.").getBoolean(true); enableStatReRegistering = config.get(CATEGORY_GENERAL, "1.33_enableStatReRegistering", true, "If enabled, will re-register item crafting/breaking/usage stats in order to fix a forge bug where modded items just won't show up.").getBoolean(true); + enableKeybindOverlap = config.get(CATEGORY_GENERAL, "1.34_enableKeybindOverlap", true, "If enabled, will handle keybinds that would otherwise be ignored due to overlapping.").getBoolean(true); final String CATEGORY_528 = CommonConfig.CATEGORY_528; diff --git a/src/main/java/com/hbm/inventory/fluid/tank/FluidTank.java b/src/main/java/com/hbm/inventory/fluid/tank/FluidTank.java index ce98e9579..ee0dfe019 100644 --- a/src/main/java/com/hbm/inventory/fluid/tank/FluidTank.java +++ b/src/main/java/com/hbm/inventory/fluid/tank/FluidTank.java @@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; public class FluidTank { @@ -258,7 +259,9 @@ public class FluidTank { fluid = nbt.getInteger(s); int max = nbt.getInteger(s + "_max"); if(max > 0) - maxFluid = nbt.getInteger(s + "_max"); + maxFluid = max; + + fluid = MathHelper.clamp_int(fluid, 0, max); type = Fluids.fromName(nbt.getString(s + "_type")); //compat if(type == Fluids.NONE) diff --git a/src/main/java/com/hbm/main/ModEventHandlerClient.java b/src/main/java/com/hbm/main/ModEventHandlerClient.java index 0c181697b..de63427b1 100644 --- a/src/main/java/com/hbm/main/ModEventHandlerClient.java +++ b/src/main/java/com/hbm/main/ModEventHandlerClient.java @@ -83,6 +83,7 @@ import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent; import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; @@ -101,6 +102,7 @@ import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.Slot; @@ -954,6 +956,52 @@ public class ModEventHandlerClient { } } } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onMouseClicked(InputEvent.KeyInputEvent event) { + + if(GeneralConfig.enableKeybindOverlap) { + boolean state = Mouse.getEventButtonState(); + int keyCode = Mouse.getEventButton() - 100; + + //if anything errors here, run ./gradlew clean setupDecompWorkSpace + for(Object o : KeyBinding.keybindSet) { + KeyBinding key = (KeyBinding) o; + + if(key.getKeyCode() == keyCode && KeyBinding.hash.lookup(key.getKeyCode()) != key) { + + key.pressed = state; + if(state) { + key.pressTime++; + } + } + } + } + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onKeyTyped(InputEvent.KeyInputEvent event) { + + if(GeneralConfig.enableKeybindOverlap) { + boolean state = Keyboard.getEventKeyState(); + int keyCode = Keyboard.getEventKey(); + + //if anything errors here, run ./gradlew clean setupDecompWorkSpace + for(Object o : KeyBinding.keybindSet) { + KeyBinding key = (KeyBinding) o; + + if(key.getKeyCode() == keyCode && KeyBinding.hash.lookup(key.getKeyCode()) != key) { + + key.pressed = state; + if(state) { + key.pressTime++; + } + } + } + } + } @SideOnly(Side.CLIENT) @SubscribeEvent diff --git a/src/main/resources/META-INF/HBM_at.cfg b/src/main/resources/META-INF/HBM_at.cfg index 1cc05d2b5..5d2a92333 100644 --- a/src/main/resources/META-INF/HBM_at.cfg +++ b/src/main/resources/META-INF/HBM_at.cfg @@ -8,3 +8,10 @@ public net.minecraft.entity.monster.EntityCreeper func_146077_cc()V # ex # RenderCreeper public net.minecraft.client.renderer.entity.RenderCreeper field_77064_a # creeperModel + +# KeyBinding +public net.minecraft.client.settings.KeyBinding field_74516_a # keybindArray +public net.minecraft.client.settings.KeyBinding field_74514_b # hash +public net.minecraft.client.settings.KeyBinding field_151473_c # keybindSet +public net.minecraft.client.settings.KeyBinding field_74513_e # pressed +public net.minecraft.client.settings.KeyBinding field_151474_i # pressTime