2015-04-11 21:46:55 +02:00
|
|
|
package techreborn.items;
|
|
|
|
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2015-06-14 01:21:03 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2015-04-11 21:46:55 +02:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-06-14 01:21:03 +02:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import techreborn.Core;
|
|
|
|
import techreborn.client.GuiHandler;
|
2015-05-06 02:50:34 +02:00
|
|
|
import techreborn.client.TechRebornCreativeTab;
|
2015-06-07 05:52:51 +02:00
|
|
|
import techreborn.init.ModItems;
|
2015-11-24 23:58:18 +01:00
|
|
|
import techreborn.lib.ModInfo;
|
2015-04-15 17:23:12 +02:00
|
|
|
|
2016-04-30 06:21:28 +02:00
|
|
|
import java.security.InvalidParameterException;
|
|
|
|
import java.util.List;
|
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public class ItemParts extends ItemTextureBase {
|
2016-04-30 06:21:28 +02:00
|
|
|
public static final String[] types = new String[] { "energyFlowCircuit", "dataControlCircuit", "dataStorageCircuit",
|
2016-10-08 21:46:16 +02:00
|
|
|
"dataOrb", "diamondGrindingHead", "diamondSawBlade", "tungstenGrindingHead", "heliumCoolantSimple",
|
|
|
|
"heliumCoolantTriple", "heliumCoolantSix", "NaKCoolantSimple", "NaKCoolantTriple", "NaKCoolantSix",
|
|
|
|
"cupronickelHeatingCoil", "nichromeHeatingCoil", "kanthalHeatingCoil", ModItems.META_PLACEHOLDER, "superConductor",
|
|
|
|
"thoriumCell", "doubleThoriumCell", "quadThoriumCell", "plutoniumCell", "doublePlutoniumCell",
|
|
|
|
"quadPlutoniumCell", "computerMonitor", "machineParts", "neutronReflector", "iridiumNeutronReflector",
|
|
|
|
"thickNeutronReflector", "electronicCircuit", "advancedCircuit", "rubberSap", "rubber", "scrap",
|
|
|
|
"carbonmesh", "carbonfiber", "coolantSimple", "coolantTriple", "coolantSix" };
|
2015-04-15 17:23:12 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public ItemParts() {
|
2016-03-25 10:47:34 +01:00
|
|
|
setCreativeTab(TechRebornCreativeTab.instance);
|
|
|
|
setHasSubtypes(true);
|
|
|
|
setUnlocalizedName("techreborn.part");
|
|
|
|
}
|
2015-04-15 17:23:12 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public static ItemStack getPartByName(String name, int count) {
|
|
|
|
for (int i = 0; i < types.length; i++) {
|
|
|
|
if (types[i].equalsIgnoreCase(name)) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return new ItemStack(ModItems.parts, count, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new InvalidParameterException("The part " + name + " could not be found.");
|
|
|
|
}
|
2015-04-11 21:46:55 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public static ItemStack getPartByName(String name) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return getPartByName(name, 1);
|
|
|
|
}
|
2015-04-11 21:46:55 +02:00
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
@Override
|
|
|
|
// gets Unlocalized Name depending on meta data
|
2016-10-08 21:46:16 +02:00
|
|
|
public String getUnlocalizedName(ItemStack itemStack) {
|
2016-03-25 10:47:34 +01:00
|
|
|
int meta = itemStack.getItemDamage();
|
2016-10-08 21:46:16 +02:00
|
|
|
if (meta < 0 || meta >= types.length) {
|
2016-03-25 10:47:34 +01:00
|
|
|
meta = 0;
|
|
|
|
}
|
2015-04-11 21:46:55 +02:00
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
return super.getUnlocalizedName() + "." + types[meta];
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
// Adds Dusts SubItems To Creative Tab
|
2016-10-08 21:46:16 +02:00
|
|
|
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
|
|
|
|
for (int meta = 0; meta < types.length; ++meta) {
|
|
|
|
if (!types[meta].equals(ModItems.META_PLACEHOLDER)) {
|
2016-06-02 19:21:23 +02:00
|
|
|
list.add(new ItemStack(item, 1, meta));
|
|
|
|
}
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
|
|
|
|
switch (itemStack.getItemDamage()) {
|
2016-04-24 22:07:56 +02:00
|
|
|
case 37: // Destructo pack
|
|
|
|
player.openGui(Core.INSTANCE, GuiHandler.destructoPackID, world, (int) player.posX, (int) player.posY,
|
2016-10-08 21:46:16 +02:00
|
|
|
(int) player.posY);
|
2016-04-24 22:07:56 +02:00
|
|
|
break;
|
2016-03-25 10:47:34 +01:00
|
|
|
}
|
|
|
|
return itemStack;
|
|
|
|
}
|
2015-08-09 12:05:32 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
@Override
|
|
|
|
public String getTextureName(int damage) {
|
2016-03-25 10:47:34 +01:00
|
|
|
return ModInfo.MOD_ID + ":items/part/" + types[damage];
|
|
|
|
}
|
2015-10-22 19:19:05 +02:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
@Override
|
|
|
|
public int getMaxMeta() {
|
2016-03-25 10:47:34 +01:00
|
|
|
return types.length;
|
|
|
|
}
|
2015-04-11 21:46:55 +02:00
|
|
|
}
|