forked from Lunatrius/InGame-Info-XML
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Forge to latest recommended.
Added Thaumcraft integration. Added Simply Jetpacks integration.
- Loading branch information
Showing
15 changed files
with
355 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.jar | ||
*.zip |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/github/lunatrius/ingameinfo/integration/simplyjetpacks/SimplyJetpacks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.lunatrius.ingameinfo.integration.simplyjetpacks; | ||
|
||
import com.github.lunatrius.ingameinfo.integration.simplyjetpacks.tag.TagSimplyJetpacks; | ||
import com.github.lunatrius.ingameinfo.reference.Names; | ||
import com.github.lunatrius.ingameinfo.reference.Reference; | ||
import cpw.mods.fml.common.Loader; | ||
import cpw.mods.fml.common.Mod; | ||
import cpw.mods.fml.common.Mod.EventHandler; | ||
import cpw.mods.fml.common.event.FMLPostInitializationEvent; | ||
|
||
@Mod(modid = SimplyJetpacks.MODID, name = SimplyJetpacks.NAME, version = Reference.VERSION, dependencies = SimplyJetpacks.DEPENDENCIES) | ||
public class SimplyJetpacks { | ||
public static final String MODID = Reference.MODID + "|" + Names.Mods.SIMPLYJETPACKS_MODID + "Integration"; | ||
public static final String NAME = Reference.NAME + " - " + Names.Mods.SIMPLYJETPACKS_NAME + " Integration"; | ||
public static final String DEPENDENCIES = "after:" + Reference.MODID + ";after:" + Names.Mods.SIMPLYJETPACKS_MODID; | ||
|
||
@EventHandler | ||
public void postInit(FMLPostInitializationEvent event) { | ||
if (Loader.isModLoaded(Names.Mods.SIMPLYJETPACKS_MODID)) { | ||
TagSimplyJetpacks.register(); | ||
} | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
...ava/com/github/lunatrius/ingameinfo/integration/simplyjetpacks/tag/TagSimplyJetpacks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.github.lunatrius.ingameinfo.integration.simplyjetpacks.tag; | ||
|
||
import cofh.api.energy.IEnergyContainerItem; | ||
import com.github.lunatrius.ingameinfo.tag.TagIntegration; | ||
import com.github.lunatrius.ingameinfo.tag.registry.TagRegistry; | ||
import net.minecraft.item.ItemStack; | ||
import tonius.simplyjetpacks.item.ItemJetpack; | ||
import tonius.simplyjetpacks.item.jetpack.Jetpack; | ||
|
||
import java.util.Locale; | ||
|
||
public abstract class TagSimplyJetpacks extends TagIntegration { | ||
@Override | ||
public String getCategory() { | ||
return "simplyjetpacks"; | ||
} | ||
|
||
public static class Energy extends TagSimplyJetpacks { | ||
@Override | ||
public String getValue() { | ||
try { | ||
final ItemStack chestplate = player.getCurrentArmor(2); | ||
if (chestplate != null) { | ||
if (chestplate.getItem() instanceof IEnergyContainerItem) { | ||
final IEnergyContainerItem item = (IEnergyContainerItem) chestplate.getItem(); | ||
return String.valueOf(item.getEnergyStored(chestplate)); | ||
} | ||
} | ||
} catch (Throwable e) { | ||
log(this, e); | ||
} | ||
return "-1"; | ||
} | ||
} | ||
|
||
public static class MaxEnergy extends TagSimplyJetpacks { | ||
@Override | ||
public String getValue() { | ||
try { | ||
final ItemStack chestplate = player.getCurrentArmor(2); | ||
if (chestplate != null) { | ||
if (chestplate.getItem() instanceof IEnergyContainerItem) { | ||
final IEnergyContainerItem item = (IEnergyContainerItem) chestplate.getItem(); | ||
return String.valueOf(item.getMaxEnergyStored(chestplate)); | ||
} | ||
} | ||
} catch (Throwable e) { | ||
log(this, e); | ||
} | ||
return "-1"; | ||
} | ||
} | ||
|
||
public static class Percent extends TagSimplyJetpacks { | ||
@Override | ||
public String getValue() { | ||
try { | ||
final ItemStack chestplate = player.getCurrentArmor(2); | ||
if (chestplate != null) { | ||
if (chestplate.getItem() instanceof IEnergyContainerItem) { | ||
final IEnergyContainerItem item = (IEnergyContainerItem) chestplate.getItem(); | ||
return String.format(Locale.ENGLISH, "%.2f", 100.0 * item.getEnergyStored(chestplate) / item.getMaxEnergyStored(chestplate)); | ||
} | ||
} | ||
} catch (Throwable e) { | ||
log(this, e); | ||
} | ||
return "-1"; | ||
} | ||
} | ||
|
||
public static class Enabled extends TagSimplyJetpacks { | ||
@Override | ||
public String getValue() { | ||
try { | ||
final ItemStack chestplate = player.getCurrentArmor(2); | ||
if (chestplate != null) { | ||
if (chestplate.getItem() instanceof ItemJetpack) { | ||
final ItemJetpack item = (ItemJetpack) chestplate.getItem(); | ||
final Jetpack jetpack = item.getJetpack(chestplate); | ||
return String.valueOf(jetpack != null && jetpack.isOn(chestplate)); | ||
} | ||
} | ||
} catch (Throwable e) { | ||
log(this, e); | ||
} | ||
return String.valueOf(false); | ||
} | ||
} | ||
|
||
public static class Hover extends TagSimplyJetpacks { | ||
@Override | ||
public String getValue() { | ||
try { | ||
final ItemStack chestplate = player.getCurrentArmor(2); | ||
if (chestplate != null) { | ||
if (chestplate.getItem() instanceof ItemJetpack) { | ||
final ItemJetpack item = (ItemJetpack) chestplate.getItem(); | ||
final Jetpack jetpack = item.getJetpack(chestplate); | ||
return String.valueOf(jetpack != null && jetpack.isHoverModeOn(chestplate)); | ||
} | ||
} | ||
} catch (Throwable e) { | ||
log(this, e); | ||
} | ||
return String.valueOf(false); | ||
} | ||
} | ||
|
||
public static void register() { | ||
TagRegistry.INSTANCE.register(new Energy().setName("sjenergy")); | ||
TagRegistry.INSTANCE.register(new MaxEnergy().setName("sjmaxenergy")); | ||
TagRegistry.INSTANCE.register(new Percent().setName("sjpercent")); | ||
TagRegistry.INSTANCE.register(new Enabled().setName("sjenabled")); | ||
TagRegistry.INSTANCE.register(new Hover().setName("sjhover")); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/github/lunatrius/ingameinfo/integration/thaumcraft/Thaumcraft.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.lunatrius.ingameinfo.integration.thaumcraft; | ||
|
||
import com.github.lunatrius.ingameinfo.integration.thaumcraft.tag.TagThaumcraft; | ||
import com.github.lunatrius.ingameinfo.reference.Names; | ||
import com.github.lunatrius.ingameinfo.reference.Reference; | ||
import cpw.mods.fml.common.Loader; | ||
import cpw.mods.fml.common.Mod; | ||
import cpw.mods.fml.common.Mod.EventHandler; | ||
import cpw.mods.fml.common.event.FMLPostInitializationEvent; | ||
|
||
@Mod(modid = Thaumcraft.MODID, name = Thaumcraft.NAME, version = Reference.VERSION, dependencies = Thaumcraft.DEPENDENCIES) | ||
public class Thaumcraft { | ||
public static final String MODID = Reference.MODID + "|" + Names.Mods.THAUMCRAFT_MODID + "Integration"; | ||
public static final String NAME = Reference.NAME + " - " + Names.Mods.THAUMCRAFT_NAME + " Integration"; | ||
public static final String DEPENDENCIES = "after:" + Reference.MODID + ";after:" + Names.Mods.THAUMCRAFT_MODID; | ||
|
||
@EventHandler | ||
public void postInit(FMLPostInitializationEvent event) { | ||
if (Loader.isModLoaded(Names.Mods.THAUMCRAFT_MODID)) { | ||
TagThaumcraft.register(); | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/com/github/lunatrius/ingameinfo/integration/thaumcraft/tag/TagThaumcraft.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.github.lunatrius.ingameinfo.integration.thaumcraft.tag; | ||
|
||
import com.github.lunatrius.ingameinfo.tag.TagIntegration; | ||
import com.github.lunatrius.ingameinfo.tag.registry.TagRegistry; | ||
import thaumcraft.common.Thaumcraft; | ||
|
||
public abstract class TagThaumcraft extends TagIntegration { | ||
@Override | ||
public String getCategory() { | ||
return "thaumcraft"; | ||
} | ||
|
||
public static class WarpPerm extends TagThaumcraft { | ||
@Override | ||
public String getValue() { | ||
try { | ||
return String.valueOf(Thaumcraft.proxy.getPlayerKnowledge().getWarpPerm(player.getCommandSenderName())); | ||
} catch (Throwable e) { | ||
log(this, e); | ||
} | ||
return "-1"; | ||
} | ||
} | ||
|
||
public static class WarpSticky extends TagThaumcraft { | ||
@Override | ||
public String getValue() { | ||
try { | ||
return String.valueOf(Thaumcraft.proxy.getPlayerKnowledge().getWarpSticky(player.getCommandSenderName())); | ||
} catch (Throwable e) { | ||
log(this, e); | ||
} | ||
return "-1"; | ||
} | ||
} | ||
|
||
public static class WarpTemp extends TagThaumcraft { | ||
@Override | ||
public String getValue() { | ||
try { | ||
return String.valueOf(Thaumcraft.proxy.getPlayerKnowledge().getWarpTemp(player.getCommandSenderName())); | ||
} catch (Throwable e) { | ||
log(this, e); | ||
} | ||
return "-1"; | ||
} | ||
} | ||
|
||
public static class WarpTotal extends TagThaumcraft { | ||
@Override | ||
public String getValue() { | ||
try { | ||
return String.valueOf(Thaumcraft.proxy.getPlayerKnowledge().getWarpTotal(player.getCommandSenderName())); | ||
} catch (Throwable e) { | ||
log(this, e); | ||
} | ||
return "-1"; | ||
} | ||
} | ||
|
||
public static void register() { | ||
TagRegistry.INSTANCE.register(new WarpPerm().setName("tcwarpperm")); | ||
TagRegistry.INSTANCE.register(new WarpSticky().setName("tcwarpsticky")); | ||
TagRegistry.INSTANCE.register(new WarpTemp().setName("tcwarptemp")); | ||
TagRegistry.INSTANCE.register(new WarpTotal().setName("tcwarptotal")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/github/lunatrius/ingameinfo/tag/TagIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.lunatrius.ingameinfo.tag; | ||
|
||
import com.github.lunatrius.ingameinfo.reference.Reference; | ||
|
||
public abstract class TagIntegration extends Tag { | ||
public static class TagException extends Exception { | ||
public TagException(Tag tag, Throwable cause) { | ||
super(tag.getCategory() + "/" + tag.getName(), cause); | ||
} | ||
} | ||
|
||
private boolean logged = false; | ||
|
||
protected void log(TagIntegration tag, Throwable ex) { | ||
if (!this.logged) { | ||
Reference.logger.error("Tag error!", new TagException(tag, ex)); | ||
this.logged = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.