From 8f8e69beaebe5ee61617627ee094e16d1f84e30f Mon Sep 17 00:00:00 2001 From: Black-Noise <76479838+Black-Noise@users.noreply.github.com> Date: Wed, 23 Jul 2025 17:34:17 +0300 Subject: [PATCH] omni mode vertical flight boost (#35) Co-authored-by: koolkrafter5 --- .../java/taintedmagic/api/IVoidwalker.java | 7 +++ .../items/equipment/ItemVoidwalkerBoots.java | 57 +++++++++++++++---- .../items/equipment/ItemVoidwalkerSash.java | 55 +----------------- 3 files changed, 54 insertions(+), 65 deletions(-) create mode 100644 src/main/java/taintedmagic/api/IVoidwalker.java diff --git a/src/main/java/taintedmagic/api/IVoidwalker.java b/src/main/java/taintedmagic/api/IVoidwalker.java new file mode 100644 index 0000000..b382c45 --- /dev/null +++ b/src/main/java/taintedmagic/api/IVoidwalker.java @@ -0,0 +1,7 @@ +package taintedmagic.api; + +/** + * Interface used by Voidwalker Boots here and in other mods for Voidwalker-specific effects + */ +public interface IVoidwalker { +} diff --git a/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerBoots.java b/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerBoots.java index f0ffa7e..ade4ae9 100644 --- a/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerBoots.java +++ b/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerBoots.java @@ -2,6 +2,7 @@ package taintedmagic.common.items.equipment; import java.util.List; +import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -16,10 +17,12 @@ import net.minecraftforge.common.ISpecialArmor; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent; +import baubles.common.lib.PlayerHandler; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.hazards.Hazard; import gregtech.api.hazards.IHazardProtector; +import taintedmagic.api.IVoidwalker; import taintedmagic.common.TaintedMagic; import taintedmagic.common.registry.ItemRegistry; import thaumcraft.api.IRepairable; @@ -31,10 +34,12 @@ import thaumcraft.common.Thaumcraft; import thaumcraft.common.items.armor.Hover; import thaumicboots.api.IBoots; +// import static taintedmagic.common.items.equipment.ItemVoidwalkerSash.sashBuff; + @Optional.InterfaceList({ @Optional.Interface(iface = "thaumicboots.api.IBoots", modid = "thaumicboots"), @Optional.Interface(iface = "gregtech.api.hazards.IHazardProtector", modid = "gregtech_nh") }) -public class ItemVoidwalkerBoots extends ItemArmor - implements IVisDiscountGear, IWarpingGear, IRunicArmor, IRepairable, ISpecialArmor, IBoots, IHazardProtector { +public class ItemVoidwalkerBoots extends ItemArmor implements IVoidwalker, IVisDiscountGear, IWarpingGear, IRunicArmor, + IRepairable, ISpecialArmor, IBoots, IHazardProtector { public ItemVoidwalkerBoots(ArmorMaterial m, int j, int k) { super(m, j, k); @@ -129,11 +134,10 @@ public class ItemVoidwalkerBoots extends ItemArmor } public void movementEffects(EntityPlayer player, float bonus, ItemStack itemStack) { - if (player.moveForward != 0.0F || player.moveStrafing != 0.0F) { + if (player.moveForward != 0.0F || player.moveStrafing != 0.0F || player.motionY != 0.0F) { if (TaintedMagic.isBootsActive) { boolean omniMode = isOmniEnabled(itemStack); - if ((player.moveForward == 0F && player.moveStrafing == 0F && omniMode) - || (player.moveForward <= 0F && !omniMode)) { + if (player.moveForward <= 0F && !omniMode) { return; } } @@ -146,6 +150,8 @@ public class ItemVoidwalkerBoots extends ItemArmor float speedMod = (float) getSpeedModifier(itemStack); if (player.onGround || player.capabilities.isFlying || player.isOnLadder()) { + + bonus += sashBuff(player); bonus *= speedMod; if (TaintedMagic.isBootsActive) { applyOmniState(player, bonus, itemStack); @@ -157,21 +163,45 @@ public class ItemVoidwalkerBoots extends ItemArmor } player.jumpMovementFactor = 0.00002F; } else if (Hover.getHover(player.getEntityId())) { - player.jumpMovementFactor = 0.03F * speedMod; + player.jumpMovementFactor = 0.03F; } else { - player.jumpMovementFactor = 0.05F * speedMod; + player.jumpMovementFactor = 0.05F; } } } + public static float sashBuff(final EntityPlayer player) { + // speed & jump buff should only apply when sash+voidwalkers are worn together + ItemStack boots = player.getCurrentArmor(0); + if (boots == null || !(boots.getItem() instanceof IVoidwalker)) { + return 0.0F; + } + for (ItemStack stack : PlayerHandler.getPlayerBaubles(player).stackList) { + if (stack != null && stack.getItem() == ItemRegistry.ItemVoidwalkerSash + && (ItemVoidwalkerSash.hasSpeedBoost(stack))) { + return 0.4F; + } + } + return 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); + if (getOmniState(itemStack)) { + if (player.moveStrafing != 0.0) { + player.moveFlying(player.moveStrafing, 0.0F, bonus); + } + boolean jumping = Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed(); + boolean sneaking = player.isSneaking(); + if (sneaking && !jumping && !player.onGround) { + player.motionY -= bonus; + } else if (jumping && !sneaking) { + player.motionY += bonus; + } } } @@ -214,13 +244,16 @@ public class ItemVoidwalkerBoots extends ItemArmor @SubscribeEvent public void playerJumps(LivingEvent.LivingJumpEvent event) { - if (event.entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.entity; + if (event.entityLiving instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.entityLiving; ItemStack boots = player.getCurrentArmor(0); if (player.inventory.armorItemInSlot(0) != null && player.inventory.armorItemInSlot(0).getItem() == ItemRegistry.ItemVoidwalkerBoots) { - event.entityLiving.motionY += 0.35D * (float) getJumpModifier(boots); + player.motionY += 0.35D * (float) getJumpModifier(boots); + if (sashBuff(player) > 0F) { + player.motionY += 0.15F * (float) getJumpModifier(boots); + } } } } diff --git a/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerSash.java b/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerSash.java index 6524a72..dcd41e9 100644 --- a/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerSash.java +++ b/src/main/java/taintedmagic/common/items/equipment/ItemVoidwalkerSash.java @@ -9,19 +9,14 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.LivingEvent; import baubles.api.BaubleType; import baubles.api.IBauble; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import taintedmagic.common.TaintedMagic; import thaumcraft.api.IRunicArmor; import thaumcraft.api.IWarpingGear; import thaumcraft.api.ItemRunic; import thaumcraft.common.Thaumcraft; -import thaumcraft.common.items.armor.Hover; public class ItemVoidwalkerSash extends ItemRunic implements IRunicArmor, IWarpingGear, IBauble { @@ -34,8 +29,6 @@ public class ItemVoidwalkerSash extends ItemRunic implements IRunicArmor, IWarpi this.setMaxDamage(-1); this.setMaxStackSize(1); this.setUnlocalizedName("ItemVoidwalkerSash"); - - MinecraftForge.EVENT_BUS.register(new EventHandler()); } public EnumRarity getRarity(ItemStack s) { @@ -86,33 +79,7 @@ public class ItemVoidwalkerSash extends ItemRunic implements IRunicArmor, IWarpi @Override public void onWornTick(ItemStack s, EntityLivingBase e) { - EntityPlayer p = (EntityPlayer) e; - if ((p.inventory.armorItemInSlot(0) != null) - && (p.inventory.armorItemInSlot(0).getItem() instanceof ItemVoidwalkerBoots)) { - if (hasSpeedBoost(s)) { - 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)); - } - p.stepHeight = 1.0F; - } - - if (p.onGround || p.capabilities.isFlying) { - float bonus = 0.4F; - p.moveFlying(0.0F, 1.0F, p.capabilities.isFlying ? (bonus - 0.050F) : bonus); - } else if (Hover.getHover(p.getEntityId())) { - p.jumpMovementFactor = 0.015F; - - } else { - p.jumpMovementFactor = 0.025F; - } - } - if (p.fallDistance > 0.0F) p.fallDistance = 0.0F; - } - } + // functionality moved to voidwalker boots } @Override @@ -128,28 +95,10 @@ public class ItemVoidwalkerSash extends ItemRunic implements IRunicArmor, IWarpi return s; } - public boolean hasSpeedBoost(ItemStack s) { + public static boolean hasSpeedBoost(ItemStack s) { if (s.stackTagCompound == null) return true; else return s.stackTagCompound.getBoolean(TAG_MODE); } - public class EventHandler { - - @SubscribeEvent - public void onPlayerJump(LivingEvent.LivingJumpEvent event) { - if ((event.entityLiving instanceof EntityPlayer)) { - EntityPlayer player = (EntityPlayer) event.entityLiving; - ItemStack sash = PlayerHandler.getPlayerBaubles(player).getStackInSlot(3); - ItemStack boots = player.inventory.armorItemInSlot(0); - if ((sash != null) && ((sash.getItem() instanceof ItemVoidwalkerSash))) { - if ((boots != null) && ((boots.getItem() instanceof ItemVoidwalkerBoots))) { - if (hasSpeedBoost(sash)) { - player.motionY += 0.15F; - } - } - } - } - } - } }