|
|
|
@ -2,10 +2,14 @@ package de.jottyfan.minecraft.quickiefabric.init;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
|
|
|
|
import de.jottyfan.minecraft.quickiefabric.blockentity.ItemHoarderBlockEntity;
|
|
|
|
|
import de.jottyfan.minecraft.quickiefabric.blockentity.MonsterHoarderBlockEntity;
|
|
|
|
|
import de.jottyfan.minecraft.quickiefabric.blockentity.QuickieFabricBlockEntity;
|
|
|
|
@ -26,16 +30,19 @@ import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraft.item.ItemGroup;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.screen.ScreenHandlerType;
|
|
|
|
|
import net.minecraft.structure.rule.RuleTest;
|
|
|
|
|
import net.minecraft.util.ActionResult;
|
|
|
|
|
import net.minecraft.util.Identifier;
|
|
|
|
|
import net.minecraft.util.registry.Registry;
|
|
|
|
|
import net.minecraft.world.biome.Biome;
|
|
|
|
|
import net.minecraft.world.biome.GenerationSettings;
|
|
|
|
|
import net.minecraft.world.gen.GenerationStep;
|
|
|
|
|
import net.minecraft.world.gen.decorator.ChanceDecoratorConfig;
|
|
|
|
|
import net.minecraft.world.gen.decorator.Decorator;
|
|
|
|
|
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
|
|
|
|
|
import net.minecraft.world.gen.feature.Feature;
|
|
|
|
|
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
|
|
|
|
import net.minecraft.world.gen.feature.OreFeatureConfig.Target;
|
|
|
|
|
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
|
|
|
|
import net.minecraft.world.gen.feature.SimpleBlockFeatureConfig;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -152,6 +159,30 @@ public class RegistryManager {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* add configured feature to biome
|
|
|
|
|
*
|
|
|
|
|
* @param biome the biome
|
|
|
|
|
* @param generationStep the genration step
|
|
|
|
|
* @param configuredFeature the configured feature
|
|
|
|
|
*/
|
|
|
|
|
private static final void addFeature(Biome biome, GenerationStep.Feature generationStep,
|
|
|
|
|
Supplier<ConfiguredFeature<?, ?>> configuredFeature) {
|
|
|
|
|
GenerationSettings generationSettings = biome.getGenerationSettings();
|
|
|
|
|
List<List<Supplier<ConfiguredFeature<?, ?>>>> features = generationSettings.getFeatures();
|
|
|
|
|
if (features instanceof ImmutableList) {
|
|
|
|
|
features = Lists.newArrayList(features);
|
|
|
|
|
}
|
|
|
|
|
for (int i = features.size(); i <= generationStep.ordinal(); i++) {
|
|
|
|
|
features.add(Lists.newArrayList());
|
|
|
|
|
}
|
|
|
|
|
List<Supplier<ConfiguredFeature<?, ?>>> suppliers = features.get(generationStep.ordinal());
|
|
|
|
|
if (suppliers instanceof ImmutableList) {
|
|
|
|
|
features.set(generationStep.ordinal(), suppliers = Lists.newArrayList(suppliers));
|
|
|
|
|
}
|
|
|
|
|
suppliers.add(configuredFeature);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* generate ores
|
|
|
|
|
*
|
|
|
|
@ -164,12 +195,12 @@ public class RegistryManager {
|
|
|
|
|
* @param topOffset the upper limit
|
|
|
|
|
* @param maximum the maximum number of blocks in a vein
|
|
|
|
|
*/
|
|
|
|
|
public static void generateOreForTarget(Biome biome, Target target, Block block, int veinsize, int count,
|
|
|
|
|
public static void generateOreForTarget(Biome biome, RuleTest target, Block block, int veinsize, int count,
|
|
|
|
|
int bottomOffset, int topOffset, int maximum) {
|
|
|
|
|
OreFeatureConfig ofc = new OreFeatureConfig(target, block.getDefaultState(), veinsize);
|
|
|
|
|
RangeDecoratorConfig rdc = new RangeDecoratorConfig(count, bottomOffset, topOffset, maximum);
|
|
|
|
|
biome.addFeature(GenerationStep.Feature.UNDERGROUND_ORES,
|
|
|
|
|
Feature.ORE.configure(ofc).createDecoratedFeature(Decorator.COUNT_RANGE.configure(rdc)));
|
|
|
|
|
RangeDecoratorConfig rdc = new RangeDecoratorConfig(bottomOffset, topOffset, maximum);
|
|
|
|
|
addFeature(biome, GenerationStep.Feature.UNDERGROUND_ORES,
|
|
|
|
|
() -> Feature.ORE.configure(ofc).decorate(Decorator.RANGE.configure(rdc).spreadHorizontally().repeat(count)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -183,10 +214,11 @@ public class RegistryManager {
|
|
|
|
|
* @param chance the chance for the replacement
|
|
|
|
|
*/
|
|
|
|
|
public static void generateOreInBlocks(Biome biome, List<BlockState> placeOn, List<BlockState> placeIn,
|
|
|
|
|
List<BlockState> placeUnder, Block block, float chance) {
|
|
|
|
|
List<BlockState> placeUnder, Block block, int chance) {
|
|
|
|
|
SimpleBlockFeatureConfig sbfc = new SimpleBlockFeatureConfig(block.getDefaultState(), placeOn, placeIn, placeUnder);
|
|
|
|
|
biome.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS,
|
|
|
|
|
Feature.SIMPLE_BLOCK.configure(sbfc).withChance(chance).feature);
|
|
|
|
|
ChanceDecoratorConfig cdc = new ChanceDecoratorConfig(chance);
|
|
|
|
|
addFeature(biome, GenerationStep.Feature.LOCAL_MODIFICATIONS,
|
|
|
|
|
() -> Feature.SIMPLE_BLOCK.configure(sbfc).decorate(Decorator.CHANCE.configure(cdc)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -196,7 +228,7 @@ public class RegistryManager {
|
|
|
|
|
*/
|
|
|
|
|
public static final void handleBiome(Biome biome) {
|
|
|
|
|
if (biome.getCategory() == Biome.Category.NETHER) {
|
|
|
|
|
RegistryManager.generateOreForTarget(biome, OreFeatureConfig.Target.NETHER_ORE_REPLACEABLES,
|
|
|
|
|
RegistryManager.generateOreForTarget(biome, OreFeatureConfig.Rules.BASE_STONE_NETHER,
|
|
|
|
|
QuickieBlocks.ORE_NETHER_SULPHOR, 24, 10, 0, 0, 128);
|
|
|
|
|
} else if (biome.getCategory() == Biome.Category.THEEND) {
|
|
|
|
|
} else {
|
|
|
|
@ -208,13 +240,13 @@ public class RegistryManager {
|
|
|
|
|
List<BlockState> dirtlike = new ArrayList<>();
|
|
|
|
|
dirtlike.add(Blocks.DIRT.getDefaultState());
|
|
|
|
|
dirtlike.add(Blocks.GRASS.getDefaultState());
|
|
|
|
|
RegistryManager.generateOreInBlocks(biome, dirtlike, dirtlike, dirtlike, QuickieBlocks.DIRT_SALPETER, 1.0f);
|
|
|
|
|
RegistryManager.generateOreInBlocks(biome, sandlike, sandlike, sandlike, QuickieBlocks.SAND_SALPETER, 1.0f);
|
|
|
|
|
RegistryManager.generateOreInBlocks(biome, sandlike, sandlike, sandlike, QuickieBlocks.ORE_SAND_SALPETER, 1.0f);
|
|
|
|
|
RegistryManager.generateOreForTarget(biome, OreFeatureConfig.Target.NATURAL_STONE, QuickieBlocks.ORE_SULPHOR, 16,
|
|
|
|
|
4, 4, 196, 255);
|
|
|
|
|
RegistryManager.generateOreForTarget(biome, OreFeatureConfig.Target.NATURAL_STONE, QuickieBlocks.ORE_SALPETER, 12,
|
|
|
|
|
10, 4, 196, 255);
|
|
|
|
|
RegistryManager.generateOreInBlocks(biome, dirtlike, dirtlike, dirtlike, QuickieBlocks.DIRT_SALPETER, 1);
|
|
|
|
|
RegistryManager.generateOreInBlocks(biome, sandlike, sandlike, sandlike, QuickieBlocks.SAND_SALPETER, 1);
|
|
|
|
|
RegistryManager.generateOreInBlocks(biome, sandlike, sandlike, sandlike, QuickieBlocks.ORE_SAND_SALPETER, 1);
|
|
|
|
|
RegistryManager.generateOreForTarget(biome, OreFeatureConfig.Rules.BASE_STONE_OVERWORLD,
|
|
|
|
|
QuickieBlocks.ORE_SULPHOR, 16, 4, 4, 32, 255);
|
|
|
|
|
RegistryManager.generateOreForTarget(biome, OreFeatureConfig.Rules.BASE_STONE_OVERWORLD,
|
|
|
|
|
QuickieBlocks.ORE_SALPETER, 12, 10, 4, 32, 255);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|