spawn sulfor and salpeter in worlds

This commit is contained in:
Jörg Henke 2020-10-17 23:03:57 +02:00
parent a848bdb857
commit 657fe6122c
6 changed files with 183 additions and 164 deletions

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.9.3+build.207 loader_version=0.9.3+build.207
# Mod Properties # Mod Properties
mod_version = 1.16.3.3 mod_version = 1.16.3.4
maven_group = de.jottyfan.minecraft maven_group = de.jottyfan.minecraft
archives_base_name = quickiefabric archives_base_name = quickiefabric

View File

@ -2,7 +2,6 @@ package de.jottyfan.minecraft.quickiefabric;
import de.jottyfan.minecraft.quickiefabric.init.RegistryManager; import de.jottyfan.minecraft.quickiefabric.init.RegistryManager;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.minecraft.util.registry.BuiltinRegistries;
/** /**
* *
@ -19,6 +18,6 @@ public class QuickieFabric implements ModInitializer {
RegistryManager.registerBlocks(); RegistryManager.registerBlocks();
RegistryManager.registerBlockEntities(); RegistryManager.registerBlockEntities();
RegistryManager.registerContainer(); RegistryManager.registerContainer();
BuiltinRegistries.BIOME.forEach(RegistryManager::handleBiome); RegistryManager.registerFeatures();
} }
} }

View File

@ -38,109 +38,137 @@ public class EventBlockBreak {
Integer level = nbt != null ? nbt.getInt("level") : 0; Integer level = nbt != null ? nbt.getInt("level") : 0;
ToolRangeable tool = (ToolRangeable) item; ToolRangeable tool = (ToolRangeable) item;
Block block = blockState.getBlock(); Block block = blockState.getBlock();
handleRangeableTools(tool, level, world, block, blockPos, playerEntity); int handled = handleRangeableTools(tool, level, world, block, blockPos, playerEntity);
world.spawnEntity(new ExperienceOrbEntity(world, blockPos.getX(), blockPos.getY(), blockPos.getZ(), 1)); // reward for using rangeable tool if (handled >= 255) {
// reward for using rangeable tool very successful
world.spawnEntity(new ExperienceOrbEntity(world, blockPos.getX(), blockPos.getY(), blockPos.getZ(), handled / 255));
}
} }
} }
} }
/** /**
* hande the rangeable tools break event * handle the rangeable tools break event
* *
* @param tool * @param tool the tool that has been used
* the tool that has been used * @param world the world
* @param world * @param block the block to break
* the world * @param pos the position of the current block
* @param block * @param player the current player
* the block to break * @return number of affected blocks
* @param pos
* the position of the current block
* @param player
* the current player
*/ */
private void handleRangeableTools(ToolRangeable tool, Integer level, World world, Block currentBlock, BlockPos pos, PlayerEntity player) { private int handleRangeableTools(ToolRangeable tool, Integer level, World world, Block currentBlock, BlockPos pos,
PlayerEntity player) {
List<Block> validBlocks = tool.getBlockList(currentBlock); List<Block> validBlocks = tool.getBlockList(currentBlock);
HarvestRange range = tool.getRange(); HarvestRange range = tool.getRange();
if (range != null) { if (range != null) {
range = range.addXYZ(level); range = range.addXYZ(level);
} }
if (QuickieTools.SPEEDPOWDERAXE.equals(tool)) { if (QuickieTools.SPEEDPOWDERAXE.equals(tool)) {
breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS, player, true); return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.UPWARDS,
player, true);
} else if (QuickieTools.SPEEDPOWDERPICKAXE.equals(tool)) { } else if (QuickieTools.SPEEDPOWDERPICKAXE.equals(tool)) {
breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player, false); return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
player, false);
} else if (QuickieTools.SPEEDPOWDERSHOVEL.equals(tool)) { } else if (QuickieTools.SPEEDPOWDERSHOVEL.equals(tool)) {
breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL, player, false); return breakBlockRecursive(new ArrayList<>(), world, validBlocks, pos, tool, range, BlockBreakDirection.ALL,
player, false);
} else {
return 0;
} }
} }
/** /**
* break block recursively; * break block recursively;
* *
* @param visitedBlocks * @param visitedBlocks the positions of visited blocks
* the positions of visited blocks * @param world the world
* @param world * @param validBlocks the blocks to break
* the world * @param tool the tool used
* @param validBlocks * @param range the range left over
* the blocks to break * @param pos the position
* @param tool * @param blockBreakDirection the direction for the recursive call
* the tool used * @param player the player
* @param range * @return number of affected blocks
* the range left over
* @param pos
* the position
* @param blockBreakDirection
* the direction for the recursive call
* @param player
* the player
*/ */
private void breakBlockRecursive(List<String> visitedBlocks, World world, List<Block> validBlocks, BlockPos pos, ToolRangeable tool, HarvestRange range, BlockBreakDirection blockBreakDirection, private int breakBlockRecursive(List<String> visitedBlocks, World world, List<Block> validBlocks, BlockPos pos,
PlayerEntity player, boolean breakLeaves) { ToolRangeable tool, HarvestRange range, BlockBreakDirection blockBreakDirection, PlayerEntity player,
boolean breakLeaves) {
if (visitedBlocks.contains(pos.toString())) { if (visitedBlocks.contains(pos.toString())) {
return; // reduce loops return 0;
} else if (validBlocks == null) { } else if (validBlocks == null) {
return; // reduce loops return 0;
} else { } else {
visitedBlocks.add(pos.toString()); visitedBlocks.add(pos.toString());
} }
Integer affected = 0;
BlockState blockState = world.getBlockState(pos); BlockState blockState = world.getBlockState(pos);
if (tool.canBreakNeighbors(blockState)) { if (tool.canBreakNeighbors(blockState)) {
Block currentBlock = blockState.getBlock(); Block currentBlock = blockState.getBlock();
if (validBlocks.contains(currentBlock)) { if (validBlocks.contains(currentBlock)) {
Block.dropStacks(blockState, world, pos); // includes xorbs Block.dropStacks(blockState, world, pos); // includes xorbs
affected += 1;
world.setBlockState(pos, Blocks.AIR.getDefaultState()); world.setBlockState(pos, Blocks.AIR.getDefaultState());
if (range == null || range.getxRange() > 1 || range.getyRange() > 1 || range.getzRange() > 1) { if (range == null || range.getxRange() > 1 || range.getyRange() > 1 || range.getzRange() > 1) {
HarvestRange nextRadius = range == null ? null : range.addXYZ(-1); HarvestRange nextRadius = range == null ? null : range.addXYZ(-1);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north().east(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.north().west(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south().east(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().north(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().north().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.south().west(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().north().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.east(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().south().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.west(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().south().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().south(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().north(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().north().east(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().north().west(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().east(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().west(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().south().east(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().south().west(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.up().south(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
if (BlockBreakDirection.ALL.equals(blockBreakDirection)) { if (BlockBreakDirection.ALL.equals(blockBreakDirection)) {
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().north(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().south(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().north(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().south(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().north().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().north().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().east(), tool, nextRadius,
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().south().east(), tool, nextRadius, blockBreakDirection, player, breakLeaves); blockBreakDirection, player, breakLeaves);
breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().south().west(), tool, nextRadius, blockBreakDirection, player, breakLeaves); affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().west(), tool, nextRadius,
blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().north().east(), tool,
nextRadius, blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().north().west(), tool,
nextRadius, blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().south().east(), tool,
nextRadius, blockBreakDirection, player, breakLeaves);
affected += breakBlockRecursive(visitedBlocks, world, validBlocks, pos.down().south().west(), tool,
nextRadius, blockBreakDirection, player, breakLeaves);
} }
} }
} }
} }
return affected;
} }
} }

View File

@ -1,15 +1,11 @@
package de.jottyfan.minecraft.quickiefabric.init; package de.jottyfan.minecraft.quickiefabric.init;
import java.util.ArrayList; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.function.Supplier;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; 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.ItemHoarderBlockEntity;
import de.jottyfan.minecraft.quickiefabric.blockentity.MonsterHoarderBlockEntity; import de.jottyfan.minecraft.quickiefabric.blockentity.MonsterHoarderBlockEntity;
import de.jottyfan.minecraft.quickiefabric.blockentity.QuickieFabricBlockEntity; import de.jottyfan.minecraft.quickiefabric.blockentity.QuickieFabricBlockEntity;
@ -22,7 +18,6 @@ import de.jottyfan.minecraft.quickiefabric.tools.QuickieTools;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
@ -30,20 +25,16 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.structure.rule.RuleTest; import net.minecraft.structure.rule.BlockMatchRuleTest;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry; 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.Decorator;
import net.minecraft.world.gen.decorator.RangeDecoratorConfig; import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.feature.SimpleBlockFeatureConfig;
/** /**
* *
@ -59,6 +50,41 @@ public class RegistryManager {
public static final ScreenHandlerType<BackpackScreenHandler> BACKPACK_SCREEN_HANDLER = ScreenHandlerRegistry public static final ScreenHandlerType<BackpackScreenHandler> BACKPACK_SCREEN_HANDLER = ScreenHandlerRegistry
.registerExtended(RegistryManager.BACKPACK_IDENTIFIER, BackpackScreenHandler::new); .registerExtended(RegistryManager.BACKPACK_IDENTIFIER, BackpackScreenHandler::new);
public static final ConfiguredFeature<?, ?> FEATURE_ORENETHERSULPHOR = Feature.ORE
.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_NETHER,
QuickieBlocks.ORE_NETHER_SULPHOR.getDefaultState(), 24))
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 128)).spreadHorizontally().repeat(10));
public static final ConfiguredFeature<?, ?> FEATURE_ORESALPETER = Feature.ORE
.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD,
QuickieBlocks.ORE_SALPETER.getDefaultState(), 12))
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(0, 0, 128))).spreadHorizontally().repeat(10);
public static final ConfiguredFeature<?, ?> FEATURE_ORESULPHOR = Feature.ORE
.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD,
QuickieBlocks.ORE_SULPHOR.getDefaultState(), 16))
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(4, 32, 255))).spreadHorizontally().repeat(4);
public static final ConfiguredFeature<?, ?> FEATURE_DIRTSALPETER = Feature.ORE
.configure(new OreFeatureConfig(new BlockMatchRuleTest(Blocks.DIRT),
QuickieBlocks.DIRT_SALPETER.getDefaultState(), 3))
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(4, 0, 255))).spreadHorizontally().repeatRandomly(4);
public static final ConfiguredFeature<?, ?> FEATURE_SANDSALPETER = Feature.ORE
.configure(new OreFeatureConfig(new BlockMatchRuleTest(Blocks.SAND),
QuickieBlocks.SAND_SALPETER.getDefaultState(), 3))
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(4, 0, 255))).spreadHorizontally().repeatRandomly(4);
public static final ConfiguredFeature<?, ?> FEATURE_ORESANDSALPETER = Feature.ORE
.configure(new OreFeatureConfig(new BlockMatchRuleTest(Blocks.SANDSTONE),
QuickieBlocks.ORE_SAND_SALPETER.getDefaultState(), 3))
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(4, 0, 255))).spreadHorizontally().repeatRandomly(4);
public static final List<ConfiguredFeature<?, ?>> FEATURE_UNDERGROUND_ORES = Arrays.asList(FEATURE_ORESALPETER,
FEATURE_ORESULPHOR, FEATURE_DIRTSALPETER, FEATURE_SANDSALPETER, FEATURE_ORESANDSALPETER);
public static final List<ConfiguredFeature<?, ?>> FEATURE_UNDERGROUND_DECORATIONS = Arrays
.asList(FEATURE_ORENETHERSULPHOR);
public static final ItemGroup QUICKIEFABRIC_GROUP = FabricItemGroupBuilder public static final ItemGroup QUICKIEFABRIC_GROUP = FabricItemGroupBuilder
.create(new Identifier(QUICKIEFABRIC, "all")).icon(() -> new ItemStack(QuickieItems.SPEEDPOWDER)) .create(new Identifier(QUICKIEFABRIC, "all")).icon(() -> new ItemStack(QuickieItems.SPEEDPOWDER))
.appendItems(stacks -> { .appendItems(stacks -> {
@ -162,94 +188,24 @@ public class RegistryManager {
} }
/** /**
* add configured feature to biome * register ore generation feature
* *
* @param biome the biome * @param name the name for the identifier
* @param generationStep the genration step * @param feature the feature
* @param configuredFeature the configured feature
*/ */
private static final void addFeature(Biome biome, GenerationStep.Feature generationStep, private static final void registerFeature(String name, ConfiguredFeature<?, ?> feature) {
Supplier<ConfiguredFeature<?, ?>> configuredFeature) { Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(QUICKIEFABRIC, name), feature);
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 * register ore generation features
*
* @param biome the biome to generate the veins in
* @param target the block to be replaced
* @param block the block that is the replacement
* @param veinsize the size of the vein
* @param count the number of veins in a chunk
* @param bottomOffset the lower limit
* @param topOffset the upper limit
* @param maximum the maximum number of blocks in a vein
*/ */
public static void generateOreForTarget(Biome biome, RuleTest target, Block block, int veinsize, int count, public static final void registerFeatures() {
int bottomOffset, int topOffset, int maximum) { registerFeature("feature_orenethersulphor", FEATURE_ORENETHERSULPHOR);
OreFeatureConfig ofc = new OreFeatureConfig(target, block.getDefaultState(), veinsize); registerFeature("feature_oresalpeter", FEATURE_ORESALPETER);
RangeDecoratorConfig rdc = new RangeDecoratorConfig(bottomOffset, topOffset, maximum); registerFeature("feature_oresulphor", FEATURE_ORESULPHOR);
addFeature(biome, GenerationStep.Feature.UNDERGROUND_ORES, registerFeature("feature_dirtsalpeter", FEATURE_DIRTSALPETER);
() -> Feature.ORE.configure(ofc).decorate(Decorator.RANGE.configure(rdc).spreadHorizontally().repeat(count))); registerFeature("feature_sandsalpeter", FEATURE_SANDSALPETER);
} registerFeature("feature_oresandsalpeter", FEATURE_ORESANDSALPETER);
/**
* generate ore instead of block
*
* @param biome the biome
* @param placeOn the list of blockStates underneath
* @param placeIn the list of blockStates to be replaced
* @param placeUnder the list of blockStates above
* @param block the block to set
* @param chance the chance for the replacement
*/
public static void generateOreInBlocks(Biome biome, List<BlockState> placeOn, List<BlockState> placeIn,
List<BlockState> placeUnder, Block block, int chance) {
SimpleBlockFeatureConfig sbfc = new SimpleBlockFeatureConfig(block.getDefaultState(), placeOn, placeIn, placeUnder);
ChanceDecoratorConfig cdc = new ChanceDecoratorConfig(chance);
addFeature(biome, GenerationStep.Feature.LOCAL_MODIFICATIONS,
() -> Feature.SIMPLE_BLOCK.configure(sbfc).decorate(Decorator.CHANCE.configure(cdc)));
}
/**
* add the quickiefabric ores to the biome
*
* @param biome the biome
*/
public static final void handleBiome(Biome biome) {
if (biome.getCategory() == Biome.Category.NETHER) {
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 {
List<BlockState> sandlike = new ArrayList<>();
sandlike.add(Blocks.SAND.getDefaultState());
sandlike.add(Blocks.SANDSTONE.getDefaultState());
sandlike.add(Blocks.SANDSTONE_WALL.getDefaultState());
sandlike.add(Blocks.CHISELED_SANDSTONE.getDefaultState());
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);
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);
} }
} }
}

View File

@ -0,0 +1,35 @@
package de.jottyfan.minecraft.quickiefabric.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import de.jottyfan.minecraft.quickiefabric.init.RegistryManager;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.DefaultBiomeFeatures;
/**
*
* @author jotty
*
*/
@Mixin(DefaultBiomeFeatures.class)
public class FeatureConfigMixin {
@Inject(at = @At("TAIL"), method = "addMineables(Lnet/minecraft/world/biome/GenerationSettings$Builder;)V")
private static void addMineables(GenerationSettings.Builder builder, CallbackInfo ci) {
for (ConfiguredFeature<?, ?> configuredFeature : RegistryManager.FEATURE_UNDERGROUND_ORES) {
builder.feature(GenerationStep.Feature.UNDERGROUND_ORES, configuredFeature);
}
}
@Inject(at = @At("HEAD"), method = "addNetherMineables(Lnet/minecraft/world/biome/GenerationSettings$Builder;)V")
private static void addNetherMineables(GenerationSettings.Builder builder, CallbackInfo ci) {
for (ConfiguredFeature<?, ?> configuredFeature : RegistryManager.FEATURE_UNDERGROUND_DECORATIONS) {
builder.feature(GenerationStep.Feature.UNDERGROUND_DECORATION, configuredFeature);
}
}
}

View File

@ -4,7 +4,8 @@
"package": "de.jottyfan.minecraft.quickiefabric.mixin", "package": "de.jottyfan.minecraft.quickiefabric.mixin",
"compatibilityLevel": "JAVA_8", "compatibilityLevel": "JAVA_8",
"mixins": [ "mixins": [
"BlockBreakMixin" "BlockBreakMixin",
"FeatureConfigMixin"
], ],
"client": [ "client": [
], ],