summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbspkrs <bspkrs@gmail.com>2013-12-16 13:50:31 -0500
committerbspkrs <bspkrs@gmail.com>2013-12-16 13:50:31 -0500
commit6c4d552878efb37c98dad381b6256cca95436e1c (patch)
tree55e2d7b40d497f13972cad14a801d321dbfbea37
parent54138e01c39832c7d95fb76e83b6a1d7ae30087a (diff)
parentf4d6af6c84bce89c6189f9d9c821e5ec58eacdfa (diff)
Merge branch 'master' of https://github.com/sor1n/Modjam-Mod
Conflicts: common/darkknight/jewelrycraft/block/BlockMolder.java common/darkknight/jewelrycraft/item/ItemRing.java
-rw-r--r--common/darkknight/jewelrycraft/block/BlockMolder.java20
-rw-r--r--common/darkknight/jewelrycraft/item/ItemRing.java72
2 files changed, 25 insertions, 67 deletions
diff --git a/common/darkknight/jewelrycraft/block/BlockMolder.java b/common/darkknight/jewelrycraft/block/BlockMolder.java
index 39d567a..0003015 100644
--- a/common/darkknight/jewelrycraft/block/BlockMolder.java
+++ b/common/darkknight/jewelrycraft/block/BlockMolder.java
@@ -5,6 +5,8 @@ import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -41,7 +43,7 @@ public class BlockMolder extends BlockContainer
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
- {
+ {
TileEntityMolder te = (TileEntityMolder) world.getBlockTileEntity(i, j, k);
ItemStack item = entityPlayer.inventory.getCurrentItem();
if (te != null && item != null && !te.hasMold && item.itemID == ItemList.molds.itemID)
@@ -61,7 +63,7 @@ public class BlockMolder extends BlockContainer
@Override
public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int par5)
- {
+ {
TileEntityMolder te = (TileEntityMolder) world.getBlockTileEntity(i, j, k);
if (te != null)
{
@@ -103,29 +105,25 @@ public class BlockMolder extends BlockContainer
@Override
public void onBlockDestroyedByExplosion(World world, int i, int j, int k, Explosion par5Explosion)
- {
+ {
onBlockDestroyedByPlayer(world, i, j, k, 0);
}
- public void giveJewelToPlayer(TileEntityMolder md, EntityPlayer player, ItemStack item, ItemStack metal)
+ public void giveJewelToPlayer(TileEntityMolder md, EntityPlayer player, ItemStack item, String metal)
{
if (item != null)
{
- ItemStack copy = null;
if (item.itemID == ItemList.ring.itemID && metal != null)
{
- ItemRing r = (ItemRing) new ItemRing(ItemList.ring.itemID, metal).setUnlocalizedName("jewelrycraft.ring");
- copy = new ItemStack(r);
+ ItemRing.addMetal(item, metal);
}
- else
- copy = item;
- player.inventory.addItemStackToInventory(copy);
+ player.inventory.addItemStackToInventory(item);
}
}
@Override
public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player)
- {
+ {
TileEntityMolder me = (TileEntityMolder) world.getBlockTileEntity(i, j, k);
if (me != null && me.hasJewelBase)
{
diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java
index 30d0be4..17f961d 100644
--- a/common/darkknight/jewelrycraft/item/ItemRing.java
+++ b/common/darkknight/jewelrycraft/item/ItemRing.java
@@ -5,93 +5,53 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.world.World;
public class ItemRing extends ItemBase
{
- public ItemStack ingot;
+ public static String ingot;
public PotionEffect effect;
-
+
public ItemRing(int par1)
{
super(par1);
this.setMaxStackSize(1);
}
-
- public ItemRing(int par1, ItemStack ingot)
+
+ public ItemRing(int par1, String ingot)
{
this(par1);
this.ingot = ingot;
}
-
- public ItemRing(int par1, ItemStack ingot, PotionEffect effect)
+
+ public ItemRing(int par1, String ingot, PotionEffect effect)
{
this(par1, ingot);
this.effect = effect;
}
+ NBTTagCompound tag = new NBTTagCompound();
- public int getColor(ItemStack par1ItemStack)
+ public String getMetal(ItemStack stack)
{
- return 65535;
+ return tag.getString("ingot");
}
- @Override
- public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
+ public static void addMetal(ItemStack item, String metal)
{
- par2EntityPlayer.addChatMessage("Hello");
- return true;
+ NBTTagCompound tag = new NBTTagCompound();
+ item.setTagCompound(tag);
+ tag.setString("ingot", metal);
+ ingot = metal;
}
/**
* allows items to add custom lines of information to the mouseover description
*/
- @Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
- if (ingot != null)
- list.add(EnumChatFormatting.GRAY + ingot.getDisplayName());
- if (effect != null)
- list.add(EnumChatFormatting.GREEN + effect.getEffectName());
- }
-
- public void addEnchantment(ItemStack ringStack, ItemStack ingotStack)
- {
- NBTTagList nbttaglist = this.func_92110_g(ringStack);
- boolean flag = true;
-
- for (int i = 0; i < nbttaglist.tagCount(); ++i)
- {
- NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.tagAt(i);
-
- if (nbttagcompound.getShort("id") == par2EnchantmentData.enchantmentobj.effectId)
- {
- if (nbttagcompound.getShort("lvl") < par2EnchantmentData.enchantmentLevel)
- {
- nbttagcompound.setShort("lvl", (short) par2EnchantmentData.enchantmentLevel);
- }
-
- flag = false;
- break;
- }
- }
-
- if (flag)
- {
- NBTTagCompound nbttagcompound1 = new NBTTagCompound();
- nbttagcompound1.setShort("id", (short) par2EnchantmentData.enchantmentobj.effectId);
- nbttagcompound1.setShort("lvl", (short) par2EnchantmentData.enchantmentLevel);
- nbttaglist.appendTag(nbttagcompound1);
- }
-
- if (!ringStack.hasTagCompound())
- {
- ringStack.setTagCompound(new NBTTagCompound());
- }
-
- ringStack.getTagCompound().setTag("StoredEnchantments", nbttaglist);
+ if(ingot != null) list.add(EnumChatFormatting.GRAY + ingot);
+ if(effect != null) list.add(EnumChatFormatting.GREEN + effect.getEffectName());
}
}