[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:
Giovanni Harting
2016-12-05 20:34:02 +01:00
committed by GitHub
parent 9554b56931
commit 826ab1cf3a
625 changed files with 3540 additions and 3279 deletions

View File

@@ -1,24 +0,0 @@
package com.sosnitzka.taiga.util;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.IFuelHandler;
import static com.sosnitzka.taiga.Items.*;
import static slimeknights.tconstruct.TConstruct.random;
public class FuelHandler implements IFuelHandler {
@Override
public int getBurnTime(ItemStack fuel) {
if (fuel.getItem().equals(lignite)) {
return 200 * 6;
}
if (fuel.getItem().equals(fuel_brick)) {
return 200 * 50;
}
if (fuel.getItem().equals(glimmercoal)) {
return (random.nextInt(20) + 40) * 200;
}
return 0;
}
}

View File

@@ -1,41 +1,214 @@
package com.sosnitzka.taiga.util;
import com.sosnitzka.taiga.world.ZWorldGenMinable;
import com.google.common.collect.Lists;
import com.sosnitzka.taiga.world.MeteorWorldSaveData;
import com.sosnitzka.taiga.world.WorldGenMinable;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.oredict.OreDictionary;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import static com.sosnitzka.taiga.util.Utils.nextInt;
public class Generator {
public static void generateOre(IBlockState state, Random random, int x, int z, World world, int chance, int minY, int maxY, int minSize, int maxSize) {
generateOre(state, Blocks.STONE.getDefaultState(), null, null, random, x, z, world, chance, minY, maxY, minSize, maxSize);
public static void generateOre(boolean center, IBlockState state, IBlockState replace, Random random, int x, int z, World world, int chance, int minY, int maxY, int minSize, int maxSize) {
if (center) {
generateOreDense(state, replace, random, x, z, world, chance, minY, maxY, minSize, maxSize, null);
} else {
generateOre(state, replace, null, null, random, x, z, world, chance, minY, maxY, minSize, maxSize, null);
}
}
public static void generateNetherOre(IBlockState state, Random random, int x, int z, World world, int chance, int minY, int maxY, int minSize, int maxSize) {
generateOre(state, Blocks.NETHERRACK.getDefaultState(), null, null, random, x, z, world, chance, minY, maxY, minSize, maxSize);
}
public static void generateEndOre(IBlockState state, Random random, int x, int z, World world, int chance, int minY, int maxY, int minSize, int maxSize) {
generateOre(state, Blocks.END_STONE.getDefaultState(), null, null, random, x, z, world, chance, minY, maxY, minSize, maxSize);
}
public static void generateOre(IBlockState state, IBlockState replace, Random random, int chunkX, int chunkZ, World world, int chance, int minY, int maxY, int minSize, int maxSize) {
generateOre(state, replace, null, null, random, chunkX, chunkZ, world, chance, minY, maxY, minSize, maxSize);
}
public static void generateOre(IBlockState state, IBlockState replace, IProperty property, Comparable comparable, Random random, int chunkX, int chunkZ, World world, int chance, int minY, int maxY, int minSize, int maxSize) {
public static void generateOre(IBlockState state, IBlockState replace, IProperty property, Comparable comparable, Random random, int chunkX, int chunkZ, World world, int chance, int minY, int maxY, int minSize, int maxSize, List<Biome> biome) {
int size = minSize + random.nextInt(maxSize - minSize);
int height = maxY - minY;
for (int i = 0; i < chance; i++) {
int posX = chunkX + random.nextInt(16);
int posY = random.nextInt(height) + minY;
int posZ = chunkZ + random.nextInt(16);
new ZWorldGenMinable(state, size, StateMatcher.forState(replace, property, comparable)).generate(world, random, new BlockPos(posX, posY, posZ));
BlockPos cPos = new BlockPos(posX, posY, posZ);
if (biome == null || biome.contains(world.getBiome(cPos))) {
new WorldGenMinable(state, size, StateMatcher.forState(replace, property, comparable)).generate(world, random, new BlockPos(posX, posY, posZ));
}
}
}
public static void generateOreDescending(List<IBlockState> replaceBlockList, IBlockState replacementBlock, Random random, int chunkX, int chunkZ, World world, int count, int minY, int maxY, int chance) {
if (random.nextFloat() < (float) (0.01 * chance))
generateOreDescending(replaceBlockList, replacementBlock, random, chunkX, chunkZ, world, count, minY, maxY);
}
public static void generateOreDescending(List<IBlockState> replaceBlockList, IBlockState replacementBlock, Random random, int chunkX, int chunkZ, World world, int count, int minY, int maxY) {
for (int i = 0; i < count; i++) {
int posX = chunkX + random.nextInt(16);
int posZ = chunkZ + random.nextInt(16);
BlockPos cPos = new BlockPos(posX, maxY, posZ);
if (replaceBlockList.contains(world.getBlockState(cPos)) && replaceBlockList.contains(world.getBlockState(cPos.up()))) {
continue;
}
if (replaceBlockList.contains(world.getBlockState(cPos)) && !replaceBlockList.contains(world.getBlockState(cPos.up())))
world.setBlockState(cPos, replacementBlock);
while (!replaceBlockList.contains(world.getBlockState(cPos.down())) && cPos.getY() > minY) {
cPos = cPos.down();
}
if (replaceBlockList.contains(world.getBlockState(cPos.down())))
world.setBlockState(cPos.down(), replacementBlock);
}
}
public static void generateOreBottom(IBlockState replacedBlock, IBlockState replacementBlock, Random random, int chunkX, int chunkZ, World world, int chance, int spread, int maxY) {
for (int i = 0; i < chance; i++) {
int posX = chunkX + random.nextInt(16);
int posY = 0;
int posZ = chunkZ + random.nextInt(16);
BlockPos cPos = new BlockPos(posX, posY, posZ);
if (Blocks.AIR.getDefaultState().equals(world.getBlockState(cPos))) {
while (world.getBlockState(cPos).equals(Blocks.AIR.getDefaultState()) && cPos.getY() < maxY) {
cPos = cPos.up();
}
if (world.getBlockState(cPos).equals(replacedBlock)) {
world.setBlockState(cPos.up(random.nextInt(spread)), replacementBlock);
}
}
}
}
public static void generateCube(boolean fly, IBlockState centerBlock, IBlockState hullBlock, Random random, int chunkX, int chunkZ, World world, int count, int chance, int minY, int maxY, int maxS) {
for (int i = 0; i < count; i++) {
if (random.nextFloat() < 0.01 * chance) {
int outer = nextInt(random, 1, maxS);
int inner = random.nextInt(2);
int posX = chunkX + random.nextInt(16);
int posY = nextInt(random, minY, maxY);
int posZ = chunkZ + random.nextInt(16);
BlockPos cPos = new BlockPos(posX, posY, posZ);
if (!fly) {
if (world.getBlockState(cPos).equals(Blocks.AIR.getDefaultState()) && world.getBlockState(cPos.down()).equals(Blocks.AIR.getDefaultState())) {
// we are in mid air, go down
while (world.getBlockState(cPos.down()).equals(Blocks.AIR.getDefaultState())) {
cPos = cPos.down();
}
}
}
cPos.down((random.nextInt(4) + 2) * outer);
for (int x = -inner; x <= inner; x++) {
for (int y = -inner; y <= inner; y++) {
for (int z = -inner; z <= inner; z++) {
if (!world.getBlockState(cPos).equals(Blocks.AIR.getDefaultState()))
continue;
world.setBlockState(new BlockPos(cPos.getX() + x, cPos.getY() + y, cPos.getZ() + z), centerBlock);
}
}
}
for (int x = -outer; x <= outer; x++) {
for (int y = -outer; y <= outer; y++) {
for (int z = -outer; z <= outer; z++) {
BlockPos nPos = new BlockPos(cPos.getX() + x, cPos.getY() + y, cPos.getZ() + z);
if (world.getBlockState(nPos).equals(centerBlock) || !world.getBlockState(nPos).equals(Blocks.AIR.getDefaultState()))
continue;
world.setBlockState(nPos, hullBlock);
}
}
}
}
}
}
public static void generateMeteor(IBlockState centerBlock, IBlockState hullBlock, Random random, int chunkX, int chunkZ, World world, int count, int chance, int minY, int maxY) {
Set<Item> validSurface = new HashSet<Item>();
List<String> oredictentries = Lists.newArrayList("dirt", "grass", "stone", "sand", "gravel", "cobblestone", "sandstone");
for (String e : oredictentries) {
for (ItemStack stack : OreDictionary.getOres(e)) {
validSurface.add(stack.getItem());
}
}
for (int i = 0; i < count; i++) {
if (random.nextFloat() < 0.01 * chance) {
int r = nextInt(random, 1, 5);
int posX = chunkX + random.nextInt(16);
int posY = nextInt(random, minY, maxY);
int posZ = chunkZ + random.nextInt(16);
BlockPos cPos = new BlockPos(posX, posY, posZ);
if (world.getBlockState(cPos).equals(Blocks.AIR.getDefaultState()) && world.getBlockState(cPos.down()).equals(Blocks.AIR.getDefaultState())) {
// we are in mid air, go down
while (world.getBlockState(cPos.down()).equals(Blocks.AIR.getDefaultState())) {
cPos = cPos.down();
}
}
if (!validSurface.contains(Item.getItemFromBlock(world.getBlockState(cPos.down()).getBlock())))
continue;
cPos.down((random.nextInt(3) + 1) * r);
MeteorWorldSaveData saveData = MeteorWorldSaveData.getForWorld(world);
saveData.addPos(cPos);
saveData.markDirty();
int t = 1;
if (r > 3) t = random.nextInt(r - 1);
for (int x = -t; x <= t; x++) {
for (int y = -t; y <= t; y++) {
for (int z = -t; z <= t; z++) {
if (MathHelper.sqrt_double(x * x + y * y + z * z) > t) {
continue;
}
world.setBlockState(new BlockPos(cPos.getX() + x, cPos.getY() + y, cPos.getZ() + z), centerBlock);
}
}
}
for (int x = -r; x <= r; x++) {
for (int y = -r; y <= r; y++) {
for (int z = -r; z <= r; z++) {
if (MathHelper.sqrt_double(x * x + y * y + z * z) > r) {
continue;
}
BlockPos nPos = new BlockPos(cPos.getX() + x, cPos.getY() + y, cPos.getZ() + z);
if (world.getBlockState(nPos).equals(centerBlock))
continue;
world.setBlockState(nPos, hullBlock);
}
}
}
}
}
}
public static void generateOreDense(IBlockState state, IBlockState replace, Random random, int chunkX, int chunkZ, World world, int chance, int minY, int maxY, int minSize, int maxSize, List<Biome> biome) {
int size = minSize + random.nextInt(maxSize - minSize);
int height = maxY - minY;
BlockPos cPos;
for (int i = 0; i < chance; i += 5) {
for (int j = 0; j <= 2; j++) {
cPos = new BlockPos(chunkX + random.nextInt(16), minY + height * j / 5 + random.nextInt(height * 3 / 5), chunkZ + random.nextInt(16));
if (biome == null || biome.contains(world.getBiome(cPos))) {
new WorldGenMinable(state, size, StateMatcher.forState(replace, null, null)).generate(world, random, cPos);
}
}
for (int j = 0; j <= 1; j++) {
int x = chunkX + random.nextInt(16);
int y = chunkZ + random.nextInt(16);
cPos = new BlockPos(x, minY + height * 4 / 9 + random.nextInt(height / 9), y);
if (biome == null || biome.contains(world.getBiome(cPos))) {
new WorldGenMinable(state, size, StateMatcher.forState(replace, null, null)).generate(world, random, cPos);
}
}
}
}
}

View File

@@ -64,8 +64,6 @@ public class StateMatcher implements Predicate<IBlockState> {
IBlockState bState = world.getBlockState(blockPos);
if (bState.getBlock() == this.state.getBlock() && bState.getValue(property) == value) {
// Check if a replacable block is near origin block - show pos in console
// System.out.println(String.format("Found block with desired state! (%s), Block: %s, try #%s, y=%s", i, Y));
return true;
}
}

View File

@@ -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);
}
}
}