summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2014-10-20 00:22:01 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2014-10-20 00:22:01 +0100
commit0c636ab6c8937439b791740e98ba3c9adc81f7f9 (patch)
tree94dcc9e6e631cfd360e9c7387107e730e24939b5
parent76266bffc0cc1d78fc6e36498da211096765dc9b (diff)
downloadnoctis-0c636ab6c8937439b791740e98ba3c9adc81f7f9.tar.bz2
Initial attempt at a subtypeable item (catalyst)
-rw-r--r--src/main/java/net/flarn/noctis/init/ModItems.java7
-rw-r--r--src/main/java/net/flarn/noctis/item/ItemCatalyst.java62
-rw-r--r--src/main/java/net/flarn/noctis/item/ItemGlassSword.java3
-rw-r--r--src/main/java/net/flarn/noctis/refs/Names.java10
-rw-r--r--src/main/resources/assets/noctis/lang/en_GB.lang4
5 files changed, 84 insertions, 2 deletions
diff --git a/src/main/java/net/flarn/noctis/init/ModItems.java b/src/main/java/net/flarn/noctis/init/ModItems.java
index 921dcc2..0bad35e 100644
--- a/src/main/java/net/flarn/noctis/init/ModItems.java
+++ b/src/main/java/net/flarn/noctis/init/ModItems.java
@@ -2,13 +2,18 @@ package net.flarn.noctis.init;
import cpw.mods.fml.common.registry.GameRegistry;
+import net.flarn.noctis.item.ItemCatalyst;
import net.flarn.noctis.item.ItemGlassSword;
import net.flarn.noctis.item.ItemNoctisBase;
+import net.flarn.noctis.refs.Names;
public class ModItems {
public static final ItemNoctisBase glassSword = new ItemGlassSword();
+ public static final ItemCatalyst catalyst = new ItemCatalyst();
public static void init() {
- GameRegistry.registerItem(glassSword, "glassSword");
+ GameRegistry.registerItem(glassSword, Names.Items.GLASS_SWORD);
+ GameRegistry.registerItem(catalyst, Names.Items.CATALYST);
}
+
}
diff --git a/src/main/java/net/flarn/noctis/item/ItemCatalyst.java b/src/main/java/net/flarn/noctis/item/ItemCatalyst.java
new file mode 100644
index 0000000..3c95fb0
--- /dev/null
+++ b/src/main/java/net/flarn/noctis/item/ItemCatalyst.java
@@ -0,0 +1,62 @@
+package net.flarn.noctis.item;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.flarn.noctis.refs.Names;
+import net.flarn.noctis.refs.Textures;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+
+import java.util.List;
+
+public class ItemCatalyst extends ItemNoctisBase {
+
+ @SideOnly(Side.CLIENT)
+ private IIcon[] icons;
+
+ public ItemCatalyst() {
+ super();
+ this.setHasSubtypes(true);
+ this.setUnlocalizedName("catalyst");
+
+ }
+
+ @Override
+ public String getUnlocalizedName() {
+ return String.format("item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.CATALYST);
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack itemStack) {
+ int dmg = itemStack.getItemDamage();
+ if (dmg < 0 || dmg > Names.Items.CATALYSTS.length - 1) { dmg = 0; }
+ return String.format("item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.CATALYSTS[dmg]);
+ }
+
+ @Override
+ public void getSubItems(Item item, CreativeTabs creativeTab, List list) {
+ for (int meta = 0; meta < Names.Items.CATALYSTS.length; ++meta) {
+ list.add(new ItemStack(this, 1, meta));
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int meta) {
+ if (meta < 0 || meta > Names.Items.CATALYSTS.length - 1) { meta = 0; }
+ return icons[meta];
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister iconRegister) {
+ icons = new IIcon[Names.Items.CATALYSTS.length];
+ for (int i = 0; i < Names.Items.CATALYSTS.length; ++i) {
+ icons[i] = iconRegister.registerIcon(Textures.RESOURCE_PREFIX + Names.Items.CATALYSTS[i]);
+ }
+ }
+
+}
diff --git a/src/main/java/net/flarn/noctis/item/ItemGlassSword.java b/src/main/java/net/flarn/noctis/item/ItemGlassSword.java
index 6d7c0b5..5b2fa93 100644
--- a/src/main/java/net/flarn/noctis/item/ItemGlassSword.java
+++ b/src/main/java/net/flarn/noctis/item/ItemGlassSword.java
@@ -2,6 +2,7 @@ package net.flarn.noctis.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import net.flarn.noctis.refs.Names;
import net.flarn.noctis.utils.LogHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -11,7 +12,7 @@ public class ItemGlassSword extends ItemNoctisBase {
public ItemGlassSword() {
super();
- this.setUnlocalizedName("glassSword");
+ this.setUnlocalizedName(Names.Items.GLASS_SWORD);
}
@Override
diff --git a/src/main/java/net/flarn/noctis/refs/Names.java b/src/main/java/net/flarn/noctis/refs/Names.java
new file mode 100644
index 0000000..ff3fe17
--- /dev/null
+++ b/src/main/java/net/flarn/noctis/refs/Names.java
@@ -0,0 +1,10 @@
+package net.flarn.noctis.refs;
+
+public class Names {
+
+ public static final class Items {
+ public static final String GLASS_SWORD = "glassSword";
+ public static final String CATALYST = "catalyst";
+ public static final String CATALYSTS[] = new String[] { "lightCatalyst", "darkCatalyst", "mixedCatalyst" };
+ }
+}
diff --git a/src/main/resources/assets/noctis/lang/en_GB.lang b/src/main/resources/assets/noctis/lang/en_GB.lang
index 2b04600..e3820d2 100644
--- a/src/main/resources/assets/noctis/lang/en_GB.lang
+++ b/src/main/resources/assets/noctis/lang/en_GB.lang
@@ -4,3 +4,7 @@ itemGroup.noctis.creative=Noctis - Creative Mode Only Itemss
# Item localisations
item.noctis:glassSword.name=Un-attuned Glass Sword
+item.noctis:lightCatalyst.name=Catalyst attuned to the light of the moon
+item.noctis:darkCatalyst.name=Catalyst attuned to the space between the stars
+item.noctis:mixedCatalyst.name=Catalyst attuned to all the night can provide
+