mirror of
https://github.com/GTNewHorizons/Electro-Magic-Tools.git
synced 2026-11-18 19:29:29 +00:00
Allow changing Electric Boots using ThaumicBoots Keybinds. (#75)
* Allow changing Traveler Boots speed using ThaumicBoots Keybinds. * Air speed bonus gets modified by speedModifier * Spotless Apply :/ * Added the temp lib file for tests This should instead use the remote dependency system once TB PR 27 is merged * Fix potential NSM exception when GTNH Thaumic Boots is not present. * Spotless apply. * Now using ThaumicBoots 1.2.2-Pre build * Delete ThaumicBoots-1.2.1-master+4e33b9941e-dirty-dev.jar * Fixed DuplicateMod, Excluded EMT from the ThaumicBoots pre jar * Fixing the EMT Issues + Updating the way the Electric Boots Work * Update dependencies.gradle * update --------- Co-authored-by: Alastors <[email protected]> Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
7 files changed
+59
-13
No files matched your search
@@ -7,6 +7,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
@@ -65,12 +66,18 @@ public class EMT {
|
||||
@Mod.Instance("EMT")
|
||||
public static EMT instance;
|
||||
|
||||
public static boolean isBootsActive = false;
|
||||
public static final String BOOTS = "thaumicboots";
|
||||
|
||||
public boolean isSimulating() {
|
||||
return !FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
if (Loader.isModLoaded(BOOTS)) {
|
||||
isBootsActive = true;
|
||||
}
|
||||
EMTConfigHandler.init(event.getSuggestedConfigurationFile());
|
||||
FMLCommonHandler.instance().bus().register(new EMTEventHandler());
|
||||
if (FMLCommonHandler.instance().getSide().isClient()) {
|
||||
|
||||
@@ -18,6 +18,8 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -33,9 +35,11 @@ import thaumcraft.api.IVisDiscountGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.items.armor.Hover;
|
||||
import thaumicboots.api.IBoots;
|
||||
|
||||
@Interface(iface = "thaumicboots.api.IBoots", modid = "thaumicboots")
|
||||
public class ItemElectricBootsTraveller extends ItemArmor
|
||||
implements IRunicArmor, IElectricItem, IVisDiscountGear, IMetalArmor, ISpecialArmor {
|
||||
implements IRunicArmor, IElectricItem, IVisDiscountGear, IMetalArmor, ISpecialArmor, IBoots {
|
||||
|
||||
public int maxCharge = 100000;
|
||||
public int energyPerDamage = 1000;
|
||||
@@ -128,8 +132,8 @@ public class ItemElectricBootsTraveller extends ItemArmor
|
||||
}
|
||||
player.stepHeight = 1.0F;
|
||||
}
|
||||
|
||||
if (player.onGround) {
|
||||
float speedMod = (float) getSpeedModifier(itemStack);
|
||||
if (player.onGround || player.isOnLadder() || player.capabilities.isFlying) {
|
||||
float bonus = speedBonus;
|
||||
if (player.isInWater()) {
|
||||
bonus /= 4.0F;
|
||||
@@ -138,29 +142,45 @@ public class ItemElectricBootsTraveller extends ItemArmor
|
||||
if (player.isSneaking()) {
|
||||
bonus /= 2.0F;
|
||||
}
|
||||
|
||||
player.moveFlying(player.moveStrafing, player.moveForward, bonus);
|
||||
bonus *= speedMod;
|
||||
if (EMT.isBootsActive) {
|
||||
applyOmniState(player, bonus, itemStack);
|
||||
} else {
|
||||
player.moveFlying(0.0F, player.moveForward, bonus);
|
||||
}
|
||||
} else if (Hover.getHover(player.getEntityId())) {
|
||||
// Base ItemBootsTraveller jumpBonus equals to jumpBonus of Electric Boots,
|
||||
// so any other boots factor can be calculated via proportion method
|
||||
player.jumpMovementFactor = 0.03F
|
||||
/ ((ItemElectricBootsTraveller) EMTItems.electricBootsTraveller).jumpBonus
|
||||
* jumpBonus;
|
||||
* jumpBonus
|
||||
* speedMod;
|
||||
} else {
|
||||
player.jumpMovementFactor = 0.05F
|
||||
/ ((ItemElectricBootsTraveller) EMTItems.electricBootsTraveller).jumpBonus
|
||||
* jumpBonus;
|
||||
* jumpBonus
|
||||
* speedMod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "thaumicboots")
|
||||
public void applyOmniState(EntityPlayer player, float bonus, ItemStack itemStack) {
|
||||
if (player.moveStrafing != 0.0 && itemStack.stackTagCompound.getBoolean("omni")) {
|
||||
player.moveFlying(player.moveStrafing, 0.0F, bonus);
|
||||
} else if (player.moveForward != 0.0) {
|
||||
player.moveFlying(0.0F, player.moveForward, bonus);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerJump(LivingEvent.LivingJumpEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
boolean hasArmor = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem() == this;
|
||||
ItemStack boots = player.getCurrentArmor(0);
|
||||
boolean hasArmor = boots != null && boots.getItem() == this;
|
||||
|
||||
if (hasArmor) player.motionY += jumpBonus;
|
||||
if (hasArmor) player.motionY += jumpBonus * (float) getJumpModifier(boots);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,4 +296,19 @@ public class ItemElectricBootsTraveller extends ItemArmor
|
||||
public int getRunicCharge(ItemStack itemStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Avoid NSM Exception when ThaumicBoots is not present.
|
||||
public double getSpeedModifier(ItemStack stack) {
|
||||
if (stack.stackTagCompound != null) {
|
||||
return stack.stackTagCompound.getDouble("speed");
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
public double getJumpModifier(ItemStack stack) {
|
||||
if (stack.stackTagCompound != null) {
|
||||
return stack.stackTagCompound.getDouble("jump");
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user