summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/item
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-15 16:52:41 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-15 16:52:41 +0200
commit06415dc21d71e8ac363dae5c56c5317971f7aede (patch)
tree7ddbe2cc709a5a39c3fe8b8a80d7ac77f336a220 /common/darkknight/jewelrycraft/item
parent9342967bd8a6a9451591325c7c5deb5416819adc (diff)
parent943f1a493b27c630e95730b385e6524643d98564 (diff)
Merge branch 'master' of https://github.com/sor1n/Modjam-Mod
As well as added the smelter and working on the molder
Diffstat (limited to 'common/darkknight/jewelrycraft/item')
-rw-r--r--common/darkknight/jewelrycraft/item/ItemBase.java18
-rw-r--r--common/darkknight/jewelrycraft/item/ItemList.java24
-rw-r--r--common/darkknight/jewelrycraft/item/ItemThiefGloves.java64
3 files changed, 106 insertions, 0 deletions
diff --git a/common/darkknight/jewelrycraft/item/ItemBase.java b/common/darkknight/jewelrycraft/item/ItemBase.java
new file mode 100644
index 0000000..7f806bf
--- /dev/null
+++ b/common/darkknight/jewelrycraft/item/ItemBase.java
@@ -0,0 +1,18 @@
+package darkknight.jewelrycraft.item;
+
+import net.minecraft.item.Item;
+
+public class ItemBase extends Item
+{
+ public ItemBase(int par1)
+ {
+ super(par1);
+ }
+
+ @Override
+ public Item setUnlocalizedName(String name)
+ {
+ Item r = super.setUnlocalizedName(name);
+ return r.setTextureName(name.replaceAll("\\.", ":"));
+ }
+}
diff --git a/common/darkknight/jewelrycraft/item/ItemList.java b/common/darkknight/jewelrycraft/item/ItemList.java
new file mode 100644
index 0000000..7bf3705
--- /dev/null
+++ b/common/darkknight/jewelrycraft/item/ItemList.java
@@ -0,0 +1,24 @@
+package darkknight.jewelrycraft.item;
+
+import net.minecraft.item.Item;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.config.ConfigHandler;
+
+public class ItemList
+{
+ public static Item thiefGloves;
+ public static Item shadowIngot;
+
+ private static boolean isInitialized = false;
+
+ public static void preInit(FMLPreInitializationEvent e)
+ {
+ if (!isInitialized)
+ {
+ thiefGloves = new ItemThiefGloves(ConfigHandler.idThiefGloves).setUnlocalizedName("jewelrycraft.thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft);
+ shadowIngot = new ItemBase(ConfigHandler.idShadowIngot).setUnlocalizedName("jewelrycraft.ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft);
+
+ }
+ }
+}
diff --git a/common/darkknight/jewelrycraft/item/ItemThiefGloves.java b/common/darkknight/jewelrycraft/item/ItemThiefGloves.java
new file mode 100644
index 0000000..97d83cd
--- /dev/null
+++ b/common/darkknight/jewelrycraft/item/ItemThiefGloves.java
@@ -0,0 +1,64 @@
+package darkknight.jewelrycraft.item;
+
+import java.util.Iterator;
+import java.util.Random;
+
+import cpw.mods.fml.relauncher.ReflectionHelper;
+
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.passive.EntityVillager;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.village.MerchantRecipe;
+import net.minecraft.village.MerchantRecipeList;
+
+public class ItemThiefGloves extends ItemBase
+{
+ public Random rand;
+ public ItemThiefGloves(int par1)
+ {
+ super(par1);
+ this.setCreativeTab(CreativeTabs.tabTools);
+ }
+
+ @Override
+ public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase)
+ {
+ if (par3EntityLivingBase instanceof EntityVillager)
+ {
+ EntityVillager villager = (EntityVillager) par3EntityLivingBase;
+ int wealth = (Integer) ReflectionHelper.getPrivateValue(EntityVillager.class, villager, "wealth", "field_70956_bz");
+ MerchantRecipeList buyingList = (MerchantRecipeList) ReflectionHelper.getPrivateValue(EntityVillager.class, villager, "buyingList", "field_70963_i");
+ if(buyingList!=null)
+ {
+ Iterator<?> iterator = buyingList.iterator();
+ while(iterator.hasNext())
+ {
+ MerchantRecipe recipe = (MerchantRecipe)iterator.next();
+ int quantity;
+ if(recipe.getItemToSell().isStackable()) quantity = recipe.getItemToSell().stackSize * 7;
+ else quantity = 1;
+ ItemStack s = new ItemStack(recipe.getItemToSell().itemID, quantity, recipe.getItemToSell().getItemDamage());
+ s.setTagCompound(recipe.getItemToSell().getTagCompound());
+ if(par2EntityPlayer.inventory.addItemStackToInventory(s));
+ else villager.entityDropItem(s, 0);
+ par2EntityPlayer.addChatMessage("Villager #" + villager.getProfession() + ": Hmmm... I seem to have lost my " + s.getDisplayName() + "!");
+ }
+ buyingList.clear();
+ ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 300, "timeUntilReset", "field_70961_j");
+ ReflectionHelper.setPrivateValue(EntityVillager.class, villager, true, "needsInitilization", "field_70959_by");
+ }
+
+ villager.dropItem(Item.emerald.itemID, wealth);
+ ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 0, "wealth", "field_70956_bz");
+ return true;
+ }
+ else
+ {
+ return super.itemInteractionForEntity(par1ItemStack, par2EntityPlayer, par3EntityLivingBase);
+ }
+ }
+
+}