Skip to content

Commit

Permalink
Allow changing Electric Boots using ThaumicBoots Keybinds. (#75)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored May 6, 2024
1 parent 547db6d commit 74d1ace
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 13 deletions.
6 changes: 5 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// Add your dependencies here

dependencies {
compileOnly 'com.github.GTNewHorizons:GT5-Unofficial:5.09.45.130:dev'
compileOnly 'com.github.GTNewHorizons:GT5-Unofficial:5.09.46.05:dev'
api 'com.github.GTNewHorizons:Baubles:1.0.4:dev'
api 'com.github.GTNewHorizons:ModularUI:1.1.42:dev'
api ('com.github.GTNewHorizons:ThaumicBoots:1.3.0:dev'){
exclude group: 'com.github.GTNewHorizons', module: 'Electro-Magic-Tools'
}


api 'net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev'
api 'thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true

# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true

# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.19'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'
}


7 changes: 7 additions & 0 deletions src/main/java/emt/EMT.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;
Expand Down Expand Up @@ -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()) {
Expand Down
53 changes: 44 additions & 9 deletions src/main/java/emt/item/armor/boots/ItemElectricBootsTraveller.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
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;
Expand All @@ -33,9 +35,11 @@
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;
Expand Down Expand Up @@ -128,8 +132,8 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
}
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;
Expand All @@ -138,29 +142,45 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
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);
}
}

Expand Down Expand Up @@ -276,4 +296,19 @@ public Item getEmptyItem(ItemStack itemStack) {
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;
}
}

0 comments on commit 74d1ace

Please sign in to comment.