Some restructuring/renaming for consistency

This commit is contained in:
Bernhard Bonigl committed 2014-07-16 20:49:58 +02:00
1 parent e926f13ca8
commit c710679e35
10 files changed
+45 -43

No files matched your search

@@ -3,6 +3,8 @@ package iguanaman.iguanatweakstconstruct.leveling;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import iguanaman.iguanatweakstconstruct.leveling.handlers.LevelingEventHandler;
import iguanaman.iguanatweakstconstruct.leveling.handlers.ToolTipHandler;
import iguanaman.iguanatweakstconstruct.reference.IguanaReference;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.Pulse;
@@ -11,11 +11,10 @@ import tconstruct.library.ActiveToolMod;
import tconstruct.library.tools.HarvestTool;
import tconstruct.library.tools.ToolCore;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
// This class is responsible for actually getting XP when mining!
public class LevelingActiveToolMod extends ActiveToolMod {
// TODO: make this customizable?
static List<Material> materialBlacklist = Arrays.asList(
@@ -52,7 +51,7 @@ public class LevelingActiveToolMod extends ActiveToolMod {
// only give xp if the use makes sense
if(harvestable && effective && strong)
// TODO: maybe give xp depending on WHAT block was mined? (xp determined by hardness, if it was an ore, etc.)
IguanaLevelingLogic.addXP(stack, (EntityPlayer) entity, 1);
LevelingLogic.addXP(stack, (EntityPlayer) entity, 1);
return false;
}
@@ -28,7 +28,7 @@ import tconstruct.modifiers.tools.ModSmite;
* - If pick-boosting is enabled, all the xp you gain also fills a secondary xp-bar, the mining-boost-xp
* - When your mining-boost-xp is full, your mining level is increased by 1. Only works once per pick.
*/
public abstract class IguanaLevelingLogic {
public abstract class LevelingLogic {
public static final String TAG_EXP = "ToolEXP";
public static final String TAG_LEVEL = "ToolLevel";
public static final String TAG_BOOST_EXP = "HeadEXP"; // HeadEXP for downwards compatibility
@@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
// utility class for constructing tooltip
public abstract class IguanaLevelingTooltips {
public abstract class LevelingTooltips {
/**
* Returns only the XP progress. Standard is %.
@@ -44,8 +44,8 @@ public abstract class IguanaLevelingTooltips {
{
if (tags == null) tags = tool.getTagCompound().getCompoundTag("InfiTool");
int requiredXp = IguanaLevelingLogic.getRequiredXp(tool, tags, boostXp);
long currentXp = boostXp ? tags.getLong(IguanaLevelingLogic.TAG_BOOST_EXP) : tags.getLong(IguanaLevelingLogic.TAG_EXP);
int requiredXp = LevelingLogic.getRequiredXp(tool, tags, boostXp);
long currentXp = boostXp ? tags.getLong(LevelingLogic.TAG_BOOST_EXP) : tags.getLong(LevelingLogic.TAG_EXP);
float xpPercentage = (float)currentXp / (float)requiredXp * 100f;
String xpPercentageString = String.format("%.2f", xpPercentage) + "%";
@@ -1,6 +1,6 @@
package iguanaman.iguanatweakstconstruct.leveling.commands;
import iguanaman.iguanatweakstconstruct.leveling.IguanaLevelingLogic;
import iguanaman.iguanatweakstconstruct.leveling.LevelingLogic;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
@@ -42,13 +42,13 @@ public class IguanaCommandLevelUpTool extends CommandBase {
{
Long toolXP = tags.hasKey("ToolEXP") ? tags.getLong("ToolEXP") : -1;
Long headXP = tags.hasKey("HeadEXP") ? tags.getLong("HeadEXP") : -1;
long requiredToolXP = IguanaLevelingLogic.getRequiredXp(equipped, tags) - toolXP;
long requiredHeadXP = tags.hasKey("HeadEXP") && hLevel >= TConstructRegistry.getMaterial("Copper").harvestLevel() && hLevel < TConstructRegistry.getMaterial("Manyullyn").harvestLevel() ? IguanaLevelingLogic.getRequiredXp(equipped, tags) - headXP : -1;
long requiredToolXP = LevelingLogic.getRequiredXp(equipped, tags) - toolXP;
long requiredHeadXP = tags.hasKey("HeadEXP") && hLevel >= TConstructRegistry.getMaterial("Copper").harvestLevel() && hLevel < TConstructRegistry.getMaterial("Manyullyn").harvestLevel() ? LevelingLogic.getRequiredXp(equipped, tags) - headXP : -1;
if (requiredHeadXP < requiredToolXP && requiredHeadXP > 0)
IguanaLevelingLogic.updateXP(equipped, entityplayermp, toolXP + requiredHeadXP, headXP + requiredHeadXP);
LevelingLogic.updateXP(equipped, entityplayermp, toolXP + requiredHeadXP, headXP + requiredHeadXP);
else
IguanaLevelingLogic.updateXP(equipped, entityplayermp, toolXP + requiredToolXP, headXP + requiredToolXP);
LevelingLogic.updateXP(equipped, entityplayermp, toolXP + requiredToolXP, headXP + requiredToolXP);
if (entityplayermp != icommandsender)
{
@@ -1,6 +1,6 @@
package iguanaman.iguanatweakstconstruct.leveling.commands;
import iguanaman.iguanatweakstconstruct.leveling.IguanaLevelingLogic;
import iguanaman.iguanatweakstconstruct.leveling.LevelingLogic;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
@@ -46,7 +46,7 @@ public class IguanaCommandToolXP extends CommandBase {
Long toolXP = tags.hasKey("ToolEXP") ? tags.getLong("ToolEXP") : -1;
Long headXP = tags.hasKey("HeadEXP") ? tags.getLong("HeadEXP") : -1;
IguanaLevelingLogic.updateXP(equipped, entityplayermp, toolXP + xp, headXP + xp);
LevelingLogic.updateXP(equipped, entityplayermp, toolXP + xp, headXP + xp);
if (entityplayermp != icommandsender)
{
@@ -1,10 +1,11 @@
package iguanaman.iguanatweakstconstruct.leveling;
package iguanaman.iguanatweakstconstruct.leveling.handlers;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import iguanaman.iguanatweakstconstruct.leveling.LevelingLogic;
import iguanaman.iguanatweakstconstruct.leveling.LevelingTooltips;
import iguanaman.iguanatweakstconstruct.reference.IguanaConfig;
import iguanaman.iguanatweakstconstruct.util.IguanaLog;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
@@ -41,7 +42,7 @@ public class LevelingEventHandler {
long xp = Math.round(event.ammount);
if (event.entityLiving instanceof EntityAnimal) xp = Math.round(event.ammount / 4f);
if (xp > 0) IguanaLevelingLogic.addXP(stack, player, xp);
if (xp > 0) LevelingLogic.addXP(stack, player, xp);
}
}
}
@@ -51,7 +52,7 @@ public class LevelingEventHandler {
EntityPlayer player = event.entityPlayer;
ItemStack stack = event.current;
if (stack != null && stack.hasTagCompound() && stack.getItem() instanceof ToolCore)
IguanaLevelingLogic.addXP(stack, player, 1L);
LevelingLogic.addXP(stack, player, 1L);
}
@SubscribeEvent
@@ -67,7 +68,7 @@ public class LevelingEventHandler {
int extra = toolTag.hasKey("Extra") ? toolTag.getInteger("Extra") : -1;
// add tags for tool leveling
IguanaLevelingLogic.addLevelingTags(toolTag);
LevelingLogic.addLevelingTags(toolTag);
// add the initial tooltips for leveling info!
//IguanaLevelingLogic.addLevelingToolTips(event.tool, toolTag);
@@ -189,13 +190,13 @@ public class LevelingEventHandler {
if (IguanaConfig.showTooltipXP)
{
if (level <= 5)
event.left.add(IguanaLevelingTooltips.getXpToolTip(equipped, null));
event.left.add(LevelingTooltips.getXpToolTip(equipped, null));
if (IguanaConfig.levelingPickaxeBoost)
if (hLevel >= TConstructRegistry.getMaterial("Copper").harvestLevel() && hLevel < TConstructRegistry.getMaterial("Manyullyn").harvestLevel()
&& !tags.hasKey("HarvestLevelModified")
&& (equipped.getItem() instanceof Pickaxe || equipped.getItem() instanceof Hammer))
event.left.add(IguanaLevelingTooltips.getBoostXpToolTip(equipped, null));
event.left.add(LevelingTooltips.getBoostXpToolTip(equipped, null));
}
}
}
@@ -1,6 +1,8 @@
package iguanaman.iguanatweakstconstruct.leveling;
package iguanaman.iguanatweakstconstruct.leveling.handlers;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import iguanaman.iguanatweakstconstruct.leveling.LevelingLogic;
import iguanaman.iguanatweakstconstruct.leveling.LevelingTooltips;
import iguanaman.iguanatweakstconstruct.reference.IguanaConfig;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -41,37 +43,37 @@ public class ToolTipHandler {
boolean hasMiningLevel = tool instanceof Pickaxe || tool instanceof Hammer;
// add mining level if applicable
if(hasMiningLevel && tags.hasKey(IguanaLevelingLogic.TAG_BOOST_EXP))
if(hasMiningLevel && tags.hasKey(LevelingLogic.TAG_BOOST_EXP))
{
int hLevel = tags.getInteger("HarvestLevel");
String mLvl = IguanaLevelingTooltips.getMiningLevelTooltip(hLevel);
String mLvl = LevelingTooltips.getMiningLevelTooltip(hLevel);
// is the pick applicable for mining level boosting? if yes display xp
if(IguanaLevelingLogic.canBoostMiningLevel(hLevel)) {
if(LevelingLogic.canBoostMiningLevel(hLevel)) {
// add minimal xp if config option is set
if (!advanced && IguanaConfig.showMinimalTooltipXP && !IguanaLevelingLogic.isBoosted(tags))
mLvl += " (" + IguanaLevelingTooltips.getBoostXpString(stack, tags, false) + ")";
if (!advanced && IguanaConfig.showMinimalTooltipXP && !LevelingLogic.isBoosted(tags))
mLvl += " (" + LevelingTooltips.getBoostXpString(stack, tags, false) + ")";
inserter.add(mLvl);
// advanced mining level boost progress info
if (advanced && IguanaConfig.levelingPickaxeBoost && IguanaConfig.showTooltipXP) {
if (IguanaLevelingLogic.isBoosted(tags))
inserter.add(IguanaLevelingTooltips.getBoostedTooltip());
if (LevelingLogic.isBoosted(tags))
inserter.add(LevelingTooltips.getBoostedTooltip());
else
inserter.add(IguanaLevelingTooltips.getBoostXpToolTip(stack, tags));
inserter.add(LevelingTooltips.getBoostXpToolTip(stack, tags));
}
}
}
// add skill level
int level = IguanaLevelingLogic.getLevel(tags);
String lvl = IguanaLevelingTooltips.getLevelTooltip(level);
if(!advanced && IguanaConfig.showMinimalTooltipXP && !IguanaLevelingLogic.isMaxLevel(tags))
lvl += " (" + IguanaLevelingTooltips.getXpString(stack, tags, false) + ")";
int level = LevelingLogic.getLevel(tags);
String lvl = LevelingTooltips.getLevelTooltip(level);
if(!advanced && IguanaConfig.showMinimalTooltipXP && !LevelingLogic.isMaxLevel(tags))
lvl += " (" + LevelingTooltips.getXpString(stack, tags, false) + ")";
inserter.add(lvl);
// skill level progress
if(advanced && IguanaConfig.showTooltipXP && !IguanaLevelingLogic.isMaxLevel(tags))
inserter.add(IguanaLevelingTooltips.getXpToolTip(stack, tags));
if(advanced && IguanaConfig.showTooltipXP && !LevelingLogic.isMaxLevel(tags))
inserter.add(LevelingTooltips.getXpToolTip(stack, tags));
// since we added at least one line we'll add an empty spacing line at the end
inserter.add("");
@@ -1,8 +1,6 @@
package iguanaman.iguanatweakstconstruct.modifiers;
import iguanaman.iguanatweakstconstruct.leveling.IguanaLevelingTooltips;
import iguanaman.iguanatweakstconstruct.reference.IguanaConfig;
import iguanaman.iguanatweakstconstruct.leveling.IguanaLevelingLogic;
import java.util.ArrayList;
import java.util.Arrays;
@@ -1,8 +1,8 @@
package iguanaman.iguanatweakstconstruct.modifiers;
import iguanaman.iguanatweakstconstruct.leveling.IguanaLevelingTooltips;
import iguanaman.iguanatweakstconstruct.leveling.LevelingLogic;
import iguanaman.iguanatweakstconstruct.leveling.LevelingTooltips;
import iguanaman.iguanatweakstconstruct.reference.IguanaConfig;
import iguanaman.iguanatweakstconstruct.leveling.IguanaLevelingLogic;
import iguanaman.iguanatweakstconstruct.IguanaTweaksTConstruct;
import java.util.ArrayList;
@@ -273,10 +273,10 @@ public class IguanaModUpgrade extends ItemModifier {
if (tags.hasKey("ToolEXP"))
{
int requiredXp = IguanaLevelingLogic.getRequiredXp(tool, tags);
int requiredXp = LevelingLogic.getRequiredXp(tool, tags);
long currentXp = tags.getLong("ToolEXP");
float xpPercentage = (float)currentXp / (float)requiredXp;
int newRequiredXp = IguanaLevelingLogic.getRequiredXp(newTool, newTags);
int newRequiredXp = LevelingLogic.getRequiredXp(newTool, newTags);
long newXp = Math.round(newRequiredXp * xpPercentage);
tags.setLong("ToolEXP", newXp);
}
@@ -397,7 +397,7 @@ public class IguanaModUpgrade extends ItemModifier {
int level = tags.getInteger("ToolLevel");
int hLevel = tags.hasKey("HarvestLevel") ? hLevel = tags.getInteger("HarvestLevel") : -1;
tips.add(IguanaLevelingTooltips.getLevelTooltip(level));
tips.add(LevelingTooltips.getLevelTooltip(level));
modifierTips.add("");
if (IguanaConfig.showTooltipXP)