forked from TAIGA/TAIGA
[1.2] Material rework (#60)
* Developement tests for nbt data in traits * Lot of trait changes and better balancing * Traits reworked a bit, new traits added. * First correction of NBT Data in Trait (Soulbound). Is shown twice. Still needs corrections. * Few fixes in traits and new trait "catcher" * Small fix, needs workaround * fixed some catch issues * Fixed Catcher and Reviving Traits, new Trait: Souleater. Updated build.gradle for new TiC Version. * Splitted SoulEater to get the bad touch to an extra trait "Cursed". Added method for using nbt more easily. Changed declaration names of fluids * Some minor changes in Traits, Registry and Utils. * Iron_nugget is replaced with oreDict Item when not loaded via TAIGA. * Beginning of new material integration. Lot of names changed, lot more work to do here. Many null pointer exceptions and no changes of values up to now. * Some Small changes in names, registry and recipes * Some weird stuff I don't remember :D * fixed some things I missed while merging * Rollback to something * More Stuff * fixed some merging stuff * Fixed some misspelled names. Actually working with lots of restrictions. * Rearranged alloys, tried to add blocks / ingots for non-tinker-materials, but they won't work. * Again tried to fix the melting issue, but non-tinker materials still are not able to be casted as a block, ingot or nugget... * Fixed integration of materials without tools. * changed IMC to direct lib calls * removed more IMC, removed redundant code * some reformatting * Alloy integration reworked, needs to be balanced. * updated deps, renamed some func's, added duplicate material check * some more renaming * some reformatting, fixed wrong import, fixed string cmp's * Added images for blocks, ingots, nuggets and dust. Json changes do not work yet. * some reformatting * Removed old json files. Placeholder needed. * Fixed block json, items not working yet. * Fixed my own derp (missing json files) * Reduced materials to ensure unique traits for most of them. Still 30 though, but reduced by 20 more :'( RIP * Changed some generator stuff, not working properly right now! * rewrote offset generation, added some debug command, fixed some stuff * fixed on-surface-generation, made dependencies more flexible * reverted gen-weight back to its normal value * Meteor generator implemented. * fixed generating on ground * optimized a thing * Replaced Uru with Osram, replaced Meteorite with Uru, added Meteorite again for Hull-Material and late game alloy. * Some changes in generation of ores, not ready yet. * Added Cobble Meteorite. Added debug command. Implemented rest of ore generation. Some minor fixes left for generation including balancing. * Some changes for ore generation. Added 2 separate Generic Blocks for meteorite and their cobble variant. * some cleanup in Generator class, added meteor world save handler * Added Textures. Added blockstates and item models. Fixed fluid rendering. * renamed world save data file to be little more specific, removed a unused method * some preps for the upcoming release * First attempt of well balancing material stats. Renamed TiberiumX to Triberium. * Final changes... ready for beta testing * Added missing alloys. * Corrected balancing of ore generation. Still WIP * removed some last debug out * one last reformat
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package com.sosnitzka.taiga.traits;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import slimeknights.tconstruct.library.modifiers.ModifierNBT;
|
||||
import slimeknights.tconstruct.library.tools.ToolNBT;
|
||||
import slimeknights.tconstruct.library.traits.AbstractTrait;
|
||||
import slimeknights.tconstruct.library.utils.TagUtil;
|
||||
|
||||
/**
|
||||
* Base class for tools that progressively gain/award stats.
|
||||
* The modifier persists 2 different stat-data on the tool:
|
||||
* - A 'pool' of stats to award
|
||||
* - A 'bonus' of already awarded stats
|
||||
* <p>
|
||||
* The modifier reapplies the 'bonus' stats on application.
|
||||
* The pool is not touched inheritly but only provided for the logic of the deriving trait.
|
||||
*/
|
||||
public abstract class TraitProgressiveStats extends AbstractTrait {
|
||||
|
||||
protected final String pool_key; // Key to the tag that contains the free unassigned
|
||||
protected final String applied_key; // Key to the tag that contains the already applied bonus stats
|
||||
|
||||
public TraitProgressiveStats(String identifier, TextFormatting color) {
|
||||
super(identifier, color);
|
||||
|
||||
pool_key = identifier + "StatPool";
|
||||
applied_key = identifier + "StatBonus";
|
||||
}
|
||||
|
||||
public TraitProgressiveStats(String identifier, int color) {
|
||||
super(identifier, color);
|
||||
|
||||
pool_key = identifier + "StatPool";
|
||||
applied_key = identifier + "StatBonus";
|
||||
}
|
||||
|
||||
/* Modifier management */
|
||||
|
||||
protected static StatNBT getStats(NBTTagCompound root, String key) {
|
||||
return ModifierNBT.readTag(TagUtil.getTagSafe(TagUtil.getExtraTag(root), key), StatNBT.class);
|
||||
}
|
||||
|
||||
protected static void setStats(NBTTagCompound root, StatNBT data, String key) {
|
||||
NBTTagCompound extra = TagUtil.getExtraTag(root);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
data.write(tag);
|
||||
extra.setTag(key, tag);
|
||||
TagUtil.setExtraTag(root, extra);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyEffect(NBTTagCompound rootCompound, NBTTagCompound modifierTag) {
|
||||
super.applyEffect(rootCompound, modifierTag);
|
||||
// called on tool loading only
|
||||
// we just apply the saved bonus stats
|
||||
ToolNBT data = TagUtil.getToolStats(rootCompound);
|
||||
StatNBT bonus = getBonus(rootCompound);
|
||||
|
||||
data.durability += bonus.durability;
|
||||
data.speed += bonus.speed;
|
||||
data.attack += bonus.attack;
|
||||
|
||||
TagUtil.setToolTag(rootCompound, data.get());
|
||||
}
|
||||
|
||||
protected boolean hasPool(NBTTagCompound root) {
|
||||
return TagUtil.getExtraTag(root).hasKey(pool_key);
|
||||
}
|
||||
|
||||
protected StatNBT getPool(NBTTagCompound root) {
|
||||
return getStats(root, pool_key);
|
||||
}
|
||||
|
||||
protected void setPool(NBTTagCompound root, StatNBT data) {
|
||||
setStats(root, data, pool_key);
|
||||
}
|
||||
|
||||
protected StatNBT getBonus(NBTTagCompound root) {
|
||||
return getStats(root, applied_key);
|
||||
}
|
||||
|
||||
protected void setBonus(NBTTagCompound root, StatNBT data) {
|
||||
setStats(root, data, applied_key);
|
||||
}
|
||||
|
||||
protected boolean playerIsBreakingBlock(Entity entity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class StatNBT extends ModifierNBT {
|
||||
|
||||
// statpool
|
||||
public int durability;
|
||||
public float attack;
|
||||
public float speed;
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
super.read(tag);
|
||||
durability = tag.getInteger("durability");
|
||||
attack = tag.getFloat("attack");
|
||||
speed = tag.getFloat("speed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NBTTagCompound tag) {
|
||||
super.write(tag);
|
||||
tag.setInteger("durability", durability);
|
||||
tag.setFloat("attack", attack);
|
||||
tag.setFloat("speed", speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user