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:
@@ -1,20 +1,33 @@
|
||||
package com.sosnitzka.taiga.util;
|
||||
|
||||
|
||||
import com.sosnitzka.taiga.Items;
|
||||
import com.sosnitzka.taiga.TAIGA;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import slimeknights.tconstruct.library.MaterialIntegration;
|
||||
import slimeknights.tconstruct.library.TinkerRegistry;
|
||||
import slimeknights.tconstruct.library.materials.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.sosnitzka.taiga.TAIGA.proxy;
|
||||
|
||||
public class Utils {
|
||||
public static String PREFIX_INGOT = "ingot";
|
||||
public static String PREFIX_NUGGET = "nugget";
|
||||
public static String PREFIX_ORE = "ore";
|
||||
public static String PREFIX_BLOCK = "block";
|
||||
public static String PREFIX_DUST = "dust";
|
||||
|
||||
/**
|
||||
* Registers the block and its corresponding item (block as item in inventory)
|
||||
@@ -28,6 +41,7 @@ public class Utils {
|
||||
|
||||
/**
|
||||
* Registers the fluid and its bucket item
|
||||
*
|
||||
* @param fluid the fluid
|
||||
*/
|
||||
public static void registerFluid(Fluid fluid) {
|
||||
@@ -35,51 +49,101 @@ public class Utils {
|
||||
FluidRegistry.addBucketForFluid(fluid);
|
||||
}
|
||||
|
||||
public static void registerTinkerAlloys(Fluid alloy, int out, Fluid first, int inOne, Fluid second, int inTwo) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
NBTTagCompound fluid = new NBTTagCompound();
|
||||
fluid.setString("FluidName", alloy.getName());
|
||||
fluid.setInteger("Amount", out);
|
||||
tagList.appendTag(fluid);
|
||||
fluid = new NBTTagCompound();
|
||||
fluid.setString("FluidName", first.getName());
|
||||
fluid.setInteger("Amount", inOne);
|
||||
tagList.appendTag(fluid);
|
||||
fluid = new NBTTagCompound();
|
||||
fluid.setString("FluidName", second.getName());
|
||||
fluid.setInteger("Amount", inTwo);
|
||||
tagList.appendTag(fluid);
|
||||
|
||||
NBTTagCompound message = new NBTTagCompound();
|
||||
message.setTag("alloy", tagList);
|
||||
FMLInterModComms.sendMessage("tconstruct", "alloy", message);
|
||||
}
|
||||
|
||||
public static void registerTinkerAlloys(Fluid alloy, int out, Fluid first, int inOne, Fluid second, int inTwo, Fluid third, int inThree) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
NBTTagCompound fluid = new NBTTagCompound();
|
||||
fluid.setString("FluidName", alloy.getName());
|
||||
fluid.setInteger("Amount", out);
|
||||
tagList.appendTag(fluid);
|
||||
fluid = new NBTTagCompound();
|
||||
fluid.setString("FluidName", first.getName());
|
||||
fluid.setInteger("Amount", inOne);
|
||||
tagList.appendTag(fluid);
|
||||
fluid = new NBTTagCompound();
|
||||
fluid.setString("FluidName", second.getName());
|
||||
fluid.setInteger("Amount", inTwo);
|
||||
tagList.appendTag(fluid);
|
||||
fluid = new NBTTagCompound();
|
||||
fluid.setString("FluidName", third.getName());
|
||||
fluid.setInteger("Amount", inThree);
|
||||
tagList.appendTag(fluid);
|
||||
|
||||
NBTTagCompound message = new NBTTagCompound();
|
||||
message.setTag("alloy", tagList);
|
||||
FMLInterModComms.sendMessage("tconstruct", "alloy", message);
|
||||
public static void registerTinkerAlloy(FluidStack output, FluidStack... inputs) {
|
||||
if (inputs.length >= 2 && output != null) {
|
||||
TinkerRegistry.registerAlloy(output, inputs);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isNight(int time) {
|
||||
return time > 12500;
|
||||
}
|
||||
|
||||
public static double round2(double d) {
|
||||
return (Math.round(d * 100.0) / 100.0);
|
||||
}
|
||||
|
||||
public static void integrateMaterial(String oreSuffix, @Nullable Material material, Fluid fluid, int headDura, float headSpeed, float headAttack, float handleMod, int handleDura, int extra, int headLevel, float draw, float range, int bdamage) {
|
||||
integrateMaterial(oreSuffix, material, fluid, headDura, headSpeed, headAttack, handleMod, handleDura, extra, headLevel, new BowMaterialStats(draw, range, bdamage), false, true);
|
||||
}
|
||||
|
||||
public static void integrateMaterial(String oreSuffix, @Nullable Material material, Fluid fluid, int headDura, float headSpeed, float headAttack, float handleMod, int handleDura, int extra, int headLevel, BowMaterialStats bowstats) {
|
||||
integrateMaterial(oreSuffix, material, fluid, headDura, headSpeed, headAttack, handleMod, handleDura, extra, headLevel, bowstats, false, true);
|
||||
}
|
||||
|
||||
public static void integrateMaterial(String oreSuffix, @Nullable Material material, Fluid fluid, int headDura, float headSpeed, float headAttack, float handleMod, int handleDura, int extra, int headLevel, BowMaterialStats bowstats, boolean craft, boolean cast) {
|
||||
if (material != null) {
|
||||
if (TinkerRegistry.getMaterial(material.identifier) != Material.UNKNOWN)
|
||||
return;
|
||||
|
||||
TinkerRegistry.addMaterialStats(material, new HeadMaterialStats(headDura, headSpeed, headAttack, headLevel));
|
||||
TinkerRegistry.addMaterialStats(material, new HandleMaterialStats(handleMod, handleDura));
|
||||
TinkerRegistry.addMaterialStats(material, new ExtraMaterialStats(extra));
|
||||
TinkerRegistry.addMaterialStats(material, bowstats);
|
||||
|
||||
Item item = null;
|
||||
Field[] items = Items.class.getDeclaredFields();
|
||||
for (Field i : items) {
|
||||
if (i.getName().equals(StringUtils.uncapitalize(oreSuffix) + "Ingot")) {
|
||||
Item r = null;
|
||||
try {
|
||||
r = (Item) i.get(i.getType());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
item = r;
|
||||
}
|
||||
}
|
||||
|
||||
material.setFluid(fluid).setCraftable(craft).setCastable(cast).addItem(item, 1, Material.VALUE_Ingot);
|
||||
material.setRepresentativeItem(item);
|
||||
proxy.setRenderInfo(material);
|
||||
}
|
||||
|
||||
MaterialIntegration integration = new MaterialIntegration(material, fluid, oreSuffix);
|
||||
integration.integrate();
|
||||
TAIGA.integrateList.add(integration);
|
||||
}
|
||||
|
||||
public static void integrateOre(String oreSuffix, Fluid fluid) {
|
||||
integrateMaterial(oreSuffix, null, fluid, -1, -1, -1, -1, -1, -1, -1, new BowMaterialStats(0.1f, 0.1f, -1f), true, true);
|
||||
}
|
||||
|
||||
public static int nextInt(Random random, int min, int max) {
|
||||
return random.nextInt((max - min) + 1) + min;
|
||||
}
|
||||
|
||||
public static class GeneralNBTData {
|
||||
|
||||
public int killcount;
|
||||
public float health;
|
||||
public int brokenblocks;
|
||||
public float bonus;
|
||||
public int curse;
|
||||
public String name;
|
||||
public float radius;
|
||||
|
||||
public static GeneralNBTData read(NBTTagCompound tag) {
|
||||
GeneralNBTData data = new GeneralNBTData();
|
||||
data.killcount = tag.getInteger("killcount");
|
||||
data.brokenblocks = tag.getInteger("brokenblocks");
|
||||
data.health = tag.getFloat("health");
|
||||
data.bonus = tag.getFloat("bonus");
|
||||
data.curse = tag.getInteger("curse");
|
||||
data.name = tag.getString("name");
|
||||
data.radius = tag.getFloat("radius");
|
||||
return data;
|
||||
}
|
||||
|
||||
public void write(NBTTagCompound tag) {
|
||||
tag.setInteger("killcount", killcount);
|
||||
tag.setInteger("brokenblocks", brokenblocks);
|
||||
tag.setFloat("health", health);
|
||||
tag.setFloat("bonus", bonus);
|
||||
tag.setInteger("curse", curse);
|
||||
tag.setString("name", name);
|
||||
tag.setFloat("radius", radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user