Skip to content

Commit

Permalink
Adds an optional dep to Thaumic Explorations, giving the boots the fe…
Browse files Browse the repository at this point in the history
…atures
  • Loading branch information
Alastors committed May 6, 2024
1 parent 2f36a51 commit da334fd
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 65 deletions.
9 changes: 6 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ dependencies {
compile('com.github.GTNewHorizons:AppleCore:3.3.0:dev')
compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compile("curse.maven:witchery-69673:2234410")
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-352-GTNH:dev') {
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-400-GTNH:dev') {
transitive = false
}
compile('com.github.GTNewHorizons:Baubles:1.0.4:dev') {
transitive = false
}
compileOnly('com.github.GTNewHorizons:Botania:1.10.12-GTNH:dev') {
compileOnly('com.github.GTNewHorizons:Botania:1.11.0-GTNH:dev') {
transitive = false
}
compile('com.github.GTNewHorizons:CodeChickenLib:1.2.1:dev') {
Expand All @@ -22,6 +22,9 @@ dependencies {
compileOnly("com.github.GTNewHorizons:waila:1.7.3:api") {
transitive = false
}
api ('com.github.GTNewHorizons:ThaumicBoots:1.3.0:dev'){
exclude group: 'com.github.GTNewHorizons', module: 'Thaumic_Exploration'
}
runtimeOnly("com.github.GTNewHorizons:CodeChickenCore:1.2.1:dev") // Allow obfuscated Witchery to run in dev
runtimeOnly("com.github.GTNewHorizons:NotEnoughItems:2.5.27-GTNH:dev")
runtimeOnly("com.github.GTNewHorizons:NotEnoughItems:2.6.0-GTNH:dev")
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ public class ThaumicExploration {
public static Potion potionBinding;
public static Potion potionTaintWithdrawl;

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

@SidedProxy(
clientSide = "flaxbeard.thaumicexploration.client.ClientProxy",
serverSide = "flaxbeard.thaumicexploration.common.CommonProxy")
Expand All @@ -242,7 +247,12 @@ public class ThaumicExploration {

@EventHandler
public void preInit(FMLPreInitializationEvent event) {

if (Loader.isModLoaded(TTINKER)) {
isThaumTinkererActive = true;
}
if (Loader.isModLoaded(BOOTS)) {
isBootsActive = true;
}
// GameRegistry.registerWorldGenerator(this.worldGen = new WorldGenTX());

SoulBrazierQueue aBrazierQueue = new SoulBrazierQueue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerCapabilities;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
Expand All @@ -17,11 +18,12 @@
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import flaxbeard.thaumicexploration.ThaumicExploration;
import flaxbeard.thaumicexploration.common.ConfigTX;
import flaxbeard.thaumicexploration.integration.TTIntegration;
import flaxbeard.thaumicexploration.item.ItemTXArmorSpecial;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.nodes.INode;
Expand All @@ -30,6 +32,7 @@
import thaumcraft.common.config.ConfigItems;
import thaumcraft.common.items.wands.ItemWandCasting;
import thaumcraft.common.lib.world.ThaumcraftWorldGenerator;
import thaumicboots.api.IBoots;

public class TXBootsEventHandler {

Expand Down Expand Up @@ -298,38 +301,51 @@ public void joinWorld(EntityJoinWorldEvent event) {

@SubscribeEvent
public void playerJumps(LivingEvent.LivingJumpEvent event) {
// if not a player
if (!(event.entity instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) event.entity;

if (((event.entity instanceof EntityPlayer))
&& (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) != null)
&& (((EntityPlayer) event.entity).inventory.armorItemInSlot(0).getItem()
== ThaumicExploration.bootsMeteor)) {
if (((EntityPlayer) event.entity).isSneaking()) {
Vec3 vector = event.entityLiving.getLook(0.5F);
double total = Math.abs(vector.zCoord + vector.xCoord);
EntityPlayer player = (EntityPlayer) event.entity;
double jump = 0;
if (Loader.isModLoaded("ThaumicTinkerer")) {
jump = TTIntegration.getAscentLevel((EntityPlayer) event.entity);
}
if (jump >= 1) {
jump = (jump + 2D) / 4D;
}

if (vector.yCoord < total) vector.yCoord = total;
// if no boots equipped
if (player.inventory.armorItemInSlot(0) == null) {
return;
}

event.entityLiving.motionY += ((jump + 1) * vector.yCoord) / 1.5F;
event.entityLiving.motionZ += (jump + 1) * vector.zCoord * 4;
event.entityLiving.motionX += (jump + 1) * vector.xCoord * 4;
Item item = player.inventory.armorItemInSlot(0).getItem();

} else {
event.entityLiving.motionY += 0.2750000059604645D;
if ((item instanceof ItemTXArmorSpecial) && !((EntityPlayer) event.entity).isSneaking()) {
double jump = ((ItemTXArmorSpecial) item).jumpBonus;
if (ThaumicExploration.isBootsActive) {
jump *= applyJump(player);
}
} else if (((event.entity instanceof EntityPlayer))
&& (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) != null)
&& (((EntityPlayer) event.entity).inventory.armorItemInSlot(0).getItem()
== ThaumicExploration.bootsComet)) {
event.entityLiving.motionY += 0.2750000059604645D;
}
event.entityLiving.motionY += jump;
} else if (item == ThaumicExploration.bootsMeteor && player.isSneaking()) {
Vec3 vector = event.entityLiving.getLook(0.5F);
double total = Math.abs(vector.zCoord + vector.xCoord);
double jump = 0;
if (ThaumicExploration.isThaumTinkererActive) {
jump = TTIntegration.getAscentLevel(player);
}
if (jump >= 1) {
jump *= 0.5; // bizarre, but I made this a bit more efficient (was originally (jump*2)/4)
}
if (ThaumicExploration.isBootsActive) {
jump *= applyJump(player);
}

if (vector.yCoord < total) vector.yCoord = total;

player.motionY += ((jump + 1) * vector.yCoord) / 1.5F; // no good way to represent, 2/3 equivalent.
player.motionZ += (jump + 1) * vector.zCoord * 4;
player.motionX += (jump + 1) * vector.xCoord * 4;

}
}

@Optional.Method(modid = "thaumicboots")
public double applyJump(EntityPlayer player) {
return IBoots.isJumpEnabled(player.inventory.armorItemInSlot(0));
}

// TODO boot effect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.Optional.Interface;
import flaxbeard.thaumicexploration.ThaumicExploration;
import thaumcraft.api.IRepairable;
import thaumcraft.api.IRunicArmor;
import thaumcraft.common.Thaumcraft;
import thaumcraft.common.config.Config;
import thaumcraft.common.items.armor.Hover;
import thaumicboots.api.IBoots;

public class ItemTXArmorSpecial extends ItemArmor implements IRepairable, IRunicArmor {
@Interface(iface = "thaumicboots.api.IBoots", modid = "thaumicboots")
public class ItemTXArmorSpecial extends ItemArmor implements IRepairable, IRunicArmor, IBoots {

public double jumpBonus = 0.2750000059604645D;

public ItemTXArmorSpecial(ItemArmor.ArmorMaterial par2EnumArmorMaterial, int par3, int par4) {
super(par2EnumArmorMaterial, par3, par4);
Expand Down Expand Up @@ -47,10 +54,11 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
player.fallDistance = 0.0F;
}
}
if ((!player.capabilities.isFlying) && (player.moveForward > 0.0F)) {
if (player.moveForward != 0.0F || player.moveStrafing != 0.0F) {
int haste = EnchantmentHelper
.getEnchantmentLevel(Config.enchHaste.effectId, player.inventory.armorItemInSlot(0));
if (player.inventory.armorItemInSlot(0).getItem() == ThaumicExploration.bootsMeteor) {
Item item = player.inventory.armorItemInSlot(0).getItem();
if (item instanceof ItemTXArmorSpecial) {
if (player.worldObj.isRemote) {
if (!Thaumcraft.instance.entityEventHandler.prevStep
.containsKey(Integer.valueOf(player.getEntityId()))) {
Expand All @@ -59,29 +67,17 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
}
player.stepHeight = 1.0F;
}
}

if (item == ThaumicExploration.bootsMeteor) {
float bonus = 0.055F;
if (player.isInWater()) {
bonus /= 4.0F;
}
if (player.onGround) {
player.moveFlying(0.0F, 1.0F, bonus);
} else if (Hover.getHover(player.getEntityId())) {
player.jumpMovementFactor = 0.03F;
} else {
player.jumpMovementFactor = 0.05F;
}
movementEffects(player, bonus, itemStack);

// This seems to be redundant ???
if (player.fallDistance > 0.0F) {
player.fallDistance = 0.0F;
}
} else if (player.inventory.armorItemInSlot(0).getItem() == ThaumicExploration.bootsComet) {
if (player.worldObj.isRemote) {
if (!Thaumcraft.instance.entityEventHandler.prevStep
.containsKey(Integer.valueOf(player.getEntityId()))) {
Thaumcraft.instance.entityEventHandler.prevStep
.put(Integer.valueOf(player.getEntityId()), Float.valueOf(player.stepHeight));
}
player.stepHeight = 1.0F;
}
} else if (item == ThaumicExploration.bootsComet) {
if (!player.inventory.armorItemInSlot(0).hasTagCompound()) {
NBTTagCompound par1NBTTagCompound = new NBTTagCompound();
player.inventory.armorItemInSlot(0).setTagCompound(par1NBTTagCompound);
Expand All @@ -90,24 +86,64 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
int ticks = player.inventory.armorItemInSlot(0).stackTagCompound.getInteger("runTicks");
float bonus = 0.110F;
bonus = bonus + ((ticks / 5) * 0.003F);
if (player.isInWater()) {
bonus /= 4.0F;
}
if (player.onGround || player.isOnLadder()) {
player.moveFlying(0.0F, 1.0F, bonus);
} else if (Hover.getHover(player.getEntityId())) {
player.jumpMovementFactor = 0.03F;
} else {
player.jumpMovementFactor = 0.05F;
}
movementEffects(player, bonus, itemStack);
if (player.fallDistance > 0.25F) {
player.fallDistance -= 0.25F;
}
}
}
}

public void movementEffects(EntityPlayer player, float bonus, ItemStack itemStack) {
float speedMod = (float) getSpeedModifier(itemStack);
if (player.isInWater()) {
bonus /= 4.0F;
}
if (player.onGround || player.isOnLadder() || player.capabilities.isFlying) {
bonus *= speedMod;
if (ThaumicExploration.isBootsActive) {
applyOmniState(player, bonus, itemStack);
} else if (player.moveForward > 0F) {
player.moveFlying(0.0F, player.moveForward, bonus);
}
} else if (Hover.getHover(player.getEntityId())) {
player.jumpMovementFactor = 0.03F;
} else {
player.jumpMovementFactor = 0.05F;
}
}

public int getRunicCharge(ItemStack arg0) {
return 0;
}

// Thaumic Boots Methods:

@Optional.Method(modid = "thaumicboots")
public void applyOmniState(EntityPlayer player, float bonus, ItemStack itemStack) {
boolean omniMode = itemStack.stackTagCompound.getBoolean(TAG_MODE_OMNI);
if (player.moveForward <= 0F && !omniMode) {
return;
}
if (player.moveStrafing != 0.0 && omniMode) {
player.moveFlying(player.moveStrafing, 0.0F, bonus);
} else if (player.moveForward != 0.0) {
player.moveFlying(0.0F, player.moveForward, bonus);
}
}

// 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 da334fd

Please sign in to comment.