diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core')
4 files changed, 74 insertions, 5 deletions
diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java index f09b91c275..06467503d8 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_PlayerAPI.java @@ -3,7 +3,7 @@ package gtPlusPlus.core.common.compat; import api.player.client.ClientPlayerAPI; import gtPlusPlus.core.common.BasePlayer; import gtPlusPlus.core.handler.events.SneakManager; -import net.minecraftforge.common.MinecraftForge; +import gtPlusPlus.core.util.Utils; public class COMPAT_PlayerAPI { @@ -23,7 +23,7 @@ public class COMPAT_PlayerAPI { public static class clientProxy{ public static void initPre(){ - MinecraftForge.EVENT_BUS.register(SneakManager.instance); + Utils.registerEvent(SneakManager.instance); } public static void Init(){ diff --git a/src/Java/gtPlusPlus/core/item/bauble/BaseBauble.java b/src/Java/gtPlusPlus/core/item/bauble/BaseBauble.java index a280f17efb..ecaec4318f 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/BaseBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/BaseBauble.java @@ -19,14 +19,12 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.nbt.ModularArmourUtils.BT; import gtPlusPlus.core.util.nbt.NBTUtils; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingAttackEvent; @Optional.InterfaceList(value = { @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), @@ -45,7 +43,7 @@ public class BaseBauble extends Item implements IBauble { public BaseBauble(BaubleType type, String displayName) { this.mThisBauble = type; this.mDisplayName = displayName; - MinecraftForge.EVENT_BUS.register(this); + Utils.registerEvent(this); this.setMaxStackSize(1); this.setCreativeTab(AddToCreativeTab.tabMisc); this.setUnlocalizedName(Utils.sanitizeString(displayName.toLowerCase())); diff --git a/src/Java/gtPlusPlus/core/util/StringUtils.java b/src/Java/gtPlusPlus/core/util/StringUtils.java index 6aedc7943f..a4679d36a1 100644 --- a/src/Java/gtPlusPlus/core/util/StringUtils.java +++ b/src/Java/gtPlusPlus/core/util/StringUtils.java @@ -29,5 +29,69 @@ public class StringUtils { str = str.replaceAll("9", "\u2089"); return str; } + + public static boolean containsSuperOrSubScript(final String s){ + if (s.contains(StringUtils.superscript("0"))) { + return true; + } + else if (s.contains(StringUtils.superscript("1"))) { + return true; + } + else if (s.contains(StringUtils.superscript("2"))) { + return true; + } + else if (s.contains(StringUtils.superscript("3"))) { + return true; + } + else if (s.contains(StringUtils.superscript("4"))) { + return true; + } + else if (s.contains(StringUtils.superscript("5"))) { + return true; + } + else if (s.contains(StringUtils.superscript("6"))) { + return true; + } + else if (s.contains(StringUtils.superscript("7"))) { + return true; + } + else if (s.contains(StringUtils.superscript("8"))) { + return true; + } + else if (s.contains(StringUtils.superscript("9"))) { + return true; + } + if (s.contains(StringUtils.subscript("0"))) { + return true; + } + else if (s.contains(StringUtils.subscript("1"))) { + return true; + } + else if (s.contains(StringUtils.subscript("2"))) { + return true; + } + else if (s.contains(StringUtils.subscript("3"))) { + return true; + } + else if (s.contains(StringUtils.subscript("4"))) { + return true; + } + else if (s.contains(StringUtils.subscript("5"))) { + return true; + } + else if (s.contains(StringUtils.subscript("6"))) { + return true; + } + else if (s.contains(StringUtils.subscript("7"))) { + return true; + } + else if (s.contains(StringUtils.subscript("8"))) { + return true; + } + else if (s.contains(StringUtils.subscript("9"))) { + return true; + } + return false; + } } diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 979c1f0287..9ef411fcc5 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -49,6 +49,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -230,6 +231,12 @@ public class Utils { public static void LOG_ASM(final String s) { FMLRelaunchLog.info("", s); } + + //Register an event to both busses. + public static void registerEvent(Object o){ + MinecraftForge.EVENT_BUS.register(o); + FMLCommonHandler.instance().bus().register(o); + } public static void paintBox(final Graphics g, final int MinA, final int MinB, final int MaxA, final int MaxB) { g.drawRect(MinA, MinB, MaxA, MaxB); |