Compare commits

...

2 Commits

17 changed files with 135 additions and 57 deletions

View File

@ -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

View File

@ -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(){
}
}

View File

@ -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<DefaultFeatureConfig> CHERRY_TREE_1 = new CherryTree(DefaultFeatureConfig.CODEC);
// Create the features
private static final Feature<DefaultFeatureConfig> 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<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.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();
}
}

View File

@ -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();
}
}

View File

@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "cherry:block/cherry_planks" }
}
}

View File

@ -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"
}

View File

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "cherry:block/cherry_planks"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "cherry:block/cherry_planks"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,13 @@
{
"type": "minecraft:crafting_shapeless",
"group": "planks",
"ingredients": [
{
"tag": "cherry:cherry_logs"
}
],
"result": {
"item": "cherry:cherry_planks",
"count": 4
}
}

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"cherry:cherry_log"
]
}

View File

@ -1,6 +1,6 @@
{
"replace": false,
"values": [
"#cherry:cherry_wood"
"#cherry:cherry_logs"
]
}

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"cherry:cherry_planks"
]
}

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"cherry:cherry_leaves"
]
}

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"#cherry:cherry_logs"
]
}

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"cherry:cherry_planks"
]
}