diff --git a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java index 922b504..fa48aff 100644 --- a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java +++ b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java @@ -315,14 +315,16 @@ public class CinderEventHandler implements IFuelHandler { // Isildurs chestplate handler // Incoming damage from poison, drink poison (for lurtz bow, rip anyone who drinks a bad drink), or wither is doubled + if (event.entityLiving.worldObj.isRemote) return; + if (!(event.entityLiving instanceof EntityPlayerMP)) return; + EntityPlayerMP player = (EntityPlayerMP) event.entityLiving; ItemStack chest = player.getEquipmentInSlot(2); if (chest == null || chest.getItem() != CinderLoE.bodyIsildur) return; - boolean isPoison = player.isPotionActive(Potion.poison.id); - boolean isPoisonedDrink = player.isPotionActive(LOTRPoisonedDrinks.killingPoison.id); - boolean isWitherDamage = event.source == DamageSource.wither; - if (isPoisonedDrink || isWitherDamage || isPoison) { + boolean isDrinkPoison = player.isPotionActive(LOTRPoisonedDrinks.killingPoison.id); + boolean isWither = event.source == DamageSource.wither; + if (isDrinkPoison || isWither) { event.ammount *= 2.0F; } } diff --git a/src/main/java/com/zivilon/cinder_loe/CinderLoE.java b/src/main/java/com/zivilon/cinder_loe/CinderLoE.java index 58abc11..9eb13fe 100644 --- a/src/main/java/com/zivilon/cinder_loe/CinderLoE.java +++ b/src/main/java/com/zivilon/cinder_loe/CinderLoE.java @@ -332,6 +332,7 @@ public class CinderLoE { public static Item alatarStaff; public static Item sarumanStaff; public static Item sarumanWhiteStaff; + public static Item mouthofsauronSword; // Relics public static Item welfRelic; @@ -728,18 +729,22 @@ public class CinderLoE { alatarStaff = (new AlatarStaff()).setUnlocalizedName("lotr:alatarStaff").setTextureName("lotr:alatarStaff"); sarumanStaff = (new SarumanStaff()).setUnlocalizedName("lotr:sarumanStaff").setTextureName("lotr:sarumanStaff"); sarumanWhiteStaff = (new SarumanWhiteStaff()).setUnlocalizedName("lotr:sarumanWhiteStaff").setTextureName("lotr:sarumanStaff"); + mouthofsauronSword = (new MouthOfSauronWeapon()).setUnlocalizedName("lotr:mouthofsauronSword").setTextureName("lotr:mouthofsauronSword"); ItemRegistration.register(radagastStaff, "radagastStaff", 6700); ItemRegistration.register(pallandoStaff, "pallandoStaff", 6701); ItemRegistration.register(alatarStaff, "alatarStaff", 6702); ItemRegistration.register(sarumanStaff, "sarumanStaff", 6703); ItemRegistration.register(sarumanWhiteStaff, "sarumanWhiteStaff", 6705); + ItemRegistration.register(mouthofsauronSword, "mouthofsauronSword", 6711); linkLOTRWeapon(radagastStaff, "radagastStaff"); linkLOTRWeapon(pallandoStaff, "pallandoStaff"); linkLOTRWeapon(alatarStaff, "alatarStaff"); linkLOTRWeapon(sarumanStaff, "sarumanStaff"); linkLOTRWeapon(sarumanWhiteStaff, "sarumanWhiteStaff"); + linkLOTRWeapon(mouthofsauronSword, "mouthofsauronSword"); + // Relics welfRelic = (new WoodElfRelic()).setUnlocalizedName("lotr:welfRelic").setTextureName("lotr:welfRelic"); diff --git a/src/main/java/com/zivilon/cinder_loe/character/CharacterEventListener.java b/src/main/java/com/zivilon/cinder_loe/character/CharacterEventListener.java index 518dd0a..dcea738 100644 --- a/src/main/java/com/zivilon/cinder_loe/character/CharacterEventListener.java +++ b/src/main/java/com/zivilon/cinder_loe/character/CharacterEventListener.java @@ -45,35 +45,36 @@ public class CharacterEventListener { //Mouth of Sauron event handler @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { - if (event.phase != TickEvent.Phase.END || event.player.worldObj.isRemote) return; + if (event.phase != TickEvent.Phase.END || event.player.worldObj.isRemote) { + return; + } EntityPlayerMP player = (EntityPlayerMP) event.player; UUID id = player.getUniqueID(); - - // Only “MouthOfSauron” gets this ability - if (!CharacterRoleAPI.getCharacterRoleUUID("MouthOfSauron").equals(id)) { + UUID mosId = CharacterRoleAPI.getCharacterRoleUUID("MouthOfSauron"); + if (mosId == null || !mosId.equals(id)) { tickCounters.remove(id); hiringEnabled.remove(id); return; } + if (!hiringEnabled.contains(id)) { tickCounters.remove(id); return; } - // Tick up, and only run when we hit the interval int count = tickCounters.getOrDefault(id, 0) + 1; if (count < HIRE_INTERVAL) { tickCounters.put(id, count); return; } tickCounters.put(id, 0); - //player.addChatMessage(new ChatComponentText("[DEBUG] tryHireNPCs called")); tryHireNPCs(player); } + private static void tryHireNPCs(EntityPlayerMP player) { World world = player.worldObj; UUID playerId = player.getUniqueID(); diff --git a/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java b/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java index 343e52f..2a20799 100644 --- a/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java +++ b/src/main/java/com/zivilon/cinder_loe/coremod/LOTRWeaponLinker.java @@ -20,7 +20,7 @@ public class LOTRWeaponLinker implements IClassTransformer { // Can add any number of items, append with comma return addLinks(basicClass, "spearRedDwarf", "crossbowRedDwarf", "swordRedDwarf", "battleaxeRedDwarf", "pikeRedDwarf", "daggerRedDwarf", "daggerRedDwarfPoisoned", "hammerRedDwarf", - "radagastStaff", "alatarStaff", "pallandoStaff", "sarumanStaff", "maceWarlord", "sarumanWhiteStaff", + "radagastStaff", "alatarStaff", "pallandoStaff", "sarumanStaff", "maceWarlord", "sarumanWhiteStaff", "mouthofsauronSword", "spearLimwaith", "tridentLimwaith", "daggerLimwaith", "daggerLimwaithPoisoned", "truncheonLimwaith", "battleaxeLimwaith", "blowgunLimwaith", "frostblade", "spearsolidgold", "whip", "spearUnnamed", "welfRelic", "daggerVoid", "swordBree", "greatswordAngmar", "greatswordLindon", "greatswordDale", "greatswordNumenor", diff --git a/src/main/java/com/zivilon/cinder_loe/items/specials/MouthOfSauronWeapon.java b/src/main/java/com/zivilon/cinder_loe/items/specials/MouthOfSauronWeapon.java index 2a04c64..7f6d19e 100644 --- a/src/main/java/com/zivilon/cinder_loe/items/specials/MouthOfSauronWeapon.java +++ b/src/main/java/com/zivilon/cinder_loe/items/specials/MouthOfSauronWeapon.java @@ -5,14 +5,17 @@ import lotr.common.LOTRLevelData; import lotr.common.LOTRMod; import lotr.common.entity.animal.LOTREntityHorse; import lotr.common.fac.LOTRFaction; +import lotr.common.item.LOTRItemAxe; import lotr.common.item.LOTRItemSword; import lotr.common.item.LOTRMaterial; +import lotr.common.item.LOTRStoryItem; import lotr.common.network.LOTRPacketHandler; import lotr.common.network.LOTRPacketWeaponFX; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import net.minecraft.util.DamageSource; @@ -21,12 +24,11 @@ import net.minecraft.world.World; import java.util.List; -public class MouthOfSauronWeapon extends LOTRItemSword { +public class MouthOfSauronWeapon extends LOTRItemSword implements LOTRStoryItem { public MouthOfSauronWeapon() { super(LOTRMaterial.MORDOR); this.setMaxDamage(1500); - this.lotrWeaponDamage = 8.0f; } public ItemStack onEaten(ItemStack itemstack, World world, EntityPlayer entityplayer) { @@ -38,7 +40,7 @@ public class MouthOfSauronWeapon extends LOTRItemSword { user.swingItem(); world.playSoundAtEntity((Entity)user, "mob.wither.hurt", 2.0f, (itemRand.nextFloat() - itemRand.nextFloat()) * 0.2f + 1.0f); if (!world.isRemote) { - List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, user.boundingBox.expand(12.0, 8.0, 12.0)); + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, user.boundingBox.expand(6.0, 6.0, 6.0)); if (!entities.isEmpty()) { for (int i = 0; i < entities.size(); ++i) { EntityLiving entityliving; @@ -66,4 +68,18 @@ public class MouthOfSauronWeapon extends LOTRItemSword { return itemstack; } + public int getMaxItemUseDuration(ItemStack itemstack) { + return 40; + } + + @Override + public EnumAction getItemUseAction(ItemStack itemstack) { + return EnumAction.bow; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + entityplayer.setItemInUse(itemstack, this.getMaxItemUseDuration(itemstack)); + return itemstack; + } } diff --git a/src/main/resources/assets/cinder_loe/lang/en_US.lang b/src/main/resources/assets/cinder_loe/lang/en_US.lang index c343887..5467c69 100644 --- a/src/main/resources/assets/cinder_loe/lang/en_US.lang +++ b/src/main/resources/assets/cinder_loe/lang/en_US.lang @@ -106,6 +106,7 @@ item.lotr:pallandoStaff.name=Staff of Pallando the Blue item.lotr:alatarStaff.name=Staff of Alatar the Blue item.lotr:sarumanStaff.name=Staff of Saruman of Many Colors item.lotr:sarumanWhiteStaff.name=Staff of Saruman the White +item.lotr:mouthofsauronSword.name=Sword of the Lieutenant item.lotr:welfRelic.name=Horn of the Greenwood Stag item.lotr:ulukai.name=Ulûkai diff --git a/src/main/resources/assets/lotr/textures/items/large2/mouthofsauronSword.png b/src/main/resources/assets/lotr/textures/items/large2/mouthofsauronSword.png new file mode 100644 index 0000000..6e95b95 Binary files /dev/null and b/src/main/resources/assets/lotr/textures/items/large2/mouthofsauronSword.png differ diff --git a/src/main/resources/assets/lotr/textures/items/mouthofsauronSword.png b/src/main/resources/assets/lotr/textures/items/mouthofsauronSword.png new file mode 100644 index 0000000..c1294d9 Binary files /dev/null and b/src/main/resources/assets/lotr/textures/items/mouthofsauronSword.png differ