diff --git a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableKeybinding.java b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableKeybinding.java index c210663..21eac72 100644 --- a/src/minecraft/net/machinemuse/general/gui/clickable/ClickableKeybinding.java +++ b/src/minecraft/net/machinemuse/general/gui/clickable/ClickableKeybinding.java @@ -8,12 +8,15 @@ import net.machinemuse.general.geometry.Colour; import net.machinemuse.general.geometry.MusePoint2D; import net.machinemuse.general.geometry.MuseRenderer; import net.machinemuse.powersuits.item.ItemUtils; +import net.machinemuse.powersuits.network.packets.MusePacketToggleRequest; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.player.EntityPlayer; import org.lwjgl.input.Keyboard; +import cpw.mods.fml.common.network.Player; + public class ClickableKeybinding extends ClickableButton { protected List boundModules; protected KeyBinding keybind; @@ -43,7 +46,7 @@ public class ClickableKeybinding extends ClickableButton { } public void toggleModules() { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; + EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; if (player == null) { return; } @@ -51,6 +54,7 @@ public class ClickableKeybinding extends ClickableButton { String valstring = toggleval ? " on" : " off"; player.sendChatToPlayer("Toggled " + module.getModule().getName() + valstring); ItemUtils.toggleModuleForPlayer(player, module.getModule().getName(), toggleval); + MusePacketToggleRequest toggleRequest = new MusePacketToggleRequest((Player) player, module.getModule().getName(), toggleval); } toggleval = !toggleval; } diff --git a/src/minecraft/net/machinemuse/powersuits/item/ItemUtils.java b/src/minecraft/net/machinemuse/powersuits/item/ItemUtils.java index 96a0b5b..1c9ad4f 100644 --- a/src/minecraft/net/machinemuse/powersuits/item/ItemUtils.java +++ b/src/minecraft/net/machinemuse/powersuits/item/ItemUtils.java @@ -43,7 +43,9 @@ public class ItemUtils { } public static boolean isModuleActive(NBTTagCompound itemTag, String moduleName) { - if (ItemUtils.tagHasModule(itemTag, moduleName) && itemTag.getCompoundTag(moduleName).getBoolean(ACTIVE)) { + if (ItemUtils.tagHasModule(itemTag, moduleName) && !itemTag.getCompoundTag(moduleName).hasKey(ACTIVE)) { + return true; + } else if (ItemUtils.tagHasModule(itemTag, moduleName) && itemTag.getCompoundTag(moduleName).getBoolean(ACTIVE)) { return true; } return false; @@ -506,4 +508,8 @@ public class ItemUtils { } + public static boolean itemHasActiveModule(ItemStack pants, String module) { + return itemHasModule(pants, module) && isModuleActive(getMuseItemTag(pants), module); + } + } diff --git a/src/minecraft/net/machinemuse/powersuits/item/ModularCommon.java b/src/minecraft/net/machinemuse/powersuits/item/ModularCommon.java index 5312386..9f4a60e 100644 --- a/src/minecraft/net/machinemuse/powersuits/item/ModularCommon.java +++ b/src/minecraft/net/machinemuse/powersuits/item/ModularCommon.java @@ -171,7 +171,13 @@ public abstract class ModularCommon { } public static double getJoules(ItemStack stack) { - return ItemUtils.getDoubleOrZero(stack, CURRENT_ENERGY); + double joules = ItemUtils.getDoubleOrZero(stack, CURRENT_ENERGY); + double maxJoules = getMaxJoules(stack); + if (joules > maxJoules) { + joules = maxJoules; + setJoules(joules, stack); + } + return joules; } public static void setJoules(double joules, ItemStack stack) { @@ -180,9 +186,6 @@ public abstract class ModularCommon { public static double getMaxJoules(ItemStack stack) { double maxJoules = ModuleManager.computeModularProperty(stack, ModularCommon.MAXIMUM_ENERGY); - if (getJoules(stack) > maxJoules) { - setJoules(maxJoules, stack); - } return maxJoules; } diff --git a/src/minecraft/net/machinemuse/powersuits/network/MusePacket.java b/src/minecraft/net/machinemuse/powersuits/network/MusePacket.java index b834f00..21ae5d8 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/MusePacket.java +++ b/src/minecraft/net/machinemuse/powersuits/network/MusePacket.java @@ -43,7 +43,7 @@ public abstract class MusePacket { writeInt(id); } - protected MusePacket(Player player, DataInputStream data) { + protected MusePacket(DataInputStream data, Player player) { this.player = player; this.datain = data; } diff --git a/src/minecraft/net/machinemuse/powersuits/network/MusePacketHandler.java b/src/minecraft/net/machinemuse/powersuits/network/MusePacketHandler.java index 55a6cb5..551a2b2 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/MusePacketHandler.java +++ b/src/minecraft/net/machinemuse/powersuits/network/MusePacketHandler.java @@ -45,7 +45,7 @@ public class MusePacketHandler implements IPacketHandler { addPacketType(4, MusePacketTweakRequest.class); addPacketType(5, MusePacketFallDistance.class); addPacketType(6, MusePacketPlayerUpdate.class); - addPacketType(6, MusePacketToggleRequest.class); + addPacketType(7, MusePacketToggleRequest.class); NetworkRegistry.instance().registerChannel(this, Config.getNetworkChannelName()); diff --git a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketFallDistance.java b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketFallDistance.java index 0340d86..59f5b81 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketFallDistance.java +++ b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketFallDistance.java @@ -19,7 +19,7 @@ public class MusePacketFallDistance extends MusePacket { } public MusePacketFallDistance(DataInputStream data, Player player) { - super(player, data); + super(data, player); distance = readDouble(); } diff --git a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketInstallModuleRequest.java b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketInstallModuleRequest.java index 6c9b826..fb12a30 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketInstallModuleRequest.java +++ b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketInstallModuleRequest.java @@ -60,7 +60,7 @@ public class MusePacketInstallModuleRequest extends MusePacket { * */ public MusePacketInstallModuleRequest(DataInputStream data, Player player) { - super(player, data); + super(data, player); itemSlot = readInt(); moduleName = readString(64); Side side = FMLCommonHandler.instance().getEffectiveSide(); diff --git a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketInventoryRefresh.java b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketInventoryRefresh.java index 79ecd3a..8a66265 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketInventoryRefresh.java +++ b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketInventoryRefresh.java @@ -38,7 +38,7 @@ public class MusePacketInventoryRefresh extends MusePacket { * @param data */ public MusePacketInventoryRefresh(DataInputStream datain, Player player) { - super(player, datain); + super(datain, player); slot = readInt(); stack = readItemStack(); } diff --git a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketModeChangeRequest.java b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketModeChangeRequest.java index ec2a11f..1cecc61 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketModeChangeRequest.java +++ b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketModeChangeRequest.java @@ -29,7 +29,7 @@ public class MusePacketModeChangeRequest extends MusePacket { * @param data */ public MusePacketModeChangeRequest(Player player, DataInputStream data) { - super(player, data); + super(data, player); // TODO Auto-generated constructor stub } diff --git a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketPlayerUpdate.java b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketPlayerUpdate.java index 78169a2..a44b3cf 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketPlayerUpdate.java +++ b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketPlayerUpdate.java @@ -29,7 +29,7 @@ public class MusePacketPlayerUpdate extends MusePacket { } public MusePacketPlayerUpdate(DataInputStream data, Player player) { - super(player, data); + super(data, player); energyAdjustment = readDouble(); exhaustionAdjustment = readDouble(); motionX = readDouble(); diff --git a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketSalvageModuleRequest.java b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketSalvageModuleRequest.java index c7ab830..0df6f24 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketSalvageModuleRequest.java +++ b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketSalvageModuleRequest.java @@ -61,7 +61,7 @@ public class MusePacketSalvageModuleRequest extends MusePacket { * */ public MusePacketSalvageModuleRequest(DataInputStream data, Player player) { - super(player, data); + super(data, player); itemSlot = readInt(); moduleName = readString(64); Side side = FMLCommonHandler.instance().getEffectiveSide(); diff --git a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketToggleRequest.java b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketToggleRequest.java index 6ce2da9..9c185bd 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketToggleRequest.java +++ b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketToggleRequest.java @@ -13,14 +13,14 @@ public class MusePacketToggleRequest extends MusePacket { String module; boolean value; - protected MusePacketToggleRequest(Player player, String module, boolean active) { + public MusePacketToggleRequest(Player player, String module, boolean active) { super(player); writeString(module); writeBoolean(active); } - protected MusePacketToggleRequest(Player player, DataInputStream data) { - super(player, data); + public MusePacketToggleRequest(DataInputStream data, Player player) { + super(data, player); module = readString(64); value = readBoolean(); } diff --git a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketTweakRequest.java b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketTweakRequest.java index a47e2fb..c5f135c 100644 --- a/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketTweakRequest.java +++ b/src/minecraft/net/machinemuse/powersuits/network/packets/MusePacketTweakRequest.java @@ -59,7 +59,7 @@ public class MusePacketTweakRequest extends MusePacket { * */ public MusePacketTweakRequest(DataInputStream data, Player player) { - super(player, data); + super(data, player); itemSlot = readInt(); moduleName = readString(64); tweakName = readString(64); diff --git a/src/minecraft/net/machinemuse/powersuits/tick/PlayerTickHandlerClient.java b/src/minecraft/net/machinemuse/powersuits/tick/PlayerTickHandlerClient.java index 6c22091..02a6bd2 100644 --- a/src/minecraft/net/machinemuse/powersuits/tick/PlayerTickHandlerClient.java +++ b/src/minecraft/net/machinemuse/powersuits/tick/PlayerTickHandlerClient.java @@ -84,17 +84,17 @@ public class PlayerTickHandlerClient implements ITickHandler { boolean hasSwimAssist = false; if (pants != null && pants.getItem() instanceof IModularItem) { - hasSprintAssist = ItemUtils.itemHasModule(pants, ModularCommon.MODULE_SPRINT_ASSIST); - hasJumpAssist = ItemUtils.itemHasModule(pants, ModularCommon.MODULE_JUMP_ASSIST); - hasSwimAssist = ItemUtils.itemHasModule(pants, ModularCommon.MODULE_SWIM_BOOST); + hasSprintAssist = ItemUtils.itemHasActiveModule(pants, ModularCommon.MODULE_SPRINT_ASSIST); + hasJumpAssist = ItemUtils.itemHasActiveModule(pants, ModularCommon.MODULE_JUMP_ASSIST); + hasSwimAssist = ItemUtils.itemHasActiveModule(pants, ModularCommon.MODULE_SWIM_BOOST); } if (boots != null && boots.getItem() instanceof IModularItem) { - hasJetboots = ItemUtils.itemHasModule(boots, ModularCommon.MODULE_JETBOOTS); + hasJetboots = ItemUtils.itemHasActiveModule(boots, ModularCommon.MODULE_JETBOOTS); } if (torso != null && torso.getItem() instanceof IModularItem) { - hasJetpack = ItemUtils.itemHasModule(torso, ModularCommon.MODULE_JETPACK); - hasGlider = ItemUtils.itemHasModule(torso, ModularCommon.MODULE_GLIDER); - hasParachute = ItemUtils.itemHasModule(torso, ModularCommon.MODULE_PARACHUTE); + hasJetpack = ItemUtils.itemHasActiveModule(torso, ModularCommon.MODULE_JETPACK); + hasGlider = ItemUtils.itemHasActiveModule(torso, ModularCommon.MODULE_GLIDER); + hasParachute = ItemUtils.itemHasActiveModule(torso, ModularCommon.MODULE_PARACHUTE); } if (player.isInWater()) { @@ -129,6 +129,7 @@ public class PlayerTickHandlerClient implements ITickHandler { } } else { if (hasJumpAssist && jumpkey) { + player.jumpMovementFactor = player.landMovementFactor; double multiplier = MovementManager.getPlayerJumpMultiplier(player); if (multiplier > 0) { player.motionY += 0.15 * Math.min(multiplier, 1) * getWeightPenaltyRatio(totalWeight, weightCapacity); @@ -202,6 +203,7 @@ public class PlayerTickHandlerClient implements ITickHandler { foodAdjustment += 0.01 * exhaustion * exhaustionComp; } + player.jumpMovementFactor = player.landMovementFactor; } }