Veins ore generation + fixes.
This commit is contained in:
parent
25e709239f
commit
42d051cda3
7 changed files with 114 additions and 36 deletions
|
@ -1015,8 +1015,8 @@ public class ModRecipes
|
|||
.addShapedOreRecipe(new ItemStack(ModBlocks.LesuStorage), "LLL", "LCL", "LLL", 'L', "blockLapis", 'C',
|
||||
"circuitBasic");
|
||||
|
||||
TechRebornAPI.addRollingOreMachinceRecipe(ItemParts.getPartByName("cupronickelHeatingCoil"), "NCN", "C C", "NCN",
|
||||
'N', "ingotCupronickel", 'C', "ingotCopper");
|
||||
TechRebornAPI.addRollingOreMachinceRecipe(ItemParts.getPartByName("cupronickelHeatingCoil"), "NCN", "CAC", "NCN",
|
||||
'N', "ingotNickel", 'C', "ingotCopper");
|
||||
}
|
||||
|
||||
static void addVacuumFreezerRecipes() {
|
||||
|
|
|
@ -41,14 +41,58 @@ public enum VeinWorldGenerator implements IWorldGenerator {
|
|||
VeinGenerator.registerVein(0, chance, avrSize, minHeight, maxHeight, varargs);
|
||||
}
|
||||
|
||||
private static void registerNetherVein(float chance, float avrSize, Pair<Float, IBlockState>... varargs) {
|
||||
VeinGenerator.registerVein(-1, chance, avrSize, 1, 128, varargs);
|
||||
}
|
||||
private static void registerEndVein(float chance, float avrSize, Pair<Float, IBlockState>... varargs) {
|
||||
VeinGenerator.registerVein(1, chance, avrSize, 1, 64, varargs);
|
||||
}
|
||||
|
||||
|
||||
public static void registerTRVeins() {
|
||||
registerOverworldVein(0.83f, 1.5f, 30, 120, primary("copper"));
|
||||
registerOverworldVein(0.80f, 1.3f, 30, 100, primary("tin"));
|
||||
//Overworld veins
|
||||
registerOverworldVein(0.05f, 0.4f, 1, 60,
|
||||
primary("iridium"));
|
||||
|
||||
registerOverworldVein(0.30f, 1.2f, 1, 60, primary("galena"), additional(0.3f, "lead"), additional(0.2f, "silver"));
|
||||
registerOverworldVein(0.34f, 0.7f, 1, 80,
|
||||
primary("bauxite"));
|
||||
|
||||
registerOverworldVein(0.67f, 1.4f, 30, 120,
|
||||
primary("copper"));
|
||||
|
||||
registerOverworldVein(0.64f, 1.3f, 30, 120,
|
||||
primary("tin"));
|
||||
|
||||
registerOverworldVein(0.32f, 0.7f, 1, 40,
|
||||
primary("galena"),
|
||||
additional(0.3f, "lead"),
|
||||
additional(0.2f, "silver"));
|
||||
|
||||
registerOverworldVein(0.37f, 1.2f, 1, 30,
|
||||
primary(Blocks.REDSTONE_ORE),
|
||||
additional(0.3f, "ruby"));
|
||||
|
||||
registerOverworldVein(0.20f, 0.74f, 1, 40,
|
||||
primary(Blocks.LAPIS_ORE),
|
||||
additional(0.37f, "sapphire"));
|
||||
|
||||
//Nether veins
|
||||
registerNetherVein(0.73f, 0.92f,
|
||||
primary("pyrite"));
|
||||
|
||||
registerNetherVein(0.47f, 0.84f,
|
||||
primary("sphalerite"),
|
||||
additional(0.2f, "cinnabar"));
|
||||
|
||||
//End veins
|
||||
registerEndVein(0.26f, 0.6f,
|
||||
primary("sheldonite"),
|
||||
additional(0.3f, "tungsten"));
|
||||
|
||||
registerEndVein(0.67f, 0.84f,
|
||||
primary("sodalite"),
|
||||
additional(0.4f, "peridot"));
|
||||
|
||||
registerOverworldVein(0.40f, 2.0f, 1, 35, primary(Blocks.REDSTONE_ORE), additional(0.3f, "ruby"));
|
||||
registerOverworldVein(0.30f, 0.7f, 1, 60, primary(Blocks.LAPIS_ORE), additional(0.3f, "sapphire"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import techreborn.utils.OreDictUtils;
|
||||
|
||||
|
@ -16,11 +14,11 @@ import java.util.Random;
|
|||
|
||||
public class VeinGenerator {
|
||||
|
||||
public static final int BASE_VEIN_SIZE_Y = 38;
|
||||
public static final int BASE_VEIN_SIZE_WIDTH = 26;
|
||||
public static final int BASE_VEIN_SIZE_DEPTH = 14;
|
||||
public static final int BASE_VEIN_SIZE_Y = 17;
|
||||
public static final int BASE_VEIN_SIZE_WIDTH = 23;
|
||||
public static final int BASE_VEIN_SIZE_DEPTH = 11;
|
||||
|
||||
public static final int VEIN_DENSITY = 3;
|
||||
public static final int VEIN_DENSITY = 4;
|
||||
|
||||
private static final HashMap<Integer, ArrayList<VeinInfo>> dimensionVeins = new HashMap<>();
|
||||
|
||||
|
@ -37,7 +35,7 @@ public class VeinGenerator {
|
|||
public static void registerVein(int dimension, float chance, float averageSize, int minHeight, int maxHeight, Pair<Float, IBlockState>... varargs) {
|
||||
HashMap<Integer, IBlockState> veinBlocks = new HashMap<>();
|
||||
for(Pair<Float, IBlockState> block : varargs) veinBlocks.put((int) (block.getKey() * 100), block.getValue());
|
||||
registerVein(dimension, chance, averageSize - 0.5f, averageSize + 0.5f, minHeight, maxHeight, veinBlocks);
|
||||
registerVein(dimension, chance, averageSize - 0.2f, averageSize + 0.2f, minHeight, maxHeight, veinBlocks);
|
||||
}
|
||||
|
||||
public static void generateRandomVein(Random random, int chunkX, int chunkZ, World world) {
|
||||
|
@ -83,45 +81,84 @@ public class VeinGenerator {
|
|||
return true;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 16; i++) {
|
||||
for(int j = 0; j < 16; j++) {
|
||||
for(int k = 0; k < world.provider.getAverageGroundLevel(); ++k) {
|
||||
BlockPos pos = new BlockPos(chunkX * 16 + i, k, chunkZ * 16 + j);
|
||||
if(world.getBlockState(pos).getBlock() == Blocks.STONE) {
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IBlockState getOreBlock(VeinInfo veinInfo, Random random) {
|
||||
Map<Integer, IBlockState> veinBlocks = veinInfo.getVeinBlocks();
|
||||
HashMap<Integer, IBlockState> clamped = new HashMap<>();
|
||||
ArrayList<RangedValue<IBlockState>> blocks = new ArrayList<>();
|
||||
int maxValue = 0;
|
||||
for(Map.Entry<Integer, IBlockState> entry : veinBlocks.entrySet()) {
|
||||
maxValue += entry.getKey();
|
||||
clamped.put(maxValue, entry.getValue());
|
||||
blocks.add(new RangedValue<>(maxValue, maxValue += entry.getKey(), entry.getValue()));
|
||||
}
|
||||
int randomValue = random.nextInt(maxValue);
|
||||
for(Map.Entry<Integer, IBlockState> entry : clamped.entrySet()) {
|
||||
if(entry.getKey() > randomValue) return entry.getValue();
|
||||
for(RangedValue<IBlockState> rangedValue : blocks) {
|
||||
if(rangedValue.isInBounds(randomValue))
|
||||
return rangedValue.get();
|
||||
}
|
||||
|
||||
//if you found diamond block in the vein, report it!
|
||||
return Blocks.DIAMOND_BLOCK.getDefaultState();
|
||||
}
|
||||
|
||||
private static VeinInfo getRandomVein(ArrayList<VeinInfo> veins, Random random) {
|
||||
if(veins.isEmpty())
|
||||
return null;
|
||||
if(veins.isEmpty()) return null;
|
||||
|
||||
HashMap<Integer, VeinInfo> clamped = new HashMap<>();
|
||||
ArrayList<RangedValue<VeinInfo>> blocks = new ArrayList<>();
|
||||
int maxValue = 0;
|
||||
for(VeinInfo veinInfo : veins) {
|
||||
maxValue += veinInfo.getChance();
|
||||
clamped.put(maxValue, veinInfo);
|
||||
for(VeinInfo entry : veins) {
|
||||
blocks.add(new RangedValue<>(maxValue, maxValue += entry.getChance(), entry));
|
||||
}
|
||||
int randomValue = random.nextInt(maxValue);
|
||||
for(Map.Entry<Integer, VeinInfo> entry : clamped.entrySet()) {
|
||||
if(entry.getKey() > randomValue)
|
||||
return entry.getValue();
|
||||
for(RangedValue<VeinInfo> rangedValue : blocks) {
|
||||
if(rangedValue.isInBounds(randomValue))
|
||||
return rangedValue.get();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isStone(World world, BlockPos blockPos) {
|
||||
IBlockState block = world.getBlockState(blockPos);
|
||||
switch (world.provider.getDimension()) {
|
||||
case 1:
|
||||
return block.getBlock() == Blocks.END_STONE || OreDictUtils.isOre(block, "endstone");
|
||||
case -1:
|
||||
return block.getBlock() == Blocks.NETHERRACK || OreDictUtils.isOre(block, "netherrack");
|
||||
default:
|
||||
return block.getBlock() == Blocks.STONE || OreDictUtils.isOre(block, "stone");
|
||||
}
|
||||
}
|
||||
|
||||
private static class RangedValue<T> {
|
||||
|
||||
private final int min, max;
|
||||
private final T block;
|
||||
|
||||
public RangedValue(int min, int max, T block) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public boolean isInBounds(int num) {
|
||||
return num >= min && num <= max;
|
||||
}
|
||||
|
||||
public T get() {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package techreborn.world.veins;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import techreborn.blocks.BlockOre;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ tile.techreborn.ore.bauxite.name=Bauxite Ore
|
|||
tile.techreborn.ore.pyrite.name=Pyrite Ore
|
||||
tile.techreborn.ore.cinnabar.name=Cinnabar Ore
|
||||
tile.techreborn.ore.sphalerite.name=Sphalerite Ore
|
||||
tile.techreborn.ore.tungston.name=Tungsten Ore
|
||||
tile.techreborn.ore.tungsten.name=Tungsten Ore
|
||||
tile.techreborn.ore.sheldonite.name=Sheldonite Ore
|
||||
tile.techreborn.ore.peridot.name=Peridot Ore
|
||||
tile.techreborn.ore.sodalite.name=Sodalite Ore
|
||||
|
|
|
@ -97,7 +97,7 @@ tile.techreborn.ore.bauxite.name=Бокситовая руда
|
|||
tile.techreborn.ore.pyrite.name=Пиритовая руда
|
||||
tile.techreborn.ore.cinnabar.name=Киноварь
|
||||
tile.techreborn.ore.sphalerite.name=Сфалеритовая руда
|
||||
tile.techreborn.ore.tungston.name=Вольфрамовая руда
|
||||
tile.techreborn.ore.tungsten.name=Вольфрамовая руда
|
||||
tile.techreborn.ore.sheldonite.name=Шелдонитовая руда
|
||||
tile.techreborn.ore.peridot.name=Перидотовая руда
|
||||
tile.techreborn.ore.sodalite.name=Содалитовая руда
|
||||
|
@ -345,7 +345,7 @@ item.techreborn.dustsmall.redstone.name=Маленькая кучка красн
|
|||
item.techreborn.dustsmall.ruby.name=Маленькая кучка рубиновой пыли
|
||||
item.techreborn.dustsmall.saltpeter.name=Маленькая кучка селитряной пыли
|
||||
item.techreborn.dustsmall.sapphire.name=Маленькая кучка сапфирной пыли
|
||||
item.techreborn.dustsmall.sawпыли.name=Маленькая кучка опилочной пыли
|
||||
item.techreborn.dustsmall.sawdust.name=Маленькая кучка опилочной пыли
|
||||
item.techreborn.dustsmall.silver.name=Маленькая кучка серебряной пыли
|
||||
item.techreborn.dustsmall.sodalite.name=Маленькая кучка содной пыли
|
||||
item.techreborn.dustsmall.spessartine.name=Маленькая кучка спессартиновой пыли
|
||||
|
|
|
@ -98,7 +98,7 @@ tile.techreborn.ore.bauxite.name=铝土矿石
|
|||
tile.techreborn.ore.pyrite.name=黄铁矿石
|
||||
tile.techreborn.ore.cinnabar.name=朱砂矿石
|
||||
tile.techreborn.ore.sphalerite.name=闪锌矿石
|
||||
tile.techreborn.ore.tungston.name=钨矿石
|
||||
tile.techreborn.ore.tungsten.name=钨矿石
|
||||
tile.techreborn.ore.sheldonite.name=铂矿石
|
||||
tile.techreborn.ore.peridot.name=橄榄石矿石
|
||||
tile.techreborn.ore.sodalite.name=方钠石
|
||||
|
|
Loading…
Add table
Reference in a new issue