introduction of cherry planks & register update
This commit is contained in:
parent
0c93573d81
commit
4169f908fc
|
@ -1,10 +1,10 @@
|
||||||
package net.parsell.cherry;
|
package net.parsell.cherry;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
import net.parsell.cherry.core.CherryBlocks;
|
||||||
import net.minecraft.block.Block;
|
import net.parsell.cherry.core.CherryFeatures;
|
||||||
import net.minecraft.block.Blocks;
|
import net.parsell.cherry.core.CherryItems;
|
||||||
import net.parsell.cherry.core.*;
|
|
||||||
public class Cherry implements ModInitializer {
|
public class Cherry implements ModInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,23 +11,34 @@ import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
public class CherryBlocks {
|
public class CherryBlocks {
|
||||||
public static final Block CHERRYLOG = new PillarBlock(FabricBlockSettings.copyOf(Blocks.OAK_LOG));
|
public static final Block CHERRYLOG = registerPillar("cherry_log", FabricBlockSettings.copyOf(Blocks.OAK_LOG), 5, 5);
|
||||||
public static final Block CHERRYLEAVES = new LeavesBlock(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES));
|
public static final Block CHERRYLEAVES = registerLeaves("cherry_leaves", FabricBlockSettings.copyOf(Blocks.OAK_LEAVES), 30, 60, 6649929);
|
||||||
|
public static final Block CHERRYPLANKS = registerBlock("cherry_planks", FabricBlockSettings.copyOf(Blocks.OAK_PLANKS), 5, 20);
|
||||||
|
|
||||||
private static void registerBlocks() {
|
private static Block registerBlock(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){
|
||||||
System.out.println("Adding blocks...");
|
Block block = new Block(settings);
|
||||||
Registry.register(Registry.BLOCK, new Identifier("cherry", "cherry_log"), CHERRYLOG);
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
||||||
Registry.register(Registry.BLOCK, new Identifier("cherry", "cherry_leaves"), CHERRYLEAVES);
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
||||||
System.out.println("Successfully added blocks!");
|
return block;
|
||||||
System.out.println("Setting flammability...");
|
}
|
||||||
FlammableBlockRegistry.getDefaultInstance().add(CHERRYLOG, 5, 5);
|
|
||||||
FlammableBlockRegistry.getDefaultInstance().add(CHERRYLEAVES, 30, 60);
|
|
||||||
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> {
|
|
||||||
return 6649929;
|
|
||||||
}, CHERRYLEAVES);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init(){
|
private static Block registerPillar(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){
|
||||||
registerBlocks();
|
Block block = new PillarBlock(settings);
|
||||||
}
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
||||||
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Block registerLeaves(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread, int color){
|
||||||
|
Block block = new LeavesBlock(settings);
|
||||||
|
Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block);
|
||||||
|
FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread);
|
||||||
|
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> {
|
||||||
|
return color;
|
||||||
|
}, block);
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(){
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,31 +27,31 @@ import net.minecraft.world.gen.trunk.StraightTrunkPlacer;
|
||||||
import net.parsell.cherry.common.features.CherryTree;
|
import net.parsell.cherry.common.features.CherryTree;
|
||||||
|
|
||||||
public class CherryFeatures {
|
public class CherryFeatures {
|
||||||
private static final BlockState CHERRYLOG_STATE = CherryBlocks.CHERRYLOG.getDefaultState();
|
private static final BlockState CHERRYLOG_STATE = CherryBlocks.CHERRYLOG.getDefaultState();
|
||||||
private static final BlockState CHERRYLEAVES_STATE = CherryBlocks.CHERRYLEAVES.getDefaultState();
|
private static final BlockState CHERRYLEAVES_STATE = CherryBlocks.CHERRYLEAVES.getDefaultState();
|
||||||
|
|
||||||
// Create the features
|
// Create the features
|
||||||
private static final Feature<DefaultFeatureConfig> CHERRY_TREE_1 = new CherryTree(DefaultFeatureConfig.CODEC);
|
private static final Feature<DefaultFeatureConfig> CHERRY_TREE_1 = new CherryTree(DefaultFeatureConfig.CODEC);
|
||||||
|
|
||||||
// Configure the features
|
// Configure the features
|
||||||
static TreeFeatureConfig CHERRY_TREE_1_CONFIG = new TreeFeatureConfig.Builder(new SimpleBlockStateProvider(CHERRYLOG_STATE), new SimpleBlockStateProvider(CHERRYLEAVES_STATE), new BlobFoliagePlacer(UniformIntDistribution.of(2), UniformIntDistribution.of(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayersFeatureSize(1, 0, 1)).ignoreVines().build();
|
static TreeFeatureConfig CHERRY_TREE_1_CONFIG = new TreeFeatureConfig.Builder(new SimpleBlockStateProvider(CHERRYLOG_STATE), new SimpleBlockStateProvider(CHERRYLEAVES_STATE), new BlobFoliagePlacer(UniformIntDistribution.of(2), UniformIntDistribution.of(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayersFeatureSize(1, 0, 1)).ignoreVines().build();
|
||||||
public static final ConfiguredFeature<?, ?> CHERRY_TREE_1_C = Feature.TREE.configure(CHERRY_TREE_1_CONFIG);
|
public static final ConfiguredFeature<?, ?> CHERRY_TREE_1_C = Feature.TREE.configure(CHERRY_TREE_1_CONFIG);
|
||||||
public static final ConfiguredFeature<?, ?> CHERRY_TREE_1_C_R = Feature.RANDOM_SELECTOR.configure(new RandomFeatureConfig(ImmutableList.of(CHERRY_TREE_1_C.withChance(0.8F)), CHERRY_TREE_1_C)).decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).decorate(Decorator.COUNT_EXTRA.configure(new CountExtraDecoratorConfig(1, 0.1F, 1)));
|
public static final ConfiguredFeature<?, ?> CHERRY_TREE_1_C_R = Feature.RANDOM_SELECTOR.configure(new RandomFeatureConfig(ImmutableList.of(CHERRY_TREE_1_C.withChance(0.8F)), CHERRY_TREE_1_C)).decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).decorate(Decorator.COUNT_EXTRA.configure(new CountExtraDecoratorConfig(1, 0.1F, 1)));
|
||||||
|
|
||||||
private static void addFeatures(){
|
private static void addFeatures(){
|
||||||
// Register the features
|
// Register the features
|
||||||
Registry.register(Registry.FEATURE, new Identifier("cherry", "cherry_tree"), CHERRY_TREE_1);
|
Registry.register(Registry.FEATURE, new Identifier("cherry", "cherry_tree"), CHERRY_TREE_1);
|
||||||
|
|
||||||
// Register the configured features
|
// Register the configured features
|
||||||
RegistryKey<ConfiguredFeature<?, ?>> cherryTree1 = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("cherry", "cherry_tree_1"));
|
RegistryKey<ConfiguredFeature<?, ?>> cherryTree1 = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("cherry", "cherry_tree_1"));
|
||||||
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, cherryTree1.getValue(), CHERRY_TREE_1_C_R);
|
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, cherryTree1.getValue(), CHERRY_TREE_1_C_R);
|
||||||
|
|
||||||
// Modify the biomes
|
// Modify the biomes
|
||||||
BiomeModifications.addFeature(BiomeSelectors.includeByKey(BiomeKeys.FOREST), GenerationStep.Feature.VEGETAL_DECORATION, cherryTree1);
|
BiomeModifications.addFeature(BiomeSelectors.includeByKey(BiomeKeys.FOREST), GenerationStep.Feature.VEGETAL_DECORATION, cherryTree1);
|
||||||
BiomeModifications.addFeature(BiomeSelectors.includeByKey(BiomeKeys.WOODED_HILLS), GenerationStep.Feature.VEGETAL_DECORATION, cherryTree1);
|
BiomeModifications.addFeature(BiomeSelectors.includeByKey(BiomeKeys.WOODED_HILLS), GenerationStep.Feature.VEGETAL_DECORATION, cherryTree1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
addFeatures();
|
addFeatures();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,26 +2,35 @@ package net.parsell.cherry.core;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
||||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
public class CherryItems {
|
public class CherryItems {
|
||||||
public static BlockItem CHERRYLEAVES_I = new BlockItem(CherryBlocks.CHERRYLEAVES, new FabricItemSettings().group(ItemGroup.BUILDING_BLOCKS));
|
private static void registerBlockItems(){
|
||||||
|
registerBlockItem("cherry_log", CherryBlocks.CHERRYLOG, ItemGroup.BUILDING_BLOCKS);
|
||||||
|
registerBlockItem("cherry_leaves", CherryBlocks.CHERRYLEAVES, ItemGroup.BUILDING_BLOCKS, 6649929);
|
||||||
|
registerBlockItem("cherry_planks", CherryBlocks.CHERRYPLANKS, ItemGroup.BUILDING_BLOCKS);
|
||||||
|
}
|
||||||
|
|
||||||
private static void registerBlockItems(){
|
// Register a standard blockItem
|
||||||
System.out.println("Adding items...");
|
private static void registerBlockItem(String itemID, Block block, ItemGroup group){
|
||||||
Registry.register(Registry.ITEM, new Identifier("cherry", "cherry_log"), new BlockItem(CherryBlocks.CHERRYLOG, new FabricItemSettings().group(ItemGroup.BUILDING_BLOCKS)));
|
Registry.register(Registry.ITEM, new Identifier("cherry", itemID), new BlockItem(block, new FabricItemSettings().group(group)));
|
||||||
Registry.register(Registry.ITEM, new Identifier("cherry", "cherry_leaves"), CHERRYLEAVES_I);
|
}
|
||||||
System.out.println("Successfully added items!");
|
|
||||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> {
|
|
||||||
return 6649929;
|
|
||||||
}, CherryBlocks.CHERRYLEAVES
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init(){
|
// Register a blockItem that require in-game color (leaves)
|
||||||
registerBlockItems();
|
private static void registerBlockItem(String itemID, Block block, ItemGroup group, int color){
|
||||||
}
|
BlockItem blockItem = new BlockItem(block, new FabricItemSettings().group(group));
|
||||||
|
Registry.register(Registry.ITEM, new Identifier("cherry", itemID), blockItem);
|
||||||
|
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> {
|
||||||
|
return color;
|
||||||
|
}, block
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(){
|
||||||
|
registerBlockItems();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"": { "model": "cherry:block/cherry_planks" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
"block.cherry.cherry_log": "Cherry Log",
|
"block.cherry.cherry_log": "Cherry Log",
|
||||||
"block.cherry.cherry_leaves": "Cherry Leaves"
|
"block.cherry.cherry_leaves": "Cherry Leaves",
|
||||||
|
"block.cherry.cherry_planks": "Cherry Planks"
|
||||||
}
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "cherry:block/cherry_planks"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"parent": "cherry:block/cherry_planks"
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"replace": false,
|
"replace": false,
|
||||||
"values": [
|
"values": [
|
||||||
"#cherry:cherry_wood"
|
"#cherry:cherry_logs"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"replace": false,
|
||||||
|
"values": [
|
||||||
|
"cherry:cherry_planks"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue