Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding TBoots soft dep #27

Merged
merged 3 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

dependencies {
compile('com.github.GTNewHorizons:Baubles:1.0.4:dev')

compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compile ('com.github.GTNewHorizons:ThaumicBoots:1.3.5:dev'){
exclude group: 'com.github.GTNewHorizons', module: 'Tainted-Magic'
}
}
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.15'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'
}


8 changes: 7 additions & 1 deletion src/main/java/taintedmagic/common/TaintedMagic.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
Expand Down Expand Up @@ -55,11 +56,16 @@ public class TaintedMagic {
public static final Logger log = LogManager.getLogger("TAINTEDMAGIC");
public static EnumRarity rarityCreation = EnumHelper.addRarity("CREATION", EnumChatFormatting.GOLD, "Creation");

public static boolean isBootsActive = false;
public static final String BOOTS = "thaumicboots";

// Pre init
@EventHandler
public static void preInit(FMLPreInitializationEvent event) {
log.info("Please stand back... Pre-initializing Tainted Magic!");

if (Loader.isModLoaded(BOOTS)) {
isBootsActive = true;
}
// Config
configHandler.config = new Configuration(event.getSuggestedConfigurationFile());
configHandler.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent;

import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import taintedmagic.common.TaintedMagic;
import taintedmagic.common.registry.ItemRegistry;
Expand All @@ -24,9 +25,11 @@
import thaumcraft.api.aspects.Aspect;
import thaumcraft.common.Thaumcraft;
import thaumcraft.common.items.armor.Hover;
import thaumicboots.api.IBoots;

@Optional.Interface(iface = "thaumicboots.api.IBoots", modid = "thaumicboots")
public class ItemVoidwalkerBoots extends ItemArmor
implements IVisDiscountGear, IWarpingGear, IRunicArmor, IRepairable, ISpecialArmor {
implements IVisDiscountGear, IWarpingGear, IRunicArmor, IRepairable, ISpecialArmor, IBoots {

public ItemVoidwalkerBoots(ArmorMaterial m, int j, int k) {
super(m, j, k);
Expand Down Expand Up @@ -99,42 +102,107 @@ public void onUpdate(ItemStack s, World w, Entity e, int j, boolean k) {
s.damageItem(-1, (EntityLivingBase) e);
}

public void onArmorTick(World w, EntityPlayer p, ItemStack s) {
super.onArmorTick(w, p, s);
if ((!w.isRemote) && (s.getItemDamage() > 0) && (p.ticksExisted % 20 == 0)) s.damageItem(-1, p);
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
super.onArmorTick(world, player, itemStack);
if ((!world.isRemote) && (itemStack.getItemDamage() > 0) && (player.ticksExisted % 20 == 0))
itemStack.damageItem(-1, player);
if (getIntertialState(itemStack) && player.moveForward == 0
&& player.moveStrafing == 0
&& player.capabilities.isFlying) {
player.motionX *= 0.5;
player.motionZ *= 0.5;
}
float bonus = 0.20F;
movementEffects(player, bonus, itemStack);
if (player.fallDistance > 0.0F) player.fallDistance = 0.0F;
}

if (p.moveForward > 0.0F) {
if ((p.worldObj.isRemote) && (!p.isSneaking())) {
if (!Thaumcraft.instance.entityEventHandler.prevStep.containsKey(Integer.valueOf(p.getEntityId()))) {
Thaumcraft.instance.entityEventHandler.prevStep
.put(Integer.valueOf(p.getEntityId()), Float.valueOf(p.stepHeight));
public void movementEffects(EntityPlayer player, float bonus, ItemStack itemStack) {
if (player.moveForward != 0.0F || player.moveStrafing != 0.0F) {
if (TaintedMagic.isBootsActive) {
boolean omniMode = isOmniEnabled(itemStack);
if ((player.moveForward == 0F && player.moveStrafing == 0F && omniMode)
|| (player.moveForward <= 0F && !omniMode)) {
return;
}
}
if (player.worldObj.isRemote && !player.isSneaking()) {
if (!Thaumcraft.instance.entityEventHandler.prevStep.containsKey(player.getEntityId())) {
Thaumcraft.instance.entityEventHandler.prevStep.put(player.getEntityId(), player.stepHeight);
}
p.stepHeight = 1.0F;
player.stepHeight = 1.0F;
}

if (p.onGround || p.capabilities.isFlying) {
float bonus = 0.20F;
p.moveFlying(0.0F, 1.0F, p.capabilities.isFlying ? (bonus - 0.075F) : bonus);
p.jumpMovementFactor = 0.00002F;
} else if (Hover.getHover(p.getEntityId())) {
p.jumpMovementFactor = 0.03F;
float speedMod = (float) getSpeedModifier(itemStack);
if (player.onGround || player.capabilities.isFlying || player.isOnLadder()) {
bonus *= speedMod;
if (TaintedMagic.isBootsActive) {
applyOmniState(player, bonus, itemStack);
} else if (player.moveForward > 0.0) {
player.moveFlying(
0.0F,
player.moveForward,
player.capabilities.isFlying ? (bonus - 0.075F) : bonus);
}
player.jumpMovementFactor = 0.00002F;
} else if (Hover.getHover(player.getEntityId())) {
player.jumpMovementFactor = 0.03F * speedMod;

} else {
p.jumpMovementFactor = 0.05F;
player.jumpMovementFactor = 0.05F * speedMod;
}
}
if (p.fallDistance > 0.0F) p.fallDistance = 0.0F;
}

@Optional.Method(modid = "thaumicboots")
public void applyOmniState(EntityPlayer player, float bonus, ItemStack itemStack) {
if (player.moveForward != 0.0) {
player.moveFlying(0.0F, player.moveForward, bonus);
}
if (player.moveStrafing != 0.0 && getOmniState(itemStack)) {
player.moveFlying(player.moveStrafing, 0.0F, bonus);
}
}

@SubscribeEvent
public void playerJumps(LivingEvent.LivingJumpEvent event) {
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
ItemStack boots = player.getCurrentArmor(0);

if (player.inventory.armorItemInSlot(0) != null
&& player.inventory.armorItemInSlot(0).getItem() == ItemRegistry.ItemVoidwalkerBoots) {
event.entityLiving.motionY += 0.35D;
event.entityLiving.motionY += 0.35D * (float) getJumpModifier(boots);
}
}
}

// 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;
}

public boolean getOmniState(ItemStack stack) {
if (stack.stackTagCompound != null) {
return stack.stackTagCompound.getBoolean("omni");
}
return false;
}

public boolean getIntertialState(ItemStack stack) {
if (stack.stackTagCompound != null) {
return stack.stackTagCompound.getBoolean("inertiacanceling");
}
return false;
}
}
Loading