2
0
Fork 0

Added swiftness modifier

main
s 7 months ago
parent 5a4f9ae524
commit 8e7cde6766

@ -57,14 +57,11 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import lotr.client.render.entity.*; import lotr.client.render.entity.*;
import lotr.client.render.entity.LOTRRenderSauron;
import lotr.client.render.tileentity.LOTRRenderUtumnoPortal; import lotr.client.render.tileentity.LOTRRenderUtumnoPortal;
import lotr.common.LOTRCreativeTabs; import lotr.common.LOTRCreativeTabs;
import lotr.common.LOTRMod; import lotr.common.LOTRMod;
import lotr.common.entity.animal.*; import lotr.common.entity.animal.*;
import lotr.common.entity.npc.*; import lotr.common.entity.npc.*;
import lotr.common.entity.npc.LOTREntityBarrowWight;
import lotr.common.entity.npc.LOTREntitySauron;
import lotr.common.entity.projectile.LOTREntityGandalfFireball; import lotr.common.entity.projectile.LOTREntityGandalfFireball;
import lotr.common.world.biome.LOTRBiome; import lotr.common.world.biome.LOTRBiome;
import lotr.common.world.spawning.LOTRBiomeSpawnList; import lotr.common.world.spawning.LOTRBiomeSpawnList;
@ -88,6 +85,7 @@ import net.minecraft.command.ICommandSender;
import net.minecraft.command.CommandBase; import net.minecraft.command.CommandBase;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.client.ClientCommandHandler;
import com.zivilon.cinder_loe.SwiftnessHandler;
@Mod( @Mod(
modid = "cinder_loe", modid = "cinder_loe",
@ -321,6 +319,7 @@ public class CinderLoE {
} }
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
new CharacterEventListener(); new CharacterEventListener();
MinecraftForge.EVENT_BUS.register(new SwiftnessHandler());
} }

@ -0,0 +1,56 @@
// File: SwiftnessHandler.java
package com.zivilon.cinder_loe;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingEvent;
import lotr.common.enchant.LOTREnchantment;
import lotr.common.enchant.LOTREnchantmentHelper;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import java.util.UUID;
public class SwiftnessHandler {
// Use fixed UUIDs to prevent stacking
private static final UUID[] SWIFTNESS_UUIDS = new UUID[]{
UUID.fromString("123e4567-e89b-12d3-a456-426614174001"), // boots
UUID.fromString("123e4567-e89b-12d3-a456-426614174002"), // leggings
UUID.fromString("123e4567-e89b-12d3-a456-426614174003"), // chestplate
UUID.fromString("123e4567-e89b-12d3-a456-426614174004") // helmet
};
private static final String[] MODIFIER_NAMES = new String[]{
"SwiftnessBoots", "SwiftnessLegs", "SwiftnessChest", "SwiftnessHelm"
};
@SubscribeEvent
public void onPlayerTick(LivingEvent.LivingUpdateEvent event) {
if (!(event.entityLiving instanceof EntityPlayer)) return;
EntityPlayer player = (EntityPlayer) event.entityLiving;
for (int i = 0; i < player.inventory.armorInventory.length; i++) {
ItemStack armor = player.inventory.armorInventory[i];
UUID uuid = SWIFTNESS_UUIDS[i];
String label = MODIFIER_NAMES[i];
// Get movement speed attribute
IAttributeInstance attr = player.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
AttributeModifier existingMod = attr.getModifier(uuid);
if (armor != null && LOTREnchantmentHelper.hasEnchant(armor, LOTREnchantment.getEnchantmentByName("swiftness"))) {
if (existingMod == null) {
AttributeModifier mod = new AttributeModifier(uuid, label, 0.05, 1);
attr.applyModifier(mod);
}
} else {
if (existingMod != null) {
attr.removeModifier(existingMod);
}
}
}
}
}

@ -346,6 +346,8 @@ lotr.enchant.meleeSpeed2=Rapid
lotr.enchant.rangedStrong4=Forceful lotr.enchant.rangedStrong4=Forceful
lotr.enchant.fireRepair=Ashen lotr.enchant.fireRepair=Ashen
lotr.enchant.fireRepair.desc=Repairs armor durability while on fire lotr.enchant.fireRepair.desc=Repairs armor durability while on fire
lotr.enchant.swiftness=Windy
lotr.enchant.swiftness.desc=+5% speed per armor piece
lotr.unit.Banner_Warg=Warg Rider Banner lotr.unit.Banner_Warg=Warg Rider Banner
lotr.unit.Banner_Horse=Mounted Banner Bearer lotr.unit.Banner_Horse=Mounted Banner Bearer

Loading…
Cancel
Save