Changed it so sprint assist and jump assist boost your aerial horizontal movement
also fixed the problem with the toggle packet
This commit is contained in:
parent
3d6870525d
commit
4d836abf41
14 changed files with 41 additions and 26 deletions
|
@ -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<ClickableModule> 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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -19,7 +19,7 @@ public class MusePacketFallDistance extends MusePacket {
|
|||
}
|
||||
|
||||
public MusePacketFallDistance(DataInputStream data, Player player) {
|
||||
super(player, data);
|
||||
super(data, player);
|
||||
distance = readDouble();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue