2
0
Fork 0

Added upgrade kits

frozen
Shinare 1 year ago
parent 0e75cae05a
commit 2046fb8636

@ -99,7 +99,7 @@ public class CinderLoE {
@Instance("cinder_loe")
public static CinderLoE instance;
public static final Logger LOG = LogManager.getLogger(Tags.MODID);
public static Logger LOG = LogManager.getLogger(Tags.MODID);
// LOTR Materials
public static LOTRMaterial MATERIAL_RED_DWARF;
@ -188,7 +188,7 @@ public class CinderLoE {
public static Item bootsJade;
// Misc
public static Item repairKit;
public static Item forgingKit;
// Common tools/weapons
public static Item whip;
@ -615,8 +615,10 @@ public class CinderLoE {
legsJade = (new LOTRItemArmor(MATERIAL_JADE, 2,"leggings")).setUnlocalizedName("lotr:legsJade").setTextureName("lotr:legsJade").setCreativeTab(null);
bootsJade = (new LOTRItemArmor(MATERIAL_JADE, 3)).setUnlocalizedName("lotr:bootsJade").setTextureName("lotr:bootsJade").setCreativeTab(null);
forgingKit = (new ForgingKit());
ItemRegistration.register(frostblade, "frostblade", 6200);
ItemRegistration.register(repairKit,"repairKit",6001);
ItemRegistration.register(forgingKit,"forgingKit",6001);
ItemRegistration.register(whip, "whip", 6110);
ItemRegistration.register(daggervoid, "daggerVoid", 6201);
ItemRegistration.register(spearsolidgold, "spearsolidgold", 6202);

@ -0,0 +1,58 @@
package com.zivilon.cinder_loe.items;
import lotr.common.item.LOTRMaterial;
import lotr.common.item.LOTRItemSword;
import com.zivilon.cinder_loe.LoECreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.List;
public class ForgingKit extends Item {
public IIcon[] icons;
public ForgingKit() {
this.setHasSubtypes(true);
setMaxStackSize(64);
this.setMaxDamage(0);
setCreativeTab(LoECreativeTabs.tabMiscLoE);
}
@Override
public IIcon getIconFromDamage(int damage) {
if (damage < 0 || damage >= icons.length) {
damage = 0;
}
return this.icons[damage];
}
@Override
public void registerIcons(IIconRegister iconRegister) {
this.icons = new IIcon[2];
this.icons[0] = iconRegister.registerIcon("lotr:repair_kit");
this.icons[1] = iconRegister.registerIcon("lotr:upgrade_kit");
}
@Override
public String getUnlocalizedName(ItemStack item) {
switch(item.getItemDamage()) {
case 0:
return "item.repair_kit";
case 1:
return "item.upgrade_kit";
default:
return "item.repair_kit";
}
}
@Override
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < icons.length; i++) {
list.add(new ItemStack(item, 1, i));
}
}
}

@ -269,7 +269,7 @@ public abstract class MixinLOTRContainerAnvil {
combineCost += Math.max(0, Math.min(restoredUses1, restoredUses2) / 100);
}
combining = true;
} else if (!alteringNameColor && combinerItem.getItem() != CinderLoE.repairKit) {
} else if (!alteringNameColor && combinerItem.getItem() != CinderLoE.forgingKit) {
this.invOutput.setInventorySlotContents(0, null);
this.materialCost = 0;
return;
@ -358,16 +358,27 @@ public abstract class MixinLOTRContainerAnvil {
combineCost += Math.max(1, (int)combinerMod.getValueModifier());
}
}
if (combinerItem.getItem() == CinderLoE.repairKit) {
List<LOTREnchantment> repairedMods = new ArrayList<LOTREnchantment>();
for (LOTREnchantment mod : outputMods) {
if (Utilities.isBadEnch(mod)) {
combineCost += 2;
} else {
repairedMods.add(mod);
if (combinerItem.getItem() == CinderLoE.forgingKit) {
List<LOTREnchantment> newMods = new ArrayList<LOTREnchantment>();
if (combinerItem.getItemDamage() == 0) {
for (LOTREnchantment mod : outputMods) {
if (Utilities.isBadEnch(mod)) {
combineCost += 2;
} else {
newMods.add(mod);
}
}
} else {
for (LOTREnchantment mod : outputMods) {
if (Utilities.upgradedEnchants.containsKey(mod.enchantName)) {
combineCost += 2;
newMods.add(Utilities.upgradeEnch(inputCopy, mod));
} else {
newMods.add(mod);
}
}
}
outputMods = repairedMods;
outputMods = newMods;
}
LOTREnchantmentHelper.setEnchantList(inputCopy, outputMods);
}

@ -16,7 +16,9 @@ import java.time.format.DateTimeFormatter;
import java.util.UUID;
import java.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lotr.common.LOTRCreativeTabs;
import lotr.common.world.biome.LOTRBiome;
@ -33,6 +35,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.nbt.NBTBase;
@ -50,6 +53,7 @@ public class Utilities {
public static LOTRBiome reflected_river;
public static LOTRCreativeTabs reflected_tab_block;
public static List<String> badEnchants = new ArrayList<>();
public static Map<String, LOTREnchantment> upgradedEnchants = new HashMap<>();
static {
badEnchants.add("weak1");
@ -66,6 +70,27 @@ public class Utilities {
badEnchants.add("rangedWeak3");
badEnchants.add("protectRangedWeak1");
badEnchants.add("protectRangedWeak2");
upgradedEnchants.put("strong1", LOTREnchantment.strong1);
upgradedEnchants.put("strong2", LOTREnchantment.strong3);
upgradedEnchants.put("strong3", LOTREnchantment.strong4);
upgradedEnchants.put("durable1", LOTREnchantment.durable2);
upgradedEnchants.put("durable2", LOTREnchantment.durable3);
upgradedEnchants.put("knockback1", LOTREnchantment.knockback2);
upgradedEnchants.put("toolSpeed1", LOTREnchantment.toolSpeed2);
upgradedEnchants.put("toolSpeed2", LOTREnchantment.toolSpeed3);
upgradedEnchants.put("toolSpeed3", LOTREnchantment.toolSpeed4);
upgradedEnchants.put("looting1", LOTREnchantment.looting2);
upgradedEnchants.put("looting2", LOTREnchantment.looting3);
upgradedEnchants.put("protect1", LOTREnchantment.protect2);
upgradedEnchants.put("protectFire1", LOTREnchantment.protectFire2);
upgradedEnchants.put("protectFire2", LOTREnchantment.protectFire3);
upgradedEnchants.put("protectFall1", LOTREnchantment.protectFall2);
upgradedEnchants.put("protectFall2", LOTREnchantment.protectFall3);
upgradedEnchants.put("protectRanged1", LOTREnchantment.protectRanged2);
upgradedEnchants.put("protectRanged2", LOTREnchantment.protectRanged3);
upgradedEnchants.put("rangedStrong1", LOTREnchantment.rangedStrong2);
upgradedEnchants.put("rangedStrong2", LOTREnchantment.rangedStrong3);
upgradedEnchants.put("rangedKnockback1", LOTREnchantment.rangedKnockback2);
}
public static void initialize_reflects() {
@ -289,4 +314,30 @@ public class Utilities {
}
return false;
}
public static LOTREnchantment upgradeEnch(ItemStack item, LOTREnchantment ench) {
if (ench == null) return ench;
if (ench != LOTREnchantment.protect1) {
LOTREnchantment return_ench = upgradedEnchants.get(ench.enchantName);
if (return_ench == null) return_ench = ench;
return return_ench;
}
int armor_piece = ((ItemArmor)item.getItem()).armorType;
int prot = ((ItemArmor)item.getItem()).damageReduceAmount;
switch(armor_piece) {
case 0:
if (prot < 2) return upgradedEnchants.get(ench);
return ench;
case 1:
if (prot < 7) return upgradedEnchants.get(ench);
return ench;
case 2:
if (prot < 5) return upgradedEnchants.get(ench);
return ench;
case 3:
if (prot < 2) return upgradedEnchants.get(ench);
return ench;
default:
return ench;
}
}
}

Loading…
Cancel
Save