Changed formatting to have bracing on a new line
This commit is contained in:
parent
e5eddd6c45
commit
e48eedb874
189 changed files with 6092 additions and 4041 deletions
|
@ -7,55 +7,68 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class LivingArmourHandler {
|
||||
public static List<Class<? extends StatTracker>> trackers = new ArrayList();
|
||||
public static HashMap<String, Class<? extends LivingArmourUpgrade>> upgradeMap = new HashMap();
|
||||
public static HashMap<String, Constructor<? extends LivingArmourUpgrade>> upgradeConstructorMap = new HashMap();
|
||||
public class LivingArmourHandler
|
||||
{
|
||||
public static List<Class<? extends StatTracker>> trackers = new ArrayList();
|
||||
public static HashMap<String, Class<? extends LivingArmourUpgrade>> upgradeMap = new HashMap();
|
||||
public static HashMap<String, Constructor<? extends LivingArmourUpgrade>> upgradeConstructorMap = new HashMap();
|
||||
|
||||
public static void registerStatTracker(Class<? extends StatTracker> tracker) {
|
||||
trackers.add(tracker);
|
||||
}
|
||||
public static void registerStatTracker(Class<? extends StatTracker> tracker)
|
||||
{
|
||||
trackers.add(tracker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a LivingArmourUpgrade using its unique identifier and class.
|
||||
* This is done to more easily load upgrades
|
||||
*
|
||||
* @param upgrade
|
||||
*/
|
||||
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) {
|
||||
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
||||
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
||||
try {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
||||
if (ctor == null) {
|
||||
// TODO: This is bad - add something to the log
|
||||
} else {
|
||||
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/**
|
||||
* Registers a LivingArmourUpgrade using its unique identifier and class.
|
||||
* This is done to more easily load upgrades
|
||||
*
|
||||
* @param upgrade
|
||||
*/
|
||||
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade)
|
||||
{
|
||||
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
||||
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
||||
try
|
||||
{
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
||||
if (ctor == null)
|
||||
{
|
||||
// TODO: This is bad - add something to the log
|
||||
} else
|
||||
{
|
||||
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) {
|
||||
return generateUpgradeFromKey(key, level, null);
|
||||
}
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level)
|
||||
{
|
||||
return generateUpgradeFromKey(key, level, null);
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
||||
if (ctor != null) {
|
||||
try {
|
||||
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
||||
if (upgrade != null && tag != null) {
|
||||
upgrade.readFromNBT(tag);
|
||||
}
|
||||
return upgrade;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag)
|
||||
{
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
||||
if (ctor != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
||||
if (upgrade != null && tag != null)
|
||||
{
|
||||
upgrade.readFromNBT(tag);
|
||||
}
|
||||
return upgrade;
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,45 +9,50 @@ import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
|||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
public abstract class LivingArmourUpgrade {
|
||||
public abstract class LivingArmourUpgrade
|
||||
{
|
||||
|
||||
protected int level = 0; // Upgrade level 0 is the first upgrade. Upgrade
|
||||
// goes from 0 to getMaxTier() - 1.
|
||||
protected int level = 0; // Upgrade level 0 is the first upgrade. Upgrade
|
||||
// goes from 0 to getMaxTier() - 1.
|
||||
|
||||
/**
|
||||
* The LivingArmourUpgrade must have a constructor that has a single integer
|
||||
* parameter. Upgrades may have other constructors, but must have one of
|
||||
* these.
|
||||
*
|
||||
* @param level
|
||||
* The level of the upgrade
|
||||
*/
|
||||
public LivingArmourUpgrade(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getUpgradeLevel()
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
/**
|
||||
* The LivingArmourUpgrade must have a constructor that has a single integer
|
||||
* parameter. Upgrades may have other constructors, but must have one of
|
||||
* these.
|
||||
*
|
||||
* @param level
|
||||
* The level of the upgrade
|
||||
*/
|
||||
public LivingArmourUpgrade(int level)
|
||||
{
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public abstract String getUniqueIdentifier();
|
||||
public int getUpgradeLevel()
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int getMaxTier();
|
||||
|
||||
public abstract int getCostOfUpgrade();
|
||||
|
||||
public void onTick(World world, EntityPlayer player, LivingArmour livingArmour){}
|
||||
public abstract String getUniqueIdentifier();
|
||||
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers() {
|
||||
return HashMultimap.<String, AttributeModifier> create();
|
||||
}
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int getMaxTier();
|
||||
|
||||
public abstract int getCostOfUpgrade();
|
||||
|
||||
public void onTick(World world, EntityPlayer player, LivingArmour livingArmour)
|
||||
{
|
||||
}
|
||||
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers()
|
||||
{
|
||||
return HashMultimap.<String, AttributeModifier> create();
|
||||
}
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
}
|
||||
|
|
|
@ -5,47 +5,51 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
|
||||
public abstract class StatTracker {
|
||||
public abstract class StatTracker
|
||||
{
|
||||
|
||||
private boolean isDirty = false;
|
||||
private boolean isDirty = false;
|
||||
|
||||
public abstract String getUniqueIdentifier();
|
||||
public abstract String getUniqueIdentifier();
|
||||
|
||||
/**
|
||||
* When called the StatTracker should reset all of its data, including
|
||||
* upgrades.
|
||||
*/
|
||||
public abstract void resetTracker();
|
||||
/**
|
||||
* When called the StatTracker should reset all of its data, including
|
||||
* upgrades.
|
||||
*/
|
||||
public abstract void resetTracker();
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
/**
|
||||
* Called each tick to update the tracker's information. Called in
|
||||
* LivingArmour
|
||||
*
|
||||
* @param world
|
||||
* World the player is in
|
||||
* @param player
|
||||
* The player that has the armour equipped
|
||||
* @param livingArmour
|
||||
* The equipped LivingArmour
|
||||
* @return True if there is a new upgrade unlocked this tick.
|
||||
*/
|
||||
public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
||||
/**
|
||||
* Called each tick to update the tracker's information. Called in
|
||||
* LivingArmour
|
||||
*
|
||||
* @param world
|
||||
* World the player is in
|
||||
* @param player
|
||||
* The player that has the armour equipped
|
||||
* @param livingArmour
|
||||
* The equipped LivingArmour
|
||||
* @return True if there is a new upgrade unlocked this tick.
|
||||
*/
|
||||
public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
||||
|
||||
public abstract LivingArmourUpgrade[] getUpgrades();
|
||||
public abstract LivingArmourUpgrade[] getUpgrades();
|
||||
|
||||
public final boolean isDirty() {
|
||||
return isDirty;
|
||||
}
|
||||
public final boolean isDirty()
|
||||
{
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
public final void markDirty() {
|
||||
this.isDirty = true;
|
||||
}
|
||||
public final void markDirty()
|
||||
{
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
public final void resetDirty() {
|
||||
this.isDirty = false;
|
||||
}
|
||||
public final void resetDirty()
|
||||
{
|
||||
this.isDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue