started with itemhoarder

This commit is contained in:
Jörg Henke 2020-07-31 20:35:04 +02:00
parent 842f04baca
commit 6f73265cc9
3 changed files with 60 additions and 34 deletions

View File

@ -17,6 +17,7 @@ public class QuickieFabric implements ModInitializer {
RegistryManager.registerTools();
RegistryManager.registerEvents();
RegistryManager.registerBlocks();
RegistryManager.registerBlockEntities();
Registry.BIOME.forEach(RegistryManager::handleBiome);
}
}

View File

@ -13,4 +13,5 @@ public class QuickieBlocks {
public static final BlockOreSulphor ORE_SULPHOR = new BlockOreSulphor();
public static final BlockSandSalpeter SAND_SALPETER = new BlockSandSalpeter();
public static final BlockLavahoarder LAVAHOARDER = new BlockLavahoarder();
public static final BlockItemhoarder ITEMHOARDER = new BlockItemhoarder();
}

View File

@ -6,6 +6,8 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.jottyfan.minecraft.quickiefabric.blockentity.ItemHoarderBlockEntity;
import de.jottyfan.minecraft.quickiefabric.blockentity.QuickieFabricBlockEntity;
import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks;
import de.jottyfan.minecraft.quickiefabric.event.BreakBlockCallback;
import de.jottyfan.minecraft.quickiefabric.event.EventBlockBreak;
@ -15,6 +17,7 @@ import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
@ -41,7 +44,8 @@ public class RegistryManager {
private static final String QUICKIEFABRIC = "quickiefabric";
public static final ItemGroup QUICKIEFABRIC_GROUP = FabricItemGroupBuilder.create(new Identifier(QUICKIEFABRIC, "all")).icon(() -> new ItemStack(QuickieItems.SPEEDPOWDER)).appendItems(stacks -> {
public static final ItemGroup QUICKIEFABRIC_GROUP = FabricItemGroupBuilder.create(new Identifier(QUICKIEFABRIC, "all")).icon(() -> new ItemStack(QuickieItems.SPEEDPOWDER))
.appendItems(stacks -> {
stacks.add(new ItemStack(QuickieItems.SALPETER));
stacks.add(new ItemStack(QuickieItems.SULPHOR));
stacks.add(new ItemStack(QuickieItems.SPEEDPOWDER));
@ -57,6 +61,7 @@ public class RegistryManager {
stacks.add(new ItemStack(QuickieBlocks.ORE_SULPHOR));
stacks.add(new ItemStack(QuickieBlocks.SAND_SALPETER));
stacks.add(new ItemStack(QuickieBlocks.LAVAHOARDER));
stacks.add(new ItemStack(QuickieBlocks.ITEMHOARDER));
}).build();
private static final void registerBlock(Block block, String name) {
@ -68,6 +73,11 @@ public class RegistryManager {
Registry.register(Registry.ITEM, new Identifier(QUICKIEFABRIC, name), item);
}
public static final void registerBlockEntities() {
QuickieFabricBlockEntity.ITEMHOARDER = Registry.register(Registry.BLOCK_ENTITY_TYPE, QUICKIEFABRIC + ":itemhoarderblockentity",
BlockEntityType.Builder.create(ItemHoarderBlockEntity::new, QuickieBlocks.ITEMHOARDER).build(null));
}
public static final void registerBlocks() {
LOGGER.debug("registering quickiefabric blocks");
registerBlock(QuickieBlocks.DIRT_SALPETER, "dirtsalpeter");
@ -77,6 +87,7 @@ public class RegistryManager {
registerBlock(QuickieBlocks.ORE_SULPHOR, "oresulphor");
registerBlock(QuickieBlocks.SAND_SALPETER, "sandsalpeter");
registerBlock(QuickieBlocks.LAVAHOARDER, "lavahoarder");
registerBlock(QuickieBlocks.ITEMHOARDER, "itemhoarder");
}
public static final void registerItems() {
@ -106,14 +117,22 @@ public class RegistryManager {
/**
* generate ores
*
* @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
* @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, Target target, Block block, int veinsize, int count, int bottomOffset, int topOffset, int maximum) {
OreFeatureConfig ofc = new OreFeatureConfig(target, block.getDefaultState(), veinsize);
@ -124,19 +143,24 @@ public class RegistryManager {
/**
* 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
* @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, float chance) {
SimpleBlockFeatureConfig sbfc = new SimpleBlockFeatureConfig(block.getDefaultState(), placeOn, placeIn, placeUnder);
biome.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, Feature.SIMPLE_BLOCK.configure(sbfc).withChance(chance).feature);
}
/**
* add the quickiefabric ores to the biome
*