diff --git a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java index ef588f6..ee1674c 100644 --- a/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java +++ b/src/main/java/com/zivilon/cinder_loe/CinderEventHandler.java @@ -4,42 +4,141 @@ import com.zivilon.cinder_loe.entity.corrupt.CorruptMan; import com.zivilon.cinder_loe.items.BrokenHalo; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.registry.GameRegistry; import lotr.common.LOTRMod; +import lotr.common.enchant.LOTREnchantment; +import lotr.common.enchant.LOTREnchantmentHelper; +import lotr.common.item.*; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemBow; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; +import net.minecraftforge.event.entity.player.ArrowLooseEvent; import java.util.Random; public class CinderEventHandler implements IFuelHandler { private static final Random random = new Random(); public CinderEventHandler() { - FMLCommonHandler.instance().bus().register((Object)this); - MinecraftForge.EVENT_BUS.register((Object)this); - MinecraftForge.TERRAIN_GEN_BUS.register((Object)this); - GameRegistry.registerFuelHandler((IFuelHandler)this); + FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.TERRAIN_GEN_BUS.register(this); + GameRegistry.registerFuelHandler(this); } @SubscribeEvent + public void onArrowLoose(ArrowLooseEvent event) { + Entity attacker = event.entityLiving; + if (attacker instanceof EntityPlayerMP player) { + ItemStack bow = player.getHeldItem(); + if (bow != null && bow.isItemStackDamageable() && (bow.getItem() instanceof LOTRItemBow || bow.getItem() instanceof ItemBow)) { + float[] durabilityThresholds = {0.6f, 0.5f, 0.4f}; + double[] probabilities = {0.02, 0.05, 0.1}; // Corrected probabilities + + // Corrected durabilityPercent calculation + float durabilityPercent = (float) (bow.getMaxDamage() - bow.getItemDamage()) / bow.getMaxDamage(); + + for (int j = 0; j < durabilityThresholds.length; j++) { + if (durabilityPercent <= durabilityThresholds[j] && random.nextDouble() <= probabilities[j]) { + addNegativeModifier(bow, player, "bow"); + break; // Exit loop once a modifier is added + } + } + } + } + } + + @SubscribeEvent + public void onLivingAttack(LivingAttackEvent event) { + Entity attacker = event.source.getEntity(); + + if (attacker instanceof EntityPlayerMP player) { + ItemStack weapon = player.getHeldItem(); + // smithing rework for melee + if (weapon != null && (weapon.getItem() instanceof LOTRItemSpear || weapon.getItem() instanceof LOTRItemSword || weapon.getItem() instanceof LOTRItemDagger || weapon.getItem() instanceof LOTRItemBattleaxe || weapon.getItem() instanceof LOTRItemHammer || weapon.getItem() instanceof ItemSword)) { + float[] durabilityThresholds = {0.6f, 0.5f, 0.4f}; + double[] probabilities = {0.02, 0.05, 0.1}; // Corrected probabilities + if (weapon.isItemStackDamageable()) { + // Corrected durabilityPercent calculation + float durabilityPercent = (float) (weapon.getMaxDamage() - weapon.getItemDamage()) / weapon.getMaxDamage(); + + for (int j = 0; j < durabilityThresholds.length; j++) { + if (durabilityPercent <= durabilityThresholds[j] && random.nextDouble() <= probabilities[j]) { + addNegativeModifier(weapon, player, "weapon"); + break; // Exit loop once a modifier is added + } + } + } + } + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) public void onLivingHurt(LivingHurtEvent event) { EntityLivingBase entity = event.entityLiving; - EntityLivingBase attacker = event.source.getEntity() instanceof EntityLivingBase ? (EntityLivingBase)event.source.getEntity() : null; + EntityLivingBase attacker = event.source.getEntity() instanceof EntityLivingBase ? (EntityLivingBase) event.source.getEntity() : null; World world = entity.worldObj; + // Negative Arrow Protection Handler + if (!event.entityLiving.worldObj.isRemote && event.source.isProjectile() && event.entityLiving instanceof EntityPlayerMP player) { + // player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Initial Damage: " + event.ammount)); + + float totalAdditionalDamage = 0.0f; // Initialize total additional damage + + for (int i = 0; i < 4; i++) { + ItemStack armor = player.getEquipmentInSlot(i + 1); + if (armor != null) { + LOTREnchantment protectRangedWeak1 = LOTREnchantment.getEnchantmentByName("protectRangedWeak1"); + LOTREnchantment protectRangedWeak2 = LOTREnchantment.getEnchantmentByName("protectRangedWeak2"); + + if (LOTREnchantmentHelper.hasEnchant(armor, protectRangedWeak1)) { + float additionalDamage = 0.2f; // 20% more damage per piece + totalAdditionalDamage += additionalDamage; // Accumulate damage increase + } + if (LOTREnchantmentHelper.hasEnchant(armor, protectRangedWeak2)) { + float additionalDamage = 0.4f; // 40% more damage per piece + totalAdditionalDamage += additionalDamage; // Accumulate damage increase + } + } + } + + // Apply total additional damage + if (totalAdditionalDamage > 0) { + float newDamage = event.ammount * (1 + totalAdditionalDamage); // Calculate new damage + float newHealth = player.getHealth() - (newDamage - event.ammount); // Calculate health after applying extra damage + + if (newHealth > 0) { + player.setHealth(newHealth); + event.setCanceled(true); + } else { + event.ammount = player.getHealth(); // Ensure player dies if health reaches 0 or below + } + + // player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "DEBUG: Total Additional Damage: " + newDamage)); + } + } + + // Broken Halo Event handler if (attacker != null && event.source.getSourceOfDamage() == attacker) { ItemStack helmet = entity.getEquipmentInSlot(4); if (helmet != null && helmet.getItem() instanceof BrokenHalo) { - if (random.nextDouble() <= 0.25 ) { + if (random.nextDouble() <= 0.25) { // Summon Corrupt Civilian NPC CorruptMan spawnedEntity = new CorruptMan(world); spawnedEntity.copyLocationAndAnglesFrom(attacker); @@ -51,7 +150,7 @@ public class CinderEventHandler implements IFuelHandler { spawnedEntity.setHealth(10); spawnedEntity.addPotionEffect(new PotionEffect(Potion.regeneration.id, 9999, 0)); - spawnedEntity.onSpawnWithEgg((IEntityLivingData) null); + spawnedEntity.onSpawnWithEgg(null); world.spawnEntityInWorld(spawnedEntity); world.playAuxSFXAtEntity(null, 1016, (int) spawnedEntity.posX, (int) spawnedEntity.posY, (int) spawnedEntity.posZ, 0); world.playSoundAtEntity(entity, "mob.zombie.unfect", 1F, 1F); @@ -59,8 +158,210 @@ public class CinderEventHandler implements IFuelHandler { } } } + + // Smithing Rework event handler + if (attacker instanceof EntityPlayerMP player) { + ItemStack weapon = player.getHeldItem(); + // smithing rework for melee + if (weapon !=null && (weapon.getItem() instanceof LOTRItemSpear || weapon.getItem() instanceof LOTRItemSword || weapon.getItem() instanceof LOTRItemDagger || weapon.getItem() instanceof LOTRItemBattleaxe || weapon.getItem() instanceof LOTRItemHammer || weapon.getItem() instanceof ItemSword)) { + float[] durabilityThresholds = {0.6f, 0.5f, 0.4f}; + double[] probabilities = {0.02, 0.05, 0.1}; + + if (weapon.isItemStackDamageable()) { + float durabilityPercent = (float) (weapon.getMaxDamage() - weapon.getItemDamage() / weapon.getMaxDamage()); + for (int j = 0; j < durabilityThresholds.length; j++) { + if (durabilityPercent <= durabilityThresholds[j] && random.nextDouble() <= probabilities[j]) { + addNegativeModifier(weapon, player, "weapon"); + break; // Exit loop once a modifier is added + } + } + } + } + } + if (entity instanceof EntityPlayerMP player) { + + // Durability thresholds and corresponding probabilities for adding a negative modifier + float[] durabilityThresholds = {0.6f, 0.5f, 0.4f}; + double[] probabilities = {0.02, 0.05, 0.1}; + + for (int i = 0; i < 4; ++i) { + ItemStack armor = player.getEquipmentInSlot(i + 1); + if (armor != null && armor.isItemStackDamageable()) { + float durabilityPercent = (float) (armor.getMaxDamage() - armor.getItemDamage()) / armor.getMaxDamage(); + // Check each threshold and apply negative modifier if conditions are met + for (int j = 0; j < durabilityThresholds.length; j++) { + if (durabilityPercent <= durabilityThresholds[j] && random.nextDouble() <= probabilities[j]) { + addNegativeModifier(armor, player, "armor"); + break; // Exit loop once a modifier is added + } + } + } + } + } + } + private void sendNegativeModifierMessage(EntityPlayerMP player, String type) { + player.addChatMessage(new ChatComponentText( + EnumChatFormatting.RED + "Your " + + EnumChatFormatting.GOLD + type + + EnumChatFormatting.RED + " has received a negative modifier!" + )); + } + private void playNegativeModifierSound(World world, double x, double y, double z) { + world.playSoundEffect(x, y, z, "mob.irongolem.hit", 1.0F, 2.0F); + } + private void addNegativeModifier(ItemStack item, EntityPlayerMP player, String type) { + NBTTagCompound tag = item.getTagCompound(); + if (tag == null) { + tag = new NBTTagCompound(); + item.setTagCompound(tag); + } + + if (!tag.hasKey("LOTREnch")) { + tag.setTag("LOTREnch", new NBTTagList()); + } + + NBTTagList enchList = tag.getTagList("LOTREnch", 8); // 8 is the type for strings + boolean protectWeakUpgraded = false; + boolean protectRangedWeakUpgraded = false; + boolean upgraded = false; + + boolean meleeSwift = false; + boolean meleeReach = false; + + if (type.equals("armor")) { + // First, iterate and upgrade if necessary + for (int i = 0; i < enchList.tagCount(); i++) { + String ench = enchList.getStringTagAt(i); + switch (ench) { + case "protectWeak1" -> { + enchList.removeTag(i); + enchList.appendTag(new NBTTagString("protectWeak2")); + protectWeakUpgraded = true; + i--; // Adjust index after removal + playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ); + sendNegativeModifierMessage(player, "Armor"); + } + case "protectRangedWeak1" -> { + enchList.removeTag(i); + enchList.appendTag(new NBTTagString("protectRangedWeak2")); + protectRangedWeakUpgraded = true; + i--; // Adjust index after removal + playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ); + sendNegativeModifierMessage(player, "Armor"); + } + case "protectWeak2" -> protectWeakUpgraded = true; + case "protectRangedWeak2" -> protectRangedWeakUpgraded = true; + } + } + // After upgrading, check if we need to add a new modifier + if (!protectWeakUpgraded || !protectRangedWeakUpgraded) { + // Separate conditions for adding new modifiers + if (!protectWeakUpgraded && !protectRangedWeakUpgraded) { + // Randomly add either protectWeak1 or protectRangedWeak1 + String[] possibleModifiers = {"protectWeak1", "protectRangedWeak1"}; + String newModifier = possibleModifiers[random.nextInt(possibleModifiers.length)]; + enchList.appendTag(new NBTTagString(newModifier)); + } else if (!protectWeakUpgraded) { + // Only protectWeak1 is added + enchList.appendTag(new NBTTagString("protectWeak1")); + } else if (!protectRangedWeakUpgraded) { + // Only protectRangedWeak1 is added + enchList.appendTag(new NBTTagString("protectRangedWeak1")); + } + playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ); + sendNegativeModifierMessage(player, "Armor"); + } + + tag.setTag("LOTREnch", enchList); + } else if (type.equals("bow")) { + for (int i = 0; i < enchList.tagCount(); i++) { + String ench = enchList.getStringTagAt(i); + switch (ench) { + case "rangedWeak1" -> { + enchList.removeTag(i); + enchList.appendTag(new NBTTagString("rangedWeak2")); + upgraded = true; + i--; // Adjust index after removal + playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ); + sendNegativeModifierMessage(player, "Bow"); + } + case "rangedWeak2" -> { + enchList.removeTag(i); + enchList.appendTag(new NBTTagString("rangedWeak3")); + upgraded = true; + i--; // Adjust index after removal + playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ); + sendNegativeModifierMessage(player, "Bow"); + } + case "rangedWeak3" -> upgraded = true; + } + } + if (!upgraded) { + // Randomly add either rangedWeak1... etc + String[] possibleModifiers = {"rangedWeak1", "rangedWeak2", "rangedWeak3"}; + String newModifier = possibleModifiers[random.nextInt(possibleModifiers.length)]; + enchList.appendTag(new NBTTagString(newModifier)); + playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ); + sendNegativeModifierMessage(player, "Weapon"); + } + } else if (type.equals("weapon")) { + // First, iterate and upgrade if necessary + for (int i = 0; i < enchList.tagCount(); i++) { + String ench = enchList.getStringTagAt(i); + switch (ench) { + case "weak1" -> { + enchList.removeTag(i); + enchList.appendTag(new NBTTagString("weak2")); + upgraded = true; + i--; // Adjust index after removal + playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ); + sendNegativeModifierMessage(player, "Weapon"); + } + case "weak3" -> { + enchList.removeTag(i); + enchList.appendTag(new NBTTagString("weak4")); + upgraded = true; + i--; // Adjust index after removal + playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ); + sendNegativeModifierMessage(player, "Weapon"); + } + case "weak4" -> upgraded = true; + case "meleeSlow1" -> meleeSwift = true; + case "meleeUnreach1" -> meleeReach = true; + } + } + // After upgrading, check if we need to add a new modifier + if (!upgraded || !meleeSwift || !meleeReach) { + // Separate conditions for adding new modifiers + if (!upgraded && !meleeSwift && !meleeReach) { + // Randomly add one of the possible modifiers + String[] possibleModifiers = {"weak1", "weak2", "weak3", "weak4", "meleeSlow1", "meleeUnreach1"}; + String newModifier = possibleModifiers[random.nextInt(possibleModifiers.length)]; + enchList.appendTag(new NBTTagString(newModifier)); + } else if (!upgraded) { + // Only weak modifier is added + String[] weakModifiers = {"weak1", "weak2", "weak3", "weak4"}; + String newModifier = weakModifiers[random.nextInt(weakModifiers.length)]; + enchList.appendTag(new NBTTagString(newModifier)); + } else if (!meleeSwift) { + // Only meleeSlow1 is added + enchList.appendTag(new NBTTagString("meleeSlow1")); + } else if (!meleeReach) { + // Only meleeUnreach1 is added + enchList.appendTag(new NBTTagString("meleeUnreach1")); + } + + playNegativeModifierSound(player.worldObj, player.posX, player.posY, player.posZ); + sendNegativeModifierMessage(player, "Weapon"); + } + + + tag.setTag("LOTREnch", enchList); + } } + + private ItemStack getRandomWeapon() { Item[] weapons = new Item[]{LOTRMod.blacksmithHammer, LOTRMod.daggerIron, LOTRMod.dunlendingTrident, LOTRMod.battleaxeBronze, CinderLoE.cleaver}; return new ItemStack(weapons[random.nextInt(weapons.length)]); diff --git a/src/main/java/com/zivilon/cinder_loe/client/render/RenderNex.java b/src/main/java/com/zivilon/cinder_loe/client/render/RenderNex.java index ce0eeb8..99c4950 100644 --- a/src/main/java/com/zivilon/cinder_loe/client/render/RenderNex.java +++ b/src/main/java/com/zivilon/cinder_loe/client/render/RenderNex.java @@ -2,6 +2,7 @@ package com.zivilon.cinder_loe.client.render; import com.zivilon.cinder_loe.client.model.ModelNex; import com.zivilon.cinder_loe.entity.Nex; +import lotr.client.render.entity.LOTRRandomSkins; import lotr.common.entity.LOTRRandomSkinEntity; import lotr.common.entity.npc.LOTREntityBalrog; import lotr.client.render.entity.LOTRRandomSkins; diff --git a/src/main/java/com/zivilon/cinder_loe/enchants/LOTREnchantmentWeakProtectionRanged.java b/src/main/java/com/zivilon/cinder_loe/enchants/LOTREnchantmentWeakProtectionRanged.java new file mode 100644 index 0000000..d4fac14 --- /dev/null +++ b/src/main/java/com/zivilon/cinder_loe/enchants/LOTREnchantmentWeakProtectionRanged.java @@ -0,0 +1,50 @@ +package com.zivilon.cinder_loe.enchants; + +import lotr.common.enchant.LOTREnchantmentProtectionRanged; +import lotr.common.enchant.LOTREnchantmentProtectionSpecial; +import lotr.common.item.LOTRMaterial; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.StatCollector; + +public class LOTREnchantmentWeakProtectionRanged extends LOTREnchantmentProtectionSpecial { + + public LOTREnchantmentWeakProtectionRanged(String s, int level) { + super(s, level); + } + + @Override + public String getDescription(ItemStack itemstack) { + return StatCollector.translateToLocalFormatted((String)"lotr.enchant.protectRanged.desc", (Object[])new Object[]{this.formatAdditiveInt(this.calcIntProtection())}); + } + + @Override + public boolean canApply(ItemStack itemstack, boolean considering) { + if (super.canApply(itemstack, considering)) { + Item item = itemstack.getItem(); + return !(item instanceof ItemArmor) || ((ItemArmor)item).getArmorMaterial() != LOTRMaterial.GALVORN.toArmorMaterial(); + } + return false; + } + + + @Override + public boolean isBeneficial() { + // This enchantment is detrimental, so return false + return false; + } + + @Override + protected boolean protectsAgainst(DamageSource damageSource) { + return false; + } + + @Override + protected int calcIntProtection() { + return this.protectLevel; + } +} + + diff --git a/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREnchantment.java b/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREnchantment.java new file mode 100644 index 0000000..b6bb4b7 --- /dev/null +++ b/src/main/java/com/zivilon/cinder_loe/mixins/MixinLOTREnchantment.java @@ -0,0 +1,48 @@ +package com.zivilon.cinder_loe.mixins; + +import com.zivilon.cinder_loe.enchants.LOTREnchantmentWeakProtectionRanged; +import lotr.common.enchant.LOTREnchantment; +import lotr.common.enchant.LOTREnchantmentDamage; +import lotr.common.enchant.LOTREnchantmentProtectionRanged; +import lotr.common.enchant.LOTREnchantmentRangedDamage; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.lang.reflect.Field; +import java.util.Map; + +@Mixin(LOTREnchantment.class) +public class MixinLOTREnchantment { + @Inject(method = "", at = @At("TAIL")) + private static void onStaticInit(CallbackInfo ci) { + // Add your new enchantments here + try { + LOTREnchantment protectRangedWeak1 = new LOTREnchantmentWeakProtectionRanged("protectRangedWeak1", -1).setEnchantWeight(0); + LOTREnchantment protectRangedWeak2 = new LOTREnchantmentWeakProtectionRanged("protectRangedWeak2", -2).setEnchantWeight(0); + LOTREnchantment rangedWeak3 = new LOTREnchantmentRangedDamage("rangedWeak3", 0.25f); + LOTREnchantment weak4 = new LOTREnchantmentDamage("weak4", -3.0f).setEnchantWeight(0); + + LOTREnchantment.allEnchantments.add(protectRangedWeak1); + LOTREnchantment.allEnchantments.add(protectRangedWeak2); + rangedWeak3.allEnchantments.add(rangedWeak3); + LOTREnchantment.allEnchantments.add(weak4); + + Field enchantsByNameField = LOTREnchantment.class.getDeclaredField("enchantsByName"); + enchantsByNameField.setAccessible(true); + @SuppressWarnings("unchecked") + Map enchantsByName = (Map) enchantsByNameField.get(null); + + enchantsByName.put(protectRangedWeak1.enchantName, protectRangedWeak1); + enchantsByName.put(protectRangedWeak2.enchantName, protectRangedWeak2); + enchantsByName.put(rangedWeak3.enchantName, rangedWeak3); + enchantsByName.put(weak4.enchantName, weak4); + + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + +} + diff --git a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRHiredNPCInfo.java b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRHiredNPCInfo.java new file mode 100644 index 0000000..94ab98f --- /dev/null +++ b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRHiredNPCInfo.java @@ -0,0 +1,95 @@ +package com.zivilon.cinder_loe.mixins.overrides; + +import lotr.common.entity.npc.LOTREntityNPC; +import lotr.common.entity.npc.LOTRHiredNPCInfo; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.item.EntityFireworkRocket; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.UUID; + +@Mixin(LOTRHiredNPCInfo.class) +public class MixinLOTRHiredNPCInfo { + @Shadow + private LOTREntityNPC theEntity; + @Shadow + private UUID hiringPlayerUUID; + @Shadow + public int xpLevel = 1; + + @Overwrite(remap = false) + private void onLevelUp() { + EntityPlayer hirer; + if (this.theEntity.getMaxHealth() >= 60) { + this.addLevelUpHealthGain((EntityLivingBase) this.theEntity); + } + Entity mount = this.theEntity.ridingEntity; + if (mount instanceof EntityLivingBase && !(mount instanceof LOTREntityNPC)) { + this.addLevelUpHealthGain((EntityLivingBase)mount); + } + if ((hirer = this.getHiringPlayer()) != null) { + hirer.addChatMessage((IChatComponent)new ChatComponentTranslation("lotr.hiredNPC.levelUp", new Object[]{this.theEntity.getCommandSenderName(), this.xpLevel})); + } + this.spawnLevelUpFireworks(); + } + + @Overwrite(remap = false) + private void addLevelUpHealthGain(EntityLivingBase gainingEntity) { + float healthBoost = 1.0f; + IAttributeInstance attrHealth = gainingEntity.getEntityAttribute(SharedMonsterAttributes.maxHealth); + attrHealth.setBaseValue(attrHealth.getBaseValue() + (double)healthBoost); + gainingEntity.heal(healthBoost); + } + + @Overwrite(remap = false) + public EntityPlayer getHiringPlayer() { + if (this.hiringPlayerUUID == null) { + return null; + } + return this.theEntity.worldObj.func_152378_a(this.hiringPlayerUUID); + } + + private void spawnLevelUpFireworks() { + boolean bigLvlUp = this.xpLevel % 5 == 0; + World world = this.theEntity.worldObj; + ItemStack itemstack = new ItemStack(Items.fireworks); + NBTTagCompound itemData = new NBTTagCompound(); + NBTTagCompound fireworkData = new NBTTagCompound(); + NBTTagList explosionsList = new NBTTagList(); + int explosions = 1; + for (int l = 0; l < explosions; ++l) { + NBTTagCompound explosionData = new NBTTagCompound(); + explosionData.setBoolean("Flicker", true); + explosionData.setBoolean("Trail", bigLvlUp); + int[] colors = new int[]{0xFF5500, this.theEntity.getFaction().getFactionColor()}; + explosionData.setIntArray("Colors", colors); + boolean effectType = bigLvlUp; + explosionData.setByte("Type", (byte)(effectType ? 1 : 0)); + explosionsList.appendTag((NBTBase)explosionData); + } + fireworkData.setTag("Explosions", (NBTBase)explosionsList); + itemData.setTag("Fireworks", (NBTBase)fireworkData); + itemstack.setTagCompound(itemData); + EntityFireworkRocket firework = new EntityFireworkRocket(world, this.theEntity.posX, this.theEntity.boundingBox.minY + (double)this.theEntity.height, this.theEntity.posZ, itemstack); + NBTTagCompound fireworkNBT = new NBTTagCompound(); + firework.writeEntityToNBT(fireworkNBT); + fireworkNBT.setInteger("LifeTime", bigLvlUp ? 20 : 15); + firework.readEntityFromNBT(fireworkNBT); + world.spawnEntityInWorld((Entity)firework); + } + +} diff --git a/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRReplacedMethods.java b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRReplacedMethods.java new file mode 100644 index 0000000..772d827 --- /dev/null +++ b/src/main/java/com/zivilon/cinder_loe/mixins/overrides/MixinLOTRReplacedMethods.java @@ -0,0 +1,25 @@ +package com.zivilon.cinder_loe.mixins.overrides; + +import lotr.common.coremod.LOTRReplacedMethods; +import lotr.common.enchant.LOTREnchantmentHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +@Mixin(LOTRReplacedMethods.Enchants.class) +public class MixinLOTRReplacedMethods { + + /** + * @author Keylime + * @reason because Mixins complains + */ + @Overwrite(remap = false) + public static int getSpecialArmorProtection(int base, ItemStack[] armor, DamageSource source) { + int i = base; + i += LOTREnchantmentHelper.calcSpecialArmorSetProtection(armor, source); + //i = MathHelper.clamp_int(i, -25, 25); + return i; + } +} diff --git a/src/main/java/com/zivilon/cinder_loe/recipes.java b/src/main/java/com/zivilon/cinder_loe/recipes.java index 94c86ad..54f07d3 100644 --- a/src/main/java/com/zivilon/cinder_loe/recipes.java +++ b/src/main/java/com/zivilon/cinder_loe/recipes.java @@ -147,9 +147,9 @@ public class recipes { OreDictionary.registerOre("meat", LOTRMod.zebraCooked); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.fruitsalad), Items.bowl, "fruit1", "fruit2", "fruit3")); - GameRegistry.addRecipe(new CinderShapelessOreRecipe(new ItemStack(CinderLoE.pasta, 4), LOTRMod.rollingPin, CinderLoE.dough, CinderLoE.dough)); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.pasta, 4), LOTRMod.rollingPin, CinderLoE.dough, CinderLoE.dough)); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.halva), Items.sugar, CinderLoE.dough, CinderLoE.spice, LOTRMod.almond)); - //takes durability from rolling pin + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.chocolatebar, 2), LOTRMod.mugChocolate)); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(CinderLoE.pelmen), Items.wheat, "meat", LOTRMod.salt)); diff --git a/src/main/java/com/zivilon/cinder_loe/util/DurableItemCrafter.java b/src/main/java/com/zivilon/cinder_loe/util/DurableItemCrafter.java index 242a81a..6392934 100644 --- a/src/main/java/com/zivilon/cinder_loe/util/DurableItemCrafter.java +++ b/src/main/java/com/zivilon/cinder_loe/util/DurableItemCrafter.java @@ -9,6 +9,9 @@ import com.zivilon.cinder_loe.CinderLoE; public class DurableItemCrafter { public static List customItems = new ArrayList<>(); + static { + customItems.add(LOTRMod.rollingPin); + } public static List exceptionItems = new ArrayList<>(); static { customItems.add(LOTRMod.chisel); 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 c8c4b34..feca52a 100644 --- a/src/main/resources/assets/cinder_loe/lang/en_US.lang +++ b/src/main/resources/assets/cinder_loe/lang/en_US.lang @@ -260,3 +260,10 @@ lotr.unit.Bree_Horse=Bree-land Outrider entity.cinder_loe.LOTREntitySauron.name=Sauron entity.cinder_loe.UtumnoSlaveTrader.bound.name=Slave Mule entity.cinder_loe.UtumnoSlaveTrader.name=Freed Utumno Trader + +lotr.enchant.protectWeak1=Dented +lotr.enchant.protectWeak2=Defective +lotr.enchant.protectRangedWeak1=Punctured +lotr.enchant.protectRangedWeak2=Pierced +lotr.enchant.weak4=Bent +lotr.enchant.rangedWeak3=Cracked diff --git a/src/main/resources/mixins.cinder_loe.json b/src/main/resources/mixins.cinder_loe.json index 812604c..055e5b1 100644 --- a/src/main/resources/mixins.cinder_loe.json +++ b/src/main/resources/mixins.cinder_loe.json @@ -7,6 +7,9 @@ "compatibilityLevel": "JAVA_8", "mixins": [ "MixinItemRenderer", + "overrides.MixinLOTRReplacedMethods", + "overrides.MixinLOTRHiredNPCInfo", + "MixinLOTREnchantment", "MixinLOTRArmorModels", "MixinLOTRClientProxy", "MixinLOTRContainerAnvil",