2013-08-23 16:59:50 +02:00
|
|
|
package com.pahimar.ee3.item;
|
|
|
|
|
2022-11-22 15:26:15 +01:00
|
|
|
import com.pahimar.ee3.EquivalentExchange3;
|
|
|
|
import com.pahimar.ee3.reference.GUIs;
|
2014-05-23 00:35:31 +02:00
|
|
|
import com.pahimar.ee3.reference.Key;
|
2014-04-01 22:11:52 +02:00
|
|
|
import com.pahimar.ee3.reference.Names;
|
2014-07-18 21:55:10 +02:00
|
|
|
import com.pahimar.ee3.util.IKeyBound;
|
2022-11-22 15:26:15 +01:00
|
|
|
import com.pahimar.ee3.util.IOverlayItem;
|
2014-04-01 22:11:52 +02:00
|
|
|
import com.pahimar.ee3.util.NBTHelper;
|
2022-11-22 15:26:15 +01:00
|
|
|
import com.pahimar.ee3.util.TransmutationHelper;
|
2014-04-01 22:11:52 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-05-23 00:35:31 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-04-01 22:11:52 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2022-11-22 15:26:15 +01:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-04-01 22:11:52 +02:00
|
|
|
|
2023-01-03 17:47:36 +01:00
|
|
|
public class ItemMiniumStone
|
|
|
|
extends ItemEE implements IKeyBound, IOverlayItem, ITransmutationStone {
|
|
|
|
public ItemMiniumStone() {
|
2014-04-01 22:11:52 +02:00
|
|
|
super();
|
|
|
|
this.setUnlocalizedName(Names.Items.MINIUM_STONE);
|
|
|
|
this.setMaxDamage(1000); // TODO Get this from configs
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-01-03 17:47:36 +01:00
|
|
|
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) {
|
2014-04-01 22:11:52 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-01-03 17:47:36 +01:00
|
|
|
public boolean getShareTag() {
|
2014-04-01 22:11:52 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-01-03 17:47:36 +01:00
|
|
|
public ItemStack getContainerItem(ItemStack itemStack) {
|
2014-04-01 22:11:52 +02:00
|
|
|
ItemStack copiedStack = itemStack.copy();
|
|
|
|
|
|
|
|
copiedStack.setItemDamage(copiedStack.getItemDamage() + 1);
|
|
|
|
copiedStack.stackSize = 1;
|
|
|
|
|
|
|
|
return copiedStack;
|
|
|
|
}
|
|
|
|
|
2022-11-22 15:26:15 +01:00
|
|
|
@Override
|
|
|
|
public boolean hasContainerItem() {
|
|
|
|
return true;
|
2023-01-03 17:47:36 +01:00
|
|
|
}
|
2022-11-22 15:26:15 +01:00
|
|
|
|
2014-04-01 22:11:52 +02:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2023-01-03 17:47:36 +01:00
|
|
|
public boolean hasEffect(ItemStack itemStack, int renderPass) {
|
|
|
|
return NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN)
|
|
|
|
|| NBTHelper.hasKey(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN);
|
2014-04-01 22:11:52 +02:00
|
|
|
}
|
2014-05-23 00:35:31 +02:00
|
|
|
|
|
|
|
@Override
|
2023-01-03 17:47:36 +01:00
|
|
|
public void
|
|
|
|
doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) {
|
2022-11-22 15:26:15 +01:00
|
|
|
if (key == Key.EXTRA) {
|
|
|
|
if (!entityPlayer.isSneaking()) {
|
|
|
|
openPortableCraftingGUI(entityPlayer, itemStack);
|
|
|
|
} else {
|
|
|
|
//this.openPortableTransmutationGUI(entityPlayer, itemStack);
|
|
|
|
}
|
|
|
|
} else if (key == Key.TOGGLE && TransmutationHelper.targetBlockStack != null) {
|
|
|
|
if (!entityPlayer.isSneaking()) {
|
2023-01-03 17:47:36 +01:00
|
|
|
TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(
|
|
|
|
TransmutationHelper.targetBlockStack.getItem(),
|
|
|
|
TransmutationHelper.targetBlockStack.getItemDamage()
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
TransmutationHelper.targetBlockStack
|
|
|
|
= TransmutationHelper.getPreviousBlock(
|
|
|
|
TransmutationHelper.targetBlockStack.getItem(),
|
|
|
|
TransmutationHelper.targetBlockStack.getItemDamage()
|
|
|
|
);
|
2022-11-22 15:26:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-01-03 17:47:36 +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
|
|
|
|
) {
|
2022-11-22 15:26:15 +01:00
|
|
|
if (world.isRemote) {
|
|
|
|
this.transmuteBlock(itemStack, entityPlayer, world, x, y, z, sideHit);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-01-03 17:47:36 +01:00
|
|
|
public void transmuteBlock(
|
|
|
|
final ItemStack itemStack,
|
|
|
|
final EntityPlayer player,
|
|
|
|
final World world,
|
|
|
|
final int x,
|
|
|
|
final int y,
|
|
|
|
final int z,
|
|
|
|
final int sideHit
|
|
|
|
) {
|
|
|
|
EquivalentExchange3.proxy.transmuteBlock(
|
|
|
|
itemStack, player, world, x, y, z, ForgeDirection.getOrientation(sideHit)
|
|
|
|
);
|
2022-11-22 15:26:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void openPortableCraftingGUI(EntityPlayer thePlayer, ItemStack itemStack) {
|
|
|
|
NBTHelper.setBoolean(itemStack, Names.NBT.CRAFTING_GUI_OPEN, true);
|
2023-01-03 17:47:36 +01:00
|
|
|
thePlayer.openGui(
|
|
|
|
(Object) EquivalentExchange3.instance,
|
|
|
|
GUIs.PORTABLE_CRAFTING.ordinal(),
|
|
|
|
thePlayer.worldObj,
|
|
|
|
(int) thePlayer.posX,
|
|
|
|
(int) thePlayer.posY,
|
|
|
|
(int) thePlayer.posZ
|
|
|
|
);
|
2014-05-23 00:35:31 +02:00
|
|
|
}
|
2022-11-22 15:26:15 +01:00
|
|
|
|
|
|
|
@Override
|
2023-01-03 17:47:36 +01:00
|
|
|
public void
|
|
|
|
openPortableTransmutationGUI(EntityPlayer thePlayer, ItemStack itemStack) {
|
2022-11-22 15:26:15 +01:00
|
|
|
NBTHelper.setBoolean(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN, true);
|
2023-01-03 17:47:36 +01:00
|
|
|
//thePlayer.openGui((Object)EquivalentExchange3.instance, 1, thePlayer.worldObj,
|
|
|
|
//(int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ);
|
2022-11-22 15:26:15 +01:00
|
|
|
}
|
2013-08-23 16:59:50 +02:00
|
|
|
}
|