Added sweet apple trees

This commit is contained in:
Sollace 2022-09-25 15:39:07 +02:00
parent b2e3008141
commit 043a54eabf
35 changed files with 292 additions and 16 deletions

View file

@ -8,6 +8,7 @@ import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.EarthPonyKickAbility.Buckable;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.block.*;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
@ -46,6 +47,7 @@ public class FruitBearingBlock extends LeavesBlock implements TintedBlock, Bucka
this.fruit = fruit;
this.rottenFruitSupplier = rottenFruitSupplier;
REGISTRY.add(this);
FlammableBlockRegistry.getDefaultInstance().add(this, 30, 60);
}
@Override
@ -63,7 +65,7 @@ public class FruitBearingBlock extends LeavesBlock implements TintedBlock, Bucka
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
super.randomTick(state, world, pos, random);
if (shouldDecay(state)) {
if (shouldDecay(state) || state.get(PERSISTENT)) {
return;
}

View file

@ -4,6 +4,7 @@ import java.util.List;
import com.minelittlepony.unicopia.ability.EarthPonyKickAbility.Buckable;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.block.*;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
@ -29,10 +30,18 @@ public class FruitBlock extends Block implements Buckable {
}
public FruitBlock(Settings settings, Direction attachmentFace, Block stem, VoxelShape shape) {
this(settings, attachmentFace, stem, shape, true);
}
public FruitBlock(Settings settings, Direction attachmentFace, Block stem, VoxelShape shape, boolean flammable) {
super(settings.nonOpaque().suffocates(UBlocks::never).blockVision(UBlocks::never));
this.attachmentFace = attachmentFace;
this.stem = stem;
this.shape = shape;
if (flammable) {
FlammableBlockRegistry.getDefaultInstance().add(this, 20, 50);
}
}
@Override

View file

@ -8,7 +8,6 @@ import com.minelittlepony.unicopia.item.UItems;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.minecraft.block.*;
import net.minecraft.entity.EntityType;
@ -40,8 +39,8 @@ public interface UBlocks {
Block STRIPPED_ZAP_WOOD = register("stripped_zap_wood", new ZapAppleLogBlock(Blocks.STRIPPED_OAK_WOOD, MapColor.GRAY, MapColor.GRAY), ItemGroup.MATERIALS);
Block ZAP_LEAVES = register("zap_leaves", new ZapAppleLeavesBlock(), ItemGroup.DECORATIONS);
Block ZAP_BULB = register("zap_bulb", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GRAY).strength(500, 1200).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE));
Block ZAP_APPLE = register("zap_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GRAY).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE));
Block ZAP_BULB = register("zap_bulb", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GRAY).strength(500, 1200).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false));
Block ZAP_APPLE = register("zap_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GRAY).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false));
Block GREEN_APPLE_LEAVES = register("green_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES),
0xE5FFFF88,
@ -51,6 +50,14 @@ public interface UBlocks {
Block GREEN_APPLE = register("green_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, GREEN_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE));
Block GREEN_APPLE_SPROUT = register("green_apple_sprout", new SproutBlock(0xE5FFFF88, () -> UItems.GREEN_APPLE_SEEDS, () -> UTreeGen.GREEN_APPLE_TREE.sapling().map(Block::getDefaultState).get()));
Block SWEET_APPLE_LEAVES = register("sweet_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES),
0xE5FFCC88,
() -> UBlocks.SWEET_APPLE,
() -> UItems.SWEET_APPLE.getDefaultStack()
), ItemGroup.DECORATIONS);
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()));
static <T extends Block> T register(String name, T item) {
return register(Unicopia.id(name), item);
}
@ -77,8 +84,6 @@ public interface UBlocks {
static void bootstrap() {
StrippableBlockRegistry.register(ZAP_LOG, STRIPPED_ZAP_LOG);
StrippableBlockRegistry.register(ZAP_WOOD, STRIPPED_ZAP_WOOD);
FlammableBlockRegistry.getDefaultInstance().add(GREEN_APPLE_LEAVES, 30, 60);
FlammableBlockRegistry.getDefaultInstance().add(GREEN_APPLE, 20, 50);
}
static boolean never(BlockState state, BlockView world, BlockPos pos) {

View file

@ -32,6 +32,7 @@ public interface UTreeGen {
.count(0, 0.01F, 1)
.build();
Tree GREEN_APPLE_TREE = createAppleTree("green_apple", UBlocks.GREEN_APPLE_LEAVES);
Tree SWEET_APPLE_TREE = createAppleTree("sweet_apple", UBlocks.SWEET_APPLE_LEAVES);
static Tree createAppleTree(String name, Block leaves) {
return Tree.Builder.create(Unicopia.id(name + "_tree"),

View file

@ -80,6 +80,7 @@ public interface UItems {
Item ROCK_STEW = register("rock_stew", new Item(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.MUSHROOM_STEW)));
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 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)));

View file

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

View file

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

View file

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

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "unicopia:block/sweet_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

@ -58,6 +58,7 @@
"item.unicopia.weird_rock": "Weird Rock",
"item.unicopia.rock_stew": "Rock Stew",
"item.unicopia.green_apple_seeds": "Granny Smith Apple Seeds",
"item.unicopia.sweet_apple_seeds": "Sweet Apple Seeds",
"item.unicopia.daffodil_daisy_sandwich": "Daffodil Daisy Sandwich",
"item.unicopia.hay_burger": "Hay Burger",
@ -97,9 +98,13 @@
"block.unicopia.zap_leaves": "Zap Apple Leaves",
"block.unicopia.zap_apple": "Zap Apple",
"block.unicopia.zap_bulb": "Unripened Zap Apple",
"block.unicopia.green_apple_leaves": "Granny Smith Leaves",
"block.unicopia.green_apple_sapling": "Granny Smith Sapling",
"block.unicopia.green_apple_sprout": "Granny Smith Sprout",
"block.unicopia.sweet_apple_leaves": "Sweet Apple Leaves",
"block.unicopia.sweet_apple_sapling": "Sweet Apple Sapling",
"block.unicopia.sweet_apple_sprout": "Sweet Apple Sprout",
"entity.unicopia.butterfly": "Butterfly",
"entity.unicopia.twittermite": "Twittermite",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 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

@ -2,6 +2,7 @@
"replace": false,
"values": [
"unicopia:zap_leaves",
"unicopia:green_apple_leaves"
"unicopia:green_apple_leaves",
"unicopia:sweet_apple_leaves"
]
}

View file

@ -2,6 +2,7 @@
"replace": false,
"values": [
"unicopia:zap_leaves",
"unicopia:green_apple_leaves"
"unicopia:green_apple_leaves",
"unicopia:sweet_apple_leaves"
]
}

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:sweet_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:sweet_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:sweet_apple_sapling"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,7 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{ "item": "unicopia:sweet_apple" }
],
"result": { "item": "unicopia:sweet_apple_seeds", "count": 3 }
}

View file

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