2012-12-17 21:21:53 +01:00
|
|
|
package com.pahimar.ee3.item;
|
|
|
|
|
2012-12-19 19:09:56 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.EnumRarity;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2012-12-17 21:21:53 +01:00
|
|
|
import com.pahimar.ee3.EquivalentExchange3;
|
2012-12-20 22:45:50 +01:00
|
|
|
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
2013-01-22 04:15:51 +01:00
|
|
|
import com.pahimar.ee3.core.helper.NBTHelper;
|
2012-12-17 21:21:53 +01:00
|
|
|
import com.pahimar.ee3.core.helper.TransmutationHelper;
|
|
|
|
import com.pahimar.ee3.lib.CustomItemRarity;
|
|
|
|
import com.pahimar.ee3.lib.GuiIds;
|
|
|
|
import com.pahimar.ee3.lib.Strings;
|
2012-08-25 08:07:59 +02:00
|
|
|
|
2012-12-18 14:41:49 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2012-08-25 08:07:59 +02:00
|
|
|
|
|
|
|
/**
|
2013-03-08 19:40:59 +01:00
|
|
|
* Equivalent-Exchange-3
|
2012-08-25 08:46:51 +02:00
|
|
|
*
|
2013-03-08 19:40:59 +01:00
|
|
|
* ItemMiniumStone
|
2012-08-25 08:46:51 +02:00
|
|
|
*
|
|
|
|
* @author pahimar
|
|
|
|
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
|
|
|
*
|
|
|
|
*/
|
2013-03-19 17:15:09 +01:00
|
|
|
public class ItemMiniumStone extends ItemEE implements ITransmutationStone, IKeyBound {
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2012-08-25 08:46:51 +02:00
|
|
|
public ItemMiniumStone(int id) {
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2012-08-25 08:46:51 +02:00
|
|
|
super(id);
|
2013-03-04 17:40:40 +01:00
|
|
|
this.setUnlocalizedName(Strings.MINIUM_STONE_NAME);
|
2012-11-06 21:49:43 +01:00
|
|
|
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
|
|
this.setMaxDamage(ConfigurationSettings.MINIUM_STONE_MAX_DURABILITY - 1);
|
2012-08-25 08:46:51 +02:00
|
|
|
}
|
2013-03-08 19:40:59 +01:00
|
|
|
|
|
|
|
@Override
|
2013-01-22 21:40:15 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public boolean hasEffect(ItemStack itemStack) {
|
|
|
|
|
2013-03-08 19:40:59 +01:00
|
|
|
return NBTHelper.hasTag(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN) || NBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN);
|
2013-01-22 21:40:15 +01:00
|
|
|
}
|
2012-08-25 08:07:59 +02:00
|
|
|
|
2013-03-08 19:40:59 +01:00
|
|
|
@Override
|
2012-08-25 08:46:51 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public EnumRarity getRarity(ItemStack stack) {
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2012-08-25 08:46:51 +02:00
|
|
|
return EquivalentExchange3.proxy.getCustomRarityType(CustomItemRarity.MAGICAL);
|
|
|
|
}
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2012-09-24 21:58:15 +02:00
|
|
|
@Override
|
|
|
|
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) {
|
2012-11-30 16:47:18 +01:00
|
|
|
|
|
|
|
return false;
|
2012-09-24 21:58:15 +02:00
|
|
|
}
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2012-09-24 21:58:15 +02:00
|
|
|
@Override
|
|
|
|
public boolean getShareTag() {
|
2012-11-30 16:47:18 +01:00
|
|
|
|
|
|
|
return true;
|
2012-09-24 21:58:15 +02:00
|
|
|
}
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2012-09-24 21:58:15 +02:00
|
|
|
@Override
|
|
|
|
public ItemStack getContainerItemStack(ItemStack itemStack) {
|
2012-11-30 16:47:18 +01:00
|
|
|
|
|
|
|
itemStack.setItemDamage(itemStack.getItemDamage() + 1);
|
|
|
|
|
|
|
|
return itemStack;
|
2012-09-24 21:58:15 +02:00
|
|
|
}
|
2012-11-30 16:47:18 +01:00
|
|
|
|
|
|
|
@Override
|
2012-12-06 22:04:20 +01:00
|
|
|
public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int sideHit, float hitVecX, float hitVecY, float hitVecZ) {
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2013-01-05 00:53:34 +01:00
|
|
|
if (world.isRemote) {
|
|
|
|
transmuteBlock(itemStack, entityPlayer, world, x, y, z, sideHit);
|
|
|
|
}
|
2012-12-19 03:57:38 +01:00
|
|
|
return true;
|
2012-10-12 03:47:35 +02:00
|
|
|
}
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2012-10-29 04:16:32 +01:00
|
|
|
@Override
|
2013-01-30 04:15:59 +01:00
|
|
|
public void openPortableCraftingGUI(EntityPlayer thePlayer, ItemStack itemStack) {
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2013-01-30 04:15:59 +01:00
|
|
|
NBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN, true);
|
2012-11-30 16:47:18 +01:00
|
|
|
thePlayer.openGui(EquivalentExchange3.instance, GuiIds.PORTABLE_CRAFTING, thePlayer.worldObj, (int) thePlayer.posX, (int) thePlayer.posY, (int) thePlayer.posZ);
|
2012-10-29 04:16:32 +01:00
|
|
|
}
|
2013-03-08 19:40:59 +01:00
|
|
|
|
2013-01-30 04:15:59 +01:00
|
|
|
@Override
|
|
|
|
public void openPortableTransmutationGUI(EntityPlayer thePlayer, ItemStack itemStack) {
|
2013-03-08 19:40:59 +01:00
|
|
|
|
2013-01-30 04:15:59 +01:00
|
|
|
NBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN, true);
|
|
|
|
thePlayer.openGui(EquivalentExchange3.instance, GuiIds.PORTABLE_TRANSMUTATION, thePlayer.worldObj, (int) thePlayer.posX, (int) thePlayer.posY, (int) thePlayer.posZ);
|
|
|
|
}
|
2012-11-26 21:59:26 +01:00
|
|
|
|
2012-12-19 19:09:56 +01:00
|
|
|
@Override
|
2012-12-31 04:03:12 +01:00
|
|
|
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit) {
|
2012-12-19 19:09:56 +01:00
|
|
|
|
2012-12-31 04:03:12 +01:00
|
|
|
EquivalentExchange3.proxy.transmuteBlock(itemStack, player, world, x, y, z, sideHit);
|
2012-12-19 19:09:56 +01:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:59:26 +01:00
|
|
|
@Override
|
2012-11-30 20:03:36 +01:00
|
|
|
public void doKeyBindingAction(EntityPlayer thePlayer, ItemStack itemStack, String keyBinding) {
|
2012-11-26 21:59:26 +01:00
|
|
|
|
2012-12-05 20:33:03 +01:00
|
|
|
if (keyBinding.equals(ConfigurationSettings.KEYBINDING_EXTRA)) {
|
2013-01-30 04:15:59 +01:00
|
|
|
if (!thePlayer.isSneaking()) {
|
|
|
|
openPortableCraftingGUI(thePlayer, itemStack);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
openPortableTransmutationGUI(thePlayer, itemStack);
|
|
|
|
}
|
2012-11-26 21:59:26 +01:00
|
|
|
}
|
2012-12-19 19:09:56 +01:00
|
|
|
else if (keyBinding.equals(ConfigurationSettings.KEYBINDING_TOGGLE)) {
|
2012-12-19 22:56:49 +01:00
|
|
|
if (TransmutationHelper.targetBlockStack != null) {
|
2013-01-18 22:12:27 +01:00
|
|
|
if (!thePlayer.isSneaking()) {
|
|
|
|
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
TransmutationHelper.targetBlockStack = TransmutationHelper.getPreviousBlock(TransmutationHelper.targetBlockStack.itemID, TransmutationHelper.targetBlockStack.getItemDamage());
|
|
|
|
}
|
2012-12-19 22:56:49 +01:00
|
|
|
}
|
2012-12-19 19:09:56 +01:00
|
|
|
}
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2012-11-26 21:59:26 +01:00
|
|
|
}
|
2012-11-30 16:47:18 +01:00
|
|
|
|
2012-08-25 08:07:59 +02:00
|
|
|
}
|