Added sour apple trees

This commit is contained in:
Sollace 2022-09-25 16:23:10 +02:00
parent 043a54eabf
commit 81eff15912
28 changed files with 304 additions and 7 deletions

View file

@ -47,6 +47,7 @@ public record Tree (
private Optional<Predicate<BiomeSelectionContext>> selector = Optional.empty(); private Optional<Predicate<BiomeSelectionContext>> selector = Optional.empty();
private Optional<PlacementModifier> countModifier = Optional.empty(); private Optional<PlacementModifier> countModifier = Optional.empty();
private Optional<Supplier<TreeFeatureConfig.Builder>> configSupplier = Optional.empty(); private Optional<Supplier<TreeFeatureConfig.Builder>> configSupplier = Optional.empty();
private Optional<TwoLayersFeatureSize> size = Optional.empty();
private Builder(Identifier id, TrunkPlacer trunkPlacer, FoliagePlacer foliagePlacer) { private Builder(Identifier id, TrunkPlacer trunkPlacer, FoliagePlacer foliagePlacer) {
this.id = id; this.id = id;
@ -84,6 +85,11 @@ public record Tree (
return this; return this;
} }
public Builder farmingCondition(int yLevel, int sizeBelowY, int sizeAboveY) {
this.size = Optional.of(new TwoLayersFeatureSize(yLevel, Math.max(0, sizeBelowY), Math.max(0, sizeAboveY)));
return this;
}
public Tree build() { public Tree build() {
RegistryEntry<ConfiguredFeature<TreeFeatureConfig, ?>> configuredFeature = ConfiguredFeatures.register(id.toString(), Feature.TREE, configSupplier.map(Supplier::get) RegistryEntry<ConfiguredFeature<TreeFeatureConfig, ?>> configuredFeature = ConfiguredFeatures.register(id.toString(), Feature.TREE, configSupplier.map(Supplier::get)
.orElseGet(() -> new TreeFeatureConfig.Builder( .orElseGet(() -> new TreeFeatureConfig.Builder(
@ -91,7 +97,7 @@ public record Tree (
trunkPlacer, trunkPlacer,
BlockStateProvider.of(leavesType), BlockStateProvider.of(leavesType),
foliagePlacer, foliagePlacer,
new TwoLayersFeatureSize(6, 0, 16) size.get()
).forceDirt()).build()); ).forceDirt()).build());
Optional<Block> sapling = saplingId.map(id -> UBlocks.register(id, new SaplingBlock(new SaplingGenerator() { Optional<Block> sapling = saplingId.map(id -> UBlocks.register(id, new SaplingBlock(new SaplingGenerator() {

View file

@ -58,6 +58,14 @@ public interface UBlocks {
Block SWEET_APPLE = register("sweet_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, SWEET_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); Block SWEET_APPLE = register("sweet_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, SWEET_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE));
Block SWEET_APPLE_SPROUT = register("sweet_apple_sprout", new SproutBlock(0xE5FFCC88, () -> UItems.SWEET_APPLE_SEEDS, () -> UTreeGen.SWEET_APPLE_TREE.sapling().map(Block::getDefaultState).get())); Block SWEET_APPLE_SPROUT = register("sweet_apple_sprout", new SproutBlock(0xE5FFCC88, () -> UItems.SWEET_APPLE_SEEDS, () -> UTreeGen.SWEET_APPLE_TREE.sapling().map(Block::getDefaultState).get()));
Block SOUR_APPLE_LEAVES = register("sour_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES),
0xE5FFCCCC,
() -> UBlocks.SOUR_APPLE,
() -> UItems.SOUR_APPLE.getDefaultStack()
), ItemGroup.DECORATIONS);
Block SOUR_APPLE = register("sour_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, SOUR_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE));
Block SOUR_APPLE_SPROUT = register("sour_apple_sprout", new SproutBlock(0xE5FFCC88, () -> UItems.SOUR_APPLE_SEEDS, () -> UTreeGen.SOUR_APPLE_TREE.sapling().map(Block::getDefaultState).get()));
static <T extends Block> T register(String name, T item) { static <T extends Block> T register(String name, T item) {
return register(Unicopia.id(name), item); return register(Unicopia.id(name), item);
} }

View file

@ -30,15 +30,18 @@ public interface UTreeGen {
.sapling(Unicopia.id("zapling")) .sapling(Unicopia.id("zapling"))
.biomes(Tree.Builder.IS_FOREST) .biomes(Tree.Builder.IS_FOREST)
.count(0, 0.01F, 1) .count(0, 0.01F, 1)
.farmingCondition(6, 0, 8)
.build(); .build();
Tree GREEN_APPLE_TREE = createAppleTree("green_apple", UBlocks.GREEN_APPLE_LEAVES); Tree GREEN_APPLE_TREE = createAppleTree("green_apple", UBlocks.GREEN_APPLE_LEAVES, 2);
Tree SWEET_APPLE_TREE = createAppleTree("sweet_apple", UBlocks.SWEET_APPLE_LEAVES); Tree SWEET_APPLE_TREE = createAppleTree("sweet_apple", UBlocks.SWEET_APPLE_LEAVES, 3);
Tree SOUR_APPLE_TREE = createAppleTree("sour_apple", UBlocks.SOUR_APPLE_LEAVES, 5);
static Tree createAppleTree(String name, Block leaves) { static Tree createAppleTree(String name, Block leaves, int preferredDensity) {
return Tree.Builder.create(Unicopia.id(name + "_tree"), return Tree.Builder.create(Unicopia.id(name + "_tree"),
new StraightTrunkPlacer(4, 6, 2), new StraightTrunkPlacer(4, 6, 2),
new BlobFoliagePlacer(ConstantIntProvider.create(3), ConstantIntProvider.create(0), 3) new BlobFoliagePlacer(ConstantIntProvider.create(3), ConstantIntProvider.create(0), 3)
) )
.farmingCondition(1, preferredDensity - 2, preferredDensity)
.log(Blocks.OAK_LOG) .log(Blocks.OAK_LOG)
.leaves(leaves) .leaves(leaves)
.sapling(Unicopia.id(name + "_sapling")) .sapling(Unicopia.id(name + "_sapling"))

View file

@ -81,6 +81,7 @@ public interface UItems {
Item GREEN_APPLE_SEEDS = register("green_apple_seeds", new AliasedBlockItem(UBlocks.GREEN_APPLE_SPROUT, new Item.Settings().group(ItemGroup.MATERIALS))); Item GREEN_APPLE_SEEDS = register("green_apple_seeds", new AliasedBlockItem(UBlocks.GREEN_APPLE_SPROUT, new Item.Settings().group(ItemGroup.MATERIALS)));
Item SWEET_APPLE_SEEDS = register("sweet_apple_seeds", new AliasedBlockItem(UBlocks.SWEET_APPLE_SPROUT, new Item.Settings().group(ItemGroup.MATERIALS))); Item SWEET_APPLE_SEEDS = register("sweet_apple_seeds", new AliasedBlockItem(UBlocks.SWEET_APPLE_SPROUT, new Item.Settings().group(ItemGroup.MATERIALS)));
Item SOUR_APPLE_SEEDS = register("sour_apple_seeds", new AliasedBlockItem(UBlocks.SOUR_APPLE_SPROUT, new Item.Settings().group(ItemGroup.MATERIALS)));
Item MUG = register("mug", new Item(new Settings().group(ItemGroup.MATERIALS).maxCount(16))); Item MUG = register("mug", new Item(new Settings().group(ItemGroup.MATERIALS).maxCount(16)));
Item CIDER = register("cider", new DrinkableItem(new Item.Settings().group(ItemGroup.FOOD).food(UFoodComponents.CIDER).maxCount(1).recipeRemainder(MUG))); Item CIDER = register("cider", new DrinkableItem(new Item.Settings().group(ItemGroup.FOOD).food(UFoodComponents.CIDER).maxCount(1).recipeRemainder(MUG)));

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "unicopia:block/sour_apple"
}
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "unicopia:block/sour_apple_leaves"
}
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "unicopia:block/sour_apple_sapling"
}
}
}

View file

@ -0,0 +1,28 @@
{
"variants": {
"age=0": {
"model": "unicopia:block/apple_sprout_stage0"
},
"age=1": {
"model": "unicopia:block/apple_sprout_stage1"
},
"age=2": {
"model": "unicopia:block/apple_sprout_stage2"
},
"age=3": {
"model": "unicopia:block/apple_sprout_stage3"
},
"age=4": {
"model": "unicopia:block/apple_sprout_stage4"
},
"age=5": {
"model": "unicopia:block/apple_sprout_stage5"
},
"age=6": {
"model": "unicopia:block/apple_sprout_stage6"
},
"age=7": {
"model": "unicopia:block/apple_sprout_stage7"
}
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "unicopia:block/fruit",
"textures": {
"cross": "unicopia:item/sour_apple"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/leaves",
"textures": {
"all": "unicopia:block/sour_apple_leaves"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "unicopia:item/sour_apple_sapling"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "unicopia:block/sour_apple_leaves"
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "unicopia:item/sour_apple_sapling"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "unicopia:item/sour_apple_seeds"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -3,6 +3,7 @@
"values": [ "values": [
"unicopia:zap_leaves", "unicopia:zap_leaves",
"unicopia:green_apple_leaves", "unicopia:green_apple_leaves",
"unicopia:sweet_apple_leaves" "unicopia:sweet_apple_leaves",
"unicopia:sour_apple_leaves"
] ]
} }

View file

@ -3,6 +3,7 @@
"values": [ "values": [
"unicopia:zap_leaves", "unicopia:zap_leaves",
"unicopia:green_apple_leaves", "unicopia:green_apple_leaves",
"unicopia:sweet_apple_leaves" "unicopia:sweet_apple_leaves",
"unicopia:sour_apple_leaves"
] ]
} }

View file

@ -2,6 +2,7 @@
"replace": false, "replace": false,
"traits": "earth:2 life:1", "traits": "earth:2 life:1",
"items": [ "items": [
"minecraft:oak_leaves",
"minecraft:oak_planks", "minecraft:oak_planks",
"minecraft:oak_log", "minecraft:oak_log",
"minecraft:oak_wood", "minecraft:oak_wood",
@ -9,13 +10,15 @@
"minecraft:oak_fence", "minecraft:oak_fence",
"minecraft:oak_stairs", "minecraft:oak_stairs",
"minecraft:spruce_leaves",
"minecraft:spruce_planks", "minecraft:spruce_planks",
"minecraft:spruce_log", "minecraft:spruce_log",
"minecraft:spruce_wood", "minecraft:spruce_wood",
"minecraft:spruce_slab", "minecraft:spruce_slab",
"minecraft:spruce_fence", "minecraft:spruce_fence",
"minecraft:spruce_stairs", "minecraft:spruce_stairs",
"minecraft:birch_leaves",
"minecraft:birch_planks", "minecraft:birch_planks",
"minecraft:birch_log", "minecraft:birch_log",
"minecraft:birch_wood", "minecraft:birch_wood",
@ -23,6 +26,7 @@
"minecraft:birch_fence", "minecraft:birch_fence",
"minecraft:birch_stairs", "minecraft:birch_stairs",
"minecraft:jungle_leaves",
"minecraft:jungle_planks", "minecraft:jungle_planks",
"minecraft:jungle_log", "minecraft:jungle_log",
"minecraft:jungle_wood", "minecraft:jungle_wood",
@ -30,6 +34,7 @@
"minecraft:jungle_fence", "minecraft:jungle_fence",
"minecraft:jungle_stairs", "minecraft:jungle_stairs",
"minecraft:acacia_leaves",
"minecraft:acacia_planks", "minecraft:acacia_planks",
"minecraft:acacia_log", "minecraft:acacia_log",
"minecraft:acacia_wood", "minecraft:acacia_wood",

View file

@ -2,6 +2,7 @@
"replace": false, "replace": false,
"traits": "earth:2 life:1 darkness:1", "traits": "earth:2 life:1 darkness:1",
"items": [ "items": [
"minecraft:dark_oak_leaves",
"minecraft:dark_oak_planks", "minecraft:dark_oak_planks",
"minecraft:dark_oak_log", "minecraft:dark_oak_log",
"minecraft:dark_oak_stairs", "minecraft:dark_oak_stairs",

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:sour_apple"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,116 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:alternative",
"terms": [
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:shears"
]
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
]
}
],
"name": "unicopia:sour_apple_leaves"
}
]
}
],
"rolls": 1.0
},
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:alternative",
"terms": [
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:shears"
]
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
]
}
}
],
"entries": [
{
"type": "minecraft:item",
"conditions": [
{
"chances": [
0.02,
0.022222223,
0.025,
0.033333335,
0.1
],
"condition": "minecraft:table_bonus",
"enchantment": "minecraft:fortune"
}
],
"functions": [
{
"add": false,
"count": {
"type": "minecraft:uniform",
"max": 2.0,
"min": 1.0
},
"function": "minecraft:set_count"
},
{
"function": "minecraft:explosion_decay"
}
],
"name": "minecraft:stick"
}
],
"rolls": 1.0
}
]
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:sour_apple_sapling"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,7 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{ "item": "unicopia:sour_apple" }
],
"result": { "item": "unicopia:sour_apple_seeds", "count": 2 }
}

View file

@ -0,0 +1,9 @@
{
"replace": false,
"traits": "earth:2 life:1",
"items": [
"unicopia:green_apple_leaves",
"unicopia:sweet_apple_leaves",
"unicopia:sour_apple_leaves"
]
}

View file

@ -0,0 +1,11 @@
{
"replace": false,
"traits": "earth:2 life:1 chaos:3",
"items": [
"unicopia:zap_leaves",
"unicopia:zap_log",
"unicopia:stripped_zap_log",
"unicopia:zap_wood",
"unicopia:stripped_zap_wood"
]
}

View file

@ -0,0 +1,6 @@
{
"logs": [ "minecraft:oak_log", "minecraft:oak_wood" ],
"leaves": [ "unicopia:sour_apple_leaves" ],
"wideTrunk": false,
"drops": []
}