Skip to content

Commit

Permalink
Fix half of #288
Browse files Browse the repository at this point in the history
  • Loading branch information
Roadhog360 committed Dec 23, 2023
1 parent a8c5912 commit cfd46d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.common.config.Config;

public class CompatThaumcraft {

Expand Down Expand Up @@ -197,4 +198,8 @@ public static void doRecipes() {
// TODO is there supposed to be Thaumcraft related Recipes? If so, what would they be?
}

public static int getHasteEnchID() {
return Config.enchHaste.effectId;
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package ganymedes01.etfuturum.mixins.backlytra;

import ganymedes01.etfuturum.compat.CompatThaumcraft;
import ganymedes01.etfuturum.compat.ModsList;
import ganymedes01.etfuturum.configuration.configs.ConfigFunctions;
import ganymedes01.etfuturum.elytra.IElytraPlayer;
import ganymedes01.etfuturum.items.equipment.ItemArmorElytra;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.entity.player.PlayerCapabilities;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
Expand All @@ -27,6 +31,9 @@ public abstract class MixinEntityPlayer extends EntityLivingBase implements IEly
@Shadow
protected abstract void setHideCape(int par1, boolean par2);

@Shadow
public InventoryPlayer inventory;

public MixinEntityPlayer(World p_i1594_1_) {
super(p_i1594_1_);
}
Expand Down Expand Up @@ -54,7 +61,23 @@ public void tickElytra() {
}

if (this.etfu$isElytraFlying()) {
this.etfu$ticksElytraFlying = this.etfu$ticksElytraFlying + 1;
this.etfu$ticksElytraFlying += 1;
if (ModsList.THAUMCRAFT.isLoaded() && inventory.armorItemInSlot(0) != null && moveForward > 0.0F) {
//Counteract haste boots Thaumcraft enchantment.
//Since Thaumcraft applies the speed no matter what, this causes practically limitless elytra flight.
int haste = EnchantmentHelper.getEnchantmentLevel(CompatThaumcraft.getHasteEnchID(), inventory.armorItemInSlot(0));
if (haste > 0) {
float bonus = haste * 0.015F;
if (isAirBorne) {
bonus *= 0.5F;
}
if (isInWater()) {
bonus *= 0.5F;
}
//Apply the same code for movement, but use -1.0F instead of 1.0F so it does the exact opposite so it cancels the Thaumcraft movement.
moveFlying(0.0F, -1.0F, bonus);
}
}
} else {
this.etfu$ticksElytraFlying = 0;
}
Expand Down

0 comments on commit cfd46d4

Please sign in to comment.