diff --git a/src/main/java/net/parsell/cherry/Cherry.java b/src/main/java/net/parsell/cherry/Cherry.java index 855a81f..c3159f6 100644 --- a/src/main/java/net/parsell/cherry/Cherry.java +++ b/src/main/java/net/parsell/cherry/Cherry.java @@ -1,10 +1,10 @@ package net.parsell.cherry; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.parsell.cherry.core.*; +import net.parsell.cherry.core.CherryBlocks; +import net.parsell.cherry.core.CherryFeatures; +import net.parsell.cherry.core.CherryItems; + public class Cherry implements ModInitializer { @Override diff --git a/src/main/java/net/parsell/cherry/core/CherryBlocks.java b/src/main/java/net/parsell/cherry/core/CherryBlocks.java index 9e5c2c0..751ec15 100644 --- a/src/main/java/net/parsell/cherry/core/CherryBlocks.java +++ b/src/main/java/net/parsell/cherry/core/CherryBlocks.java @@ -11,23 +11,34 @@ import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; public class CherryBlocks { - public static final Block CHERRYLOG = new PillarBlock(FabricBlockSettings.copyOf(Blocks.OAK_LOG)); - public static final Block CHERRYLEAVES = new LeavesBlock(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)); + public static final Block CHERRYLOG = registerPillar("cherry_log", FabricBlockSettings.copyOf(Blocks.OAK_LOG), 5, 5); + 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() { - System.out.println("Adding blocks..."); - Registry.register(Registry.BLOCK, new Identifier("cherry", "cherry_log"), CHERRYLOG); - Registry.register(Registry.BLOCK, new Identifier("cherry", "cherry_leaves"), CHERRYLEAVES); - System.out.println("Successfully added blocks!"); - 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); - } + private static Block registerBlock(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){ + Block block = new Block(settings); + Registry.register(Registry.BLOCK, new Identifier("cherry", blockID), block); + FlammableBlockRegistry.getDefaultInstance().add(block, burnChance, burnSpread); + return block; + } - public static void init(){ - registerBlocks(); - } + private static Block registerPillar(String blockID, FabricBlockSettings settings, int burnChance, int burnSpread){ + 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(){ + } } diff --git a/src/main/java/net/parsell/cherry/core/CherryFeatures.java b/src/main/java/net/parsell/cherry/core/CherryFeatures.java index 950ae97..b943ab8 100644 --- a/src/main/java/net/parsell/cherry/core/CherryFeatures.java +++ b/src/main/java/net/parsell/cherry/core/CherryFeatures.java @@ -27,31 +27,31 @@ import net.minecraft.world.gen.trunk.StraightTrunkPlacer; import net.parsell.cherry.common.features.CherryTree; public class CherryFeatures { - private static final BlockState CHERRYLOG_STATE = CherryBlocks.CHERRYLOG.getDefaultState(); - private static final BlockState CHERRYLEAVES_STATE = CherryBlocks.CHERRYLEAVES.getDefaultState(); + private static final BlockState CHERRYLOG_STATE = CherryBlocks.CHERRYLOG.getDefaultState(); + private static final BlockState CHERRYLEAVES_STATE = CherryBlocks.CHERRYLEAVES.getDefaultState(); - // Create the features - private static final Feature CHERRY_TREE_1 = new CherryTree(DefaultFeatureConfig.CODEC); + // Create the features + private static final Feature CHERRY_TREE_1 = new CherryTree(DefaultFeatureConfig.CODEC); - // 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(); - 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))); + // 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(); + 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))); - private static void addFeatures(){ - // Register the features - Registry.register(Registry.FEATURE, new Identifier("cherry", "cherry_tree"), CHERRY_TREE_1); + private static void addFeatures(){ + // Register the features + Registry.register(Registry.FEATURE, new Identifier("cherry", "cherry_tree"), CHERRY_TREE_1); - // Register the configured features + // Register the configured features RegistryKey> 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.WOODED_HILLS), GenerationStep.Feature.VEGETAL_DECORATION, cherryTree1); - } + BiomeModifications.addFeature(BiomeSelectors.includeByKey(BiomeKeys.WOODED_HILLS), GenerationStep.Feature.VEGETAL_DECORATION, cherryTree1); + } - public static void init(){ - addFeatures(); - } + public static void init(){ + addFeatures(); + } } \ No newline at end of file diff --git a/src/main/java/net/parsell/cherry/core/CherryItems.java b/src/main/java/net/parsell/cherry/core/CherryItems.java index fc6ee03..945b5d8 100644 --- a/src/main/java/net/parsell/cherry/core/CherryItems.java +++ b/src/main/java/net/parsell/cherry/core/CherryItems.java @@ -2,26 +2,35 @@ package net.parsell.cherry.core; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.minecraft.block.Block; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemGroup; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; 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(){ - System.out.println("Adding items..."); - 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", "cherry_leaves"), CHERRYLEAVES_I); - System.out.println("Successfully added items!"); - ColorProviderRegistry.ITEM.register((stack, tintIndex) -> { - return 6649929; - }, CherryBlocks.CHERRYLEAVES - ); - } + // Register a standard blockItem + private static void registerBlockItem(String itemID, Block block, ItemGroup group){ + Registry.register(Registry.ITEM, new Identifier("cherry", itemID), new BlockItem(block, new FabricItemSettings().group(group))); + } - public static void init(){ - registerBlockItems(); - } + // Register a blockItem that require in-game color (leaves) + 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(); + } } diff --git a/src/main/resources/assets/cherry/blockstates/cherry_planks.json b/src/main/resources/assets/cherry/blockstates/cherry_planks.json new file mode 100644 index 0000000..b482c75 --- /dev/null +++ b/src/main/resources/assets/cherry/blockstates/cherry_planks.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "cherry:block/cherry_planks" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/cherry/lang/en_us.json b/src/main/resources/assets/cherry/lang/en_us.json index a695e68..e35a38e 100644 --- a/src/main/resources/assets/cherry/lang/en_us.json +++ b/src/main/resources/assets/cherry/lang/en_us.json @@ -1,4 +1,5 @@ { "block.cherry.cherry_log": "Cherry Log", - "block.cherry.cherry_leaves": "Cherry Leaves" + "block.cherry.cherry_leaves": "Cherry Leaves", + "block.cherry.cherry_planks": "Cherry Planks" } \ No newline at end of file diff --git a/src/main/resources/assets/cherry/models/block/cherry_planks.json b/src/main/resources/assets/cherry/models/block/cherry_planks.json new file mode 100644 index 0000000..2cfacd4 --- /dev/null +++ b/src/main/resources/assets/cherry/models/block/cherry_planks.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "cherry:block/cherry_planks" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/cherry/models/item/cherry_planks.json b/src/main/resources/assets/cherry/models/item/cherry_planks.json new file mode 100644 index 0000000..5706e87 --- /dev/null +++ b/src/main/resources/assets/cherry/models/item/cherry_planks.json @@ -0,0 +1,3 @@ +{ + "parent": "cherry:block/cherry_planks" +} \ No newline at end of file diff --git a/src/main/resources/assets/cherry/textures/block/cherry_planks.png b/src/main/resources/assets/cherry/textures/block/cherry_planks.png new file mode 100644 index 0000000..569b753 Binary files /dev/null and b/src/main/resources/assets/cherry/textures/block/cherry_planks.png differ diff --git a/src/main/resources/data/cherry/tags/blocks/cherry_wood.json b/src/main/resources/data/cherry/tags/blocks/cherry_logs.json similarity index 100% rename from src/main/resources/data/cherry/tags/blocks/cherry_wood.json rename to src/main/resources/data/cherry/tags/blocks/cherry_logs.json diff --git a/src/main/resources/data/minecraft/tags/blocks/logs_that_burn.json b/src/main/resources/data/minecraft/tags/blocks/logs_that_burn.json index b32d396..e00a231 100644 --- a/src/main/resources/data/minecraft/tags/blocks/logs_that_burn.json +++ b/src/main/resources/data/minecraft/tags/blocks/logs_that_burn.json @@ -1,6 +1,6 @@ { "replace": false, "values": [ - "#cherry:cherry_wood" + "#cherry:cherry_logs" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/planks.json b/src/main/resources/data/minecraft/tags/blocks/planks.json new file mode 100644 index 0000000..8bcf3fb --- /dev/null +++ b/src/main/resources/data/minecraft/tags/blocks/planks.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "cherry:cherry_planks" + ] +} \ No newline at end of file