Added loot and rubber tree configs
This commit is contained in:
parent
d7474fec45
commit
45047be17b
4 changed files with 96 additions and 66 deletions
|
@ -1,21 +0,0 @@
|
|||
package techreborn.world;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
import net.minecraftforge.common.ChestGenHooks;
|
||||
import techreborn.items.ItemIngots;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class DungeonLoot {
|
||||
|
||||
public static void init() {
|
||||
generate(ItemIngots.getIngotByName("steel").getItem(), 5);
|
||||
}
|
||||
|
||||
public static void generate(Item item, int rare) {
|
||||
for (String category : Arrays.asList(ChestGenHooks.VILLAGE_BLACKSMITH, ChestGenHooks.MINESHAFT_CORRIDOR, ChestGenHooks.PYRAMID_DESERT_CHEST, ChestGenHooks.PYRAMID_JUNGLE_CHEST, ChestGenHooks.PYRAMID_JUNGLE_DISPENSER, ChestGenHooks.STRONGHOLD_CORRIDOR, ChestGenHooks.STRONGHOLD_LIBRARY, ChestGenHooks.STRONGHOLD_CROSSING, ChestGenHooks.BONUS_CHEST, ChestGenHooks.DUNGEON_CHEST)) {
|
||||
ChestGenHooks.addItem(category, new WeightedRandomChestContent(item, 0, 1, 3, rare));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import net.minecraft.world.biome.BiomeGenBase;
|
|||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -14,40 +15,44 @@ import java.util.Random;
|
|||
*/
|
||||
public class TreeGenerator implements IWorldGenerator {
|
||||
|
||||
public static RubberTreeGenerator treeGenerator = new RubberTreeGenerator();
|
||||
public static ConfigTechReborn config;
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
||||
int chance = 75;
|
||||
boolean isValidSpawn = false;
|
||||
BiomeGenBase biomeGenBase = world.getBiomeGenForCoords(new BlockPos(chunkX * 16, 72, chunkZ * 16));
|
||||
if (BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.SWAMP)) {
|
||||
chance -= random.nextInt(10) + 10;
|
||||
isValidSpawn = true;
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.FOREST) || BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.JUNGLE)) {
|
||||
chance -= random.nextInt(5) + 3;
|
||||
isValidSpawn = true;
|
||||
}
|
||||
if (!isValidSpawn) {
|
||||
return;
|
||||
}
|
||||
if (world.provider.isSurfaceWorld()) {
|
||||
if (random.nextInt(chance) == 0) {
|
||||
int x = (chunkX * 16) + random.nextInt(15);
|
||||
int z = (chunkZ * 16) + random.nextInt(15);
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int y = world.getActualHeight() - 1;
|
||||
while (world.isAirBlock(new BlockPos(x, y, z)) && y > 0) {
|
||||
y--;
|
||||
}
|
||||
treeGenerator.generate(world, random, new BlockPos(x, 72, z));
|
||||
x += random.nextInt(16) - 8;
|
||||
z += random.nextInt(16) - 8;
|
||||
}
|
||||
public static RubberTreeGenerator treeGenerator = new RubberTreeGenerator();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
||||
if (config.RubberTreeGen) {
|
||||
int chance = 75;
|
||||
boolean isValidSpawn = false;
|
||||
BiomeGenBase biomeGenBase = world.getBiomeGenForCoords(new BlockPos(chunkX * 16, 72, chunkZ * 16));
|
||||
if (BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.SWAMP)) {
|
||||
chance -= random.nextInt(10) + 10;
|
||||
isValidSpawn = true;
|
||||
}
|
||||
if (BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.FOREST) || BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.JUNGLE)) {
|
||||
chance -= random.nextInt(5) + 3;
|
||||
isValidSpawn = true;
|
||||
}
|
||||
if (!isValidSpawn) {
|
||||
return;
|
||||
}
|
||||
if (world.provider.isSurfaceWorld()) {
|
||||
if (random.nextInt(chance) == 0) {
|
||||
int x = (chunkX * 16) + random.nextInt(15);
|
||||
int z = (chunkZ * 16) + random.nextInt(15);
|
||||
for (int i = 0; i < 7; i++) {
|
||||
int y = world.getActualHeight() - 1;
|
||||
while (world.isAirBlock(new BlockPos(x, y, z)) && y > 0) {
|
||||
y--;
|
||||
}
|
||||
treeGenerator.generate(world, random, new BlockPos(x, 72, z));
|
||||
x += random.nextInt(16) - 8;
|
||||
z += random.nextInt(16) - 8;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue