summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2014-10-20 21:04:55 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2014-10-20 21:04:55 +0100
commitb12bbd5abd3af86b5247084b159cb241e7fb9835 (patch)
treed29d116a7456a2494ea71e27c5d9119ce78de816
parent3e1ce1482d7e74a7edeb9cd70d0edecf08480565 (diff)
downloadnoctis-b12bbd5abd3af86b5247084b159cb241e7fb9835.tar.bz2
Tidy up catalyst, and add localisation support for tooltip
-rw-r--r--src/main/java/net/flarn/noctis/item/ItemCatalyst.java38
-rw-r--r--src/main/java/net/flarn/noctis/refs/Strings.java8
-rw-r--r--src/main/java/net/flarn/noctis/refs/Tags.java9
-rw-r--r--src/main/resources/assets/noctis/lang/en_GB.lang3
4 files changed, 41 insertions, 17 deletions
diff --git a/src/main/java/net/flarn/noctis/item/ItemCatalyst.java b/src/main/java/net/flarn/noctis/item/ItemCatalyst.java
index d2038a2..bb60094 100644
--- a/src/main/java/net/flarn/noctis/item/ItemCatalyst.java
+++ b/src/main/java/net/flarn/noctis/item/ItemCatalyst.java
@@ -1,22 +1,22 @@
package net.flarn.noctis.item;
-import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.flarn.noctis.refs.Names;
+import net.flarn.noctis.refs.Strings;
+import net.flarn.noctis.refs.Tags;
import net.flarn.noctis.refs.Textures;
import net.flarn.noctis.utils.LogHelper;
import net.flarn.noctis.utils.NBTHelper;
import net.flarn.noctis.utils.PlayerHelper;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.server.MinecraftServer;
import net.minecraft.util.IIcon;
+import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import java.util.List;
@@ -56,7 +56,7 @@ public class ItemCatalyst extends ItemNoctisBase {
public ItemCatalyst() {
super();
this.setHasSubtypes(true);
- this.setUnlocalizedName("catalyst");
+ this.setUnlocalizedName(Names.Items.CATALYST);
}
@@ -67,7 +67,7 @@ public class ItemCatalyst extends ItemNoctisBase {
@Override
public String getUnlocalizedName(ItemStack itemStack) {
- CatalystType ctype = CatalystType.fromIndex(NBTHelper.getInt(itemStack, "type", 0));
+ CatalystType ctype = CatalystType.fromIndex(NBTHelper.getInt(itemStack, Tags.General.TYPE, 0));
return String.format("item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.CATALYSTS[ctype.getIndex()]);
}
@@ -75,7 +75,7 @@ public class ItemCatalyst extends ItemNoctisBase {
public void getSubItems(Item item, CreativeTabs creativeTab, List list) {
for (int meta = 0; meta < Names.Items.CATALYSTS.length; ++meta) {
ItemStack s = new ItemStack(this, 1, 0);
- NBTHelper.setInt(s, "type", meta);
+ NBTHelper.setInt(s, Tags.General.TYPE, meta);
list.add(s);
}
}
@@ -83,7 +83,7 @@ public class ItemCatalyst extends ItemNoctisBase {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack itemStack) {
- CatalystType ctype = CatalystType.fromIndex(NBTHelper.getInt(itemStack, "type", 0));
+ CatalystType ctype = CatalystType.fromIndex(NBTHelper.getInt(itemStack, Tags.General.TYPE, 0));
return icons[ctype.getIndex()];
}
@@ -105,20 +105,24 @@ public class ItemCatalyst extends ItemNoctisBase {
@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
// We return true only if we do not want normal entity update behaviour (which we do)
- if (entityItem.age % 20 == 0) {
- LogHelper.warn("Ruhroh! " + entityItem + " is on the floor!");
+ if (entityItem.age % 20 != 0) {
+ return false;
}
+ if (!NBTHelper.hasEntry(entityItem.getEntityItem(), Tags.General.OWNER)) {
+ return false;
+ }
+ LogHelper.warn("Ruhroh, we're on the ground!");
return false;
}
@Override
public ItemStack onItemRightClick(ItemStack s, World w, EntityPlayer p)
{
- if (!NBTHelper.hasEntry(s, "owner")) {
- NBTHelper.setUUID(s, "owner", p.getUniqueID());
+ if (!NBTHelper.hasEntry(s, Tags.General.OWNER)) {
+ NBTHelper.setUUID(s, Tags.General.OWNER, p.getUniqueID());
LogHelper.warn("Set ownership of " + s + " to " + p.getUniqueID());
} else {
- LogHelper.warn("Owner already set to " + NBTHelper.getUUID(s, "owner"));
+ LogHelper.warn("Owner already set to " + NBTHelper.getUUID(s, Tags.General.OWNER));
LogHelper.warn("Player ID is " + p.getUniqueID());
}
@@ -129,18 +133,18 @@ public class ItemCatalyst extends ItemNoctisBase {
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack s, EntityPlayer p, List strs, boolean b) {
strs.add("");
- if (!NBTHelper.hasEntry(s, "owner")) {
- strs.add("This catalyst seems dull and lifeless");
+ if (!NBTHelper.hasEntry(s, Tags.General.OWNER)) {
+ strs.add(StatCollector.translateToLocal(Strings.CATALYST_LIFELESS));
} else {
- UUID ownerid = NBTHelper.getUUID(s, "owner");
- strs.add("This catalyst thrums with the power of " + PlayerHelper.getPlayerNameFromUUID(ownerid));
+ UUID ownerid = NBTHelper.getUUID(s, Tags.General.OWNER);
+ strs.add(StatCollector.translateToLocalFormatted(Strings.CATALYST_THRUMS, PlayerHelper.getPlayerNameFromUUID(ownerid)));
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack s, int pass) {
- return NBTHelper.hasEntry(s, "owner");
+ return NBTHelper.hasEntry(s, Tags.General.OWNER);
}
}
diff --git a/src/main/java/net/flarn/noctis/refs/Strings.java b/src/main/java/net/flarn/noctis/refs/Strings.java
new file mode 100644
index 0000000..c34e808
--- /dev/null
+++ b/src/main/java/net/flarn/noctis/refs/Strings.java
@@ -0,0 +1,8 @@
+package net.flarn.noctis.refs;
+
+// These are strings which can be translated
+public class Strings {
+ public static final String DESC_PREFIX = "desc." + Refs.MOD_ID.toLowerCase() + ":";
+ public static final String CATALYST_LIFELESS = DESC_PREFIX + "catalyst.lifeless";
+ public static final String CATALYST_THRUMS = DESC_PREFIX + "catalyst.thrums";
+}
diff --git a/src/main/java/net/flarn/noctis/refs/Tags.java b/src/main/java/net/flarn/noctis/refs/Tags.java
new file mode 100644
index 0000000..d523f64
--- /dev/null
+++ b/src/main/java/net/flarn/noctis/refs/Tags.java
@@ -0,0 +1,9 @@
+package net.flarn.noctis.refs;
+
+
+public class Tags {
+ public static final class General {
+ public static final String OWNER = "owner";
+ public static final String TYPE = "type";
+ }
+}
diff --git a/src/main/resources/assets/noctis/lang/en_GB.lang b/src/main/resources/assets/noctis/lang/en_GB.lang
index e3820d2..96b4cc2 100644
--- a/src/main/resources/assets/noctis/lang/en_GB.lang
+++ b/src/main/resources/assets/noctis/lang/en_GB.lang
@@ -8,3 +8,6 @@ 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
+# Description localisations
+desc.noctis:catalyst.lifeless=This seems dull and lifeless
+desc.noctis:catalyst.thrums=This thrums with the power of %s