2022-10-26 19:42:44 +02:00
|
|
|
package assemblyline.common.machine.encoder;
|
|
|
|
|
2023-02-10 17:51:10 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2022-10-26 19:42:44 +02:00
|
|
|
import assemblyline.common.TabAssemblyLine;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTBase;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
|
|
|
|
2023-02-10 17:51:10 +01:00
|
|
|
public class ItemDisk extends Item {
|
2022-10-26 19:42:44 +02:00
|
|
|
public ItemDisk() {
|
|
|
|
super();
|
|
|
|
this.setUnlocalizedName("disk");
|
|
|
|
this.setCreativeTab(TabAssemblyLine.INSTANCE);
|
|
|
|
this.setHasSubtypes(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-02-10 17:51:10 +01:00
|
|
|
@SideOnly(value = Side.CLIENT)
|
2022-10-26 19:42:44 +02:00
|
|
|
public void registerIcons(IIconRegister par1IconRegister) {
|
|
|
|
this.itemIcon = par1IconRegister.registerIcon("assemblyline:disk");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemStackLimit() {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-02-10 17:51:10 +01:00
|
|
|
public void addInformation(
|
|
|
|
ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4
|
|
|
|
) {
|
2022-10-26 19:42:44 +02:00
|
|
|
ArrayList commands = ItemDisk.getCommands(itemStack);
|
|
|
|
if (commands.size() > 0) {
|
|
|
|
if (commands.size() == 1) {
|
|
|
|
list.add(commands.size() + " command");
|
|
|
|
} else {
|
|
|
|
list.add(commands.size() + " commands");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
list.add("No commands");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setCommands(ItemStack itemStack, ArrayList commands) {
|
|
|
|
if (itemStack.getTagCompound() == null) {
|
|
|
|
itemStack.setTagCompound(new NBTTagCompound());
|
|
|
|
}
|
|
|
|
NBTTagList nbt = new NBTTagList();
|
|
|
|
for (int i = 0; i < commands.size(); ++i) {
|
2023-02-10 17:51:10 +01:00
|
|
|
if (commands.get(i) == null)
|
|
|
|
continue;
|
2022-10-26 19:42:44 +02:00
|
|
|
NBTTagCompound newCompound = new NBTTagCompound();
|
2023-02-10 17:51:10 +01:00
|
|
|
newCompound.setString("command", (String) commands.get(i));
|
|
|
|
nbt.appendTag((NBTBase) newCompound);
|
2022-10-26 19:42:44 +02:00
|
|
|
}
|
2023-02-10 17:51:10 +01:00
|
|
|
itemStack.getTagCompound().setTag("Commands", (NBTBase) nbt);
|
2022-10-26 19:42:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static ArrayList getCommands(ItemStack itemStack) {
|
|
|
|
ArrayList<String> commands = new ArrayList<String>();
|
|
|
|
if (itemStack.getTagCompound() == null) {
|
|
|
|
itemStack.setTagCompound(new NBTTagCompound());
|
|
|
|
}
|
|
|
|
NBTTagCompound nbt = itemStack.getTagCompound();
|
|
|
|
NBTTagList tagList = nbt.getTagList("Commands", 10);
|
|
|
|
for (int i = 0; i < tagList.tagCount(); ++i) {
|
|
|
|
NBTTagCompound curTag = tagList.getCompoundTagAt(i);
|
|
|
|
String cmd = curTag.getString("command");
|
|
|
|
commands.add(cmd);
|
|
|
|
}
|
|
|
|
return commands;
|
|
|
|
}
|
|
|
|
}
|