Some more cleanup
This commit is contained in:
@@ -6,9 +6,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instances of this interface act as keys which allow spellData of any type to be stored in {@link WizardData} at
|
* Instances of this interface act as keys which allow data of any type to be stored in {@link WizardData} at
|
||||||
* runtime. This means spells (or anything else, for that matter) may define their own storedVariables to be stored
|
* runtime. This means spells (or anything else, for that matter) may define their own variables to be stored
|
||||||
* with the player and handle those storedVariables themselves. This prevents {@code WizardData} from being cluttered
|
* with the player and handle those variables themselves. This prevents {@code WizardData} from being cluttered
|
||||||
* with spell-specific fields and allows addon mods to leverage {@code WizardData} for their own spells or other data,
|
* with spell-specific fields and allows addon mods to leverage {@code WizardData} for their own spells or other data,
|
||||||
* rather than defining their own capability. This system is somewhat similar to {@code DataManager}.
|
* rather than defining their own capability. This system is somewhat similar to {@code DataManager}.
|
||||||
* <p></p>
|
* <p></p>
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
|
|||||||
|
|
||||||
/** Registers the given {@link IStoredVariable} objects as keys that will be stored to NBT for each {@code WizardData}
|
/** Registers the given {@link IStoredVariable} objects as keys that will be stored to NBT for each {@code WizardData}
|
||||||
* instance. */
|
* instance. */
|
||||||
public static void registerStoredVariables(IStoredVariable... variables){
|
public static void registerStoredVariables(IStoredVariable<?>... variables){
|
||||||
storedVariables.addAll(Arrays.asList(variables));
|
storedVariables.addAll(Arrays.asList(variables));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
|
|||||||
* other words, if an {@code Integer} is stored under a {@code IVariable<Number>}, a {@code Number} will
|
* other words, if an {@code Integer} is stored under a {@code IVariable<Number>}, a {@code Number} will
|
||||||
* be returned when the value is retrieved.
|
* be returned when the value is retrieved.
|
||||||
*/
|
*/
|
||||||
// This use of type parameters guarantees that spellData may only be stored (and therefore may only be accessed)
|
// This use of type parameters guarantees that data may only be stored (and therefore may only be accessed)
|
||||||
// using a compatible key. For instance, the following code will not compile:
|
// using a compatible key. For instance, the following code will not compile:
|
||||||
// Number i = 1;
|
// Number i = 1;
|
||||||
// setVariable(StoredVariable.ofInt("key", Persistence.ALWAYS), i);
|
// setVariable(StoredVariable.ofInt("key", Persistence.ALWAYS), i);
|
||||||
@@ -484,7 +484,7 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
|
|||||||
|
|
||||||
prevMotionY = player.motionY;
|
prevMotionY = player.motionY;
|
||||||
|
|
||||||
// This new system removes a lot of repetitive event handler code and inflexible spellData which had duplicate
|
// This new system removes a lot of repetitive event handler code and inflexible data which had duplicate
|
||||||
// functions, just for different enchantments.
|
// functions, just for different enchantments.
|
||||||
updateImbuedItems();
|
updateImbuedItems();
|
||||||
updateContinuousSpellCasting();
|
updateContinuousSpellCasting();
|
||||||
@@ -495,10 +495,10 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from the event handler each time the associated player entity is cloned, i.e. on respawn or when
|
* Called from the event handler each time the associated player entity is cloned, i.e. on respawn or when
|
||||||
* travelling to a different dimension. Used to copy over any spellData that should persist over player death. This
|
* travelling to a different dimension. Used to copy over any data that should persist over player death. This
|
||||||
* is the inverse of the old onPlayerDeath method, which reset the spellData that shouldn't persist.
|
* is the inverse of the old onPlayerDeath method, which reset the data that shouldn't persist.
|
||||||
*
|
*
|
||||||
* @param data The old WizardData whose spellData are to be copied over.
|
* @param data The old WizardData whose data is to be copied over.
|
||||||
* @param respawn True if the player died and is respawning, false if they are just travelling between dimensions.
|
* @param respawn True if the player died and is respawning, false if they are just travelling between dimensions.
|
||||||
*/
|
*/
|
||||||
public void copyFrom(WizardData data, boolean respawn){
|
public void copyFrom(WizardData data, boolean respawn){
|
||||||
|
|||||||
Reference in New Issue
Block a user