diff options
Diffstat (limited to 'src/main/java/com/sosnitzka/taiga/util')
| -rw-r--r-- | src/main/java/com/sosnitzka/taiga/util/Generator.java | 62 | ||||
| -rw-r--r-- | src/main/java/com/sosnitzka/taiga/util/Utils.java | 28 |
2 files changed, 52 insertions, 38 deletions
diff --git a/src/main/java/com/sosnitzka/taiga/util/Generator.java b/src/main/java/com/sosnitzka/taiga/util/Generator.java index fb3d916..7cd351a 100644 --- a/src/main/java/com/sosnitzka/taiga/util/Generator.java +++ b/src/main/java/com/sosnitzka/taiga/util/Generator.java @@ -25,15 +25,22 @@ import static com.sosnitzka.taiga.util.Utils.nextInt; public class Generator { - public static void generateOre(IBlockState newState, IBlockState oldState, Random random, int chunkX, int chunkZ, World world, int count, int minY, int maxY, int minSize, int maxSize) { - generateOre(newState, oldState, null, null, random, chunkX, chunkZ, world, count, 100, minY, maxY, minSize, maxSize, null); + public static void generateOre(IBlockState newState, IBlockState oldState, Random random, int chunkX, int chunkZ, + World world, int count, int minY, int maxY, int minSize, int maxSize) { + generateOre(newState, oldState, null, null, random, chunkX, chunkZ, world, count, 100, minY, maxY, minSize, + maxSize, null); } - public static void generateOre(IBlockState newState, IBlockState oldState, Random random, int chunkX, int chunkZ, World world, int count, int chance, int minY, int maxY, int minSize, int maxSize, List<Biome> biome) { - generateOre(newState, oldState, null, null, random, chunkX, chunkZ, world, count, chance, minY, maxY, minSize, maxSize, biome); + public static void generateOre(IBlockState newState, IBlockState oldState, Random random, int chunkX, int chunkZ, + World world, int count, int chance, int minY, int maxY, int minSize, int maxSize, + List<Biome> biome) { + generateOre(newState, oldState, null, null, random, chunkX, chunkZ, world, count, chance, minY, maxY, + minSize, maxSize, biome); } - public static void generateOre(IBlockState newState, IBlockState oldState, IProperty property, Comparable comparable, Random random, int chunkX, int chunkZ, World world, int count, int chance, int minY, int maxY, int minSize, int maxSize, List<Biome> biome) { + public static void generateOre(IBlockState newState, IBlockState oldState, IProperty property, Comparable + comparable, Random random, int chunkX, int chunkZ, World world, int count, 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 < count; i++) { @@ -43,28 +50,33 @@ public class Generator { int posZ = chunkZ + random.nextInt(16); BlockPos cPos = new BlockPos(posX, posY, posZ); if (biome == null || biome.contains(world.getBiome(cPos))) { - new WorldGenMinable(newState, size, StateMatcher.forState(oldState, property, comparable)).generate(world, random, new BlockPos(posX, posY, posZ)); + new WorldGenMinable(newState, size, StateMatcher.forState(oldState, property, comparable)) + .generate(world, random, new BlockPos(posX, posY, posZ)); } } } } - public static void generateOre(List<IBlockState> replaceBlockList, IBlockState replacementBlock, Random random, int chunkX, int chunkZ, World world, int count, int minY, int maxY, int chance) { + public static void generateOre(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) { + 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()))) { + 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()))) + 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(); @@ -74,7 +86,8 @@ public class Generator { } } - public static void generateOreStoneVariant(IBlockState newState, BlockStone.EnumType type, Random random, int chunkX, int chunkZ, World world, int count) { + public static void generateOreStoneVariant(IBlockState newState, BlockStone.EnumType type, Random random, int + chunkX, int chunkZ, World world, int count) { List<BlockStone.EnumType> list = newArrayList(type); for (int i = 0; i < count; i += 2) { int posX = chunkX + random.nextInt(16); @@ -118,7 +131,8 @@ public class Generator { } } - public static void generateOreBottom(IBlockState oldState, IBlockState newState, Random random, int chunkX, int chunkZ, World world, int chance, int spread, int maxY) { + public static void generateOreBottom(IBlockState oldState, IBlockState newState, 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; @@ -135,7 +149,8 @@ public class Generator { } } - 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) { + 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); @@ -145,7 +160,8 @@ public class Generator { 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())) { + 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(); @@ -158,7 +174,8 @@ public class Generator { 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); + world.setBlockState(new BlockPos(cPos.getX() + x, cPos.getY() + y, cPos.getZ() + z), + centerBlock); } } } @@ -166,7 +183,8 @@ public class Generator { 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())) + if (world.getBlockState(nPos).equals(centerBlock) || !world.getBlockState(nPos).equals + (Blocks.AIR.getDefaultState())) continue; world.setBlockState(nPos, hullBlock); } @@ -178,9 +196,11 @@ public class Generator { } - public static int generateMeteor(IBlockState centerBlock, IBlockState hullBlock, Random random, int chunkX, int chunkZ, World world, int count, int chance, int minY, int maxY) { + public static int 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"); + 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()); @@ -196,7 +216,8 @@ public class Generator { 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())) { + 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(); @@ -223,7 +244,8 @@ public class Generator { if (MathHelper.sqrt(x * x + y * y + z * z) > t) { continue; } - world.setBlockState(new BlockPos(cPos.getX() + x, cPos.getY() + y, cPos.getZ() + z), centerBlock); + world.setBlockState(new BlockPos(cPos.getX() + x, cPos.getY() + y, cPos.getZ() + z), + centerBlock); } } } diff --git a/src/main/java/com/sosnitzka/taiga/util/Utils.java b/src/main/java/com/sosnitzka/taiga/util/Utils.java index b4e8bf5..88ee206 100644 --- a/src/main/java/com/sosnitzka/taiga/util/Utils.java +++ b/src/main/java/com/sosnitzka/taiga/util/Utils.java @@ -3,14 +3,11 @@ package com.sosnitzka.taiga.util; import com.sosnitzka.taiga.Items; import com.sosnitzka.taiga.TAIGA; -import net.minecraft.block.Block; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; 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; @@ -31,16 +28,6 @@ public class Utils { public static String PREFIX_CRYSTAL = "crystal"; /** - * Registers the block and its corresponding item (block as item in inventory) - * - * @param block the associated block - */ - public static void registerBlockWithItem(Block block) { - GameRegistry.register(block); - GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName())); - } - - /** * Registers the fluid and its bucket item * * @param fluid the fluid @@ -65,8 +52,11 @@ public class Utils { 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, 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) { @@ -78,7 +68,8 @@ public class Utils { if (TinkerRegistry.getMaterial(material.identifier) != Material.UNKNOWN) return; - TinkerRegistry.addMaterialStats(material, new HeadMaterialStats(headDura, headSpeed, headAttack, headLevel)); + 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); @@ -103,12 +94,13 @@ public class Utils { } MaterialIntegration integration = new MaterialIntegration(material, fluid, oreSuffix); - integration.integrate(); + integration.preInit(); 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); + 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) { |
