2021-09-02 19:11:51 +02:00
|
|
|
package com.minelittlepony.unicopia.block;
|
|
|
|
|
2022-09-25 01:55:29 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2022-08-27 15:14:00 +02:00
|
|
|
import com.minelittlepony.unicopia.Unicopia;
|
2022-09-25 00:14:29 +02:00
|
|
|
import com.minelittlepony.unicopia.item.UItems;
|
2022-08-27 15:14:00 +02:00
|
|
|
|
2021-09-02 19:11:51 +02:00
|
|
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|
|
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder;
|
2022-09-25 00:14:29 +02:00
|
|
|
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
|
|
|
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
|
2022-09-23 23:25:00 +02:00
|
|
|
import net.minecraft.block.*;
|
|
|
|
import net.minecraft.entity.EntityType;
|
2022-09-25 00:14:29 +02:00
|
|
|
import net.minecraft.item.*;
|
2021-09-02 19:11:51 +02:00
|
|
|
import net.minecraft.sound.BlockSoundGroup;
|
2022-09-25 00:14:29 +02:00
|
|
|
import net.minecraft.util.Identifier;
|
2022-09-23 23:25:00 +02:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.Direction;
|
2021-09-02 19:11:51 +02:00
|
|
|
import net.minecraft.util.registry.Registry;
|
2022-09-23 23:25:00 +02:00
|
|
|
import net.minecraft.world.BlockView;
|
2021-09-02 19:11:51 +02:00
|
|
|
|
|
|
|
public interface UBlocks {
|
2022-09-25 01:55:29 +02:00
|
|
|
List<Block> TRANSLUCENT_BLOCKS = new ArrayList<>();
|
|
|
|
|
2021-09-02 19:11:51 +02:00
|
|
|
Block ROCKS = register("rocks", new RockCropBlock(FabricBlockSettings.of(
|
|
|
|
new FabricMaterialBuilder(MapColor.STONE_GRAY).allowsMovement().lightPassesThrough().notSolid().destroyedByPiston().build()
|
|
|
|
)
|
2021-09-03 00:47:48 +02:00
|
|
|
.requiresTool()
|
2021-09-02 19:11:51 +02:00
|
|
|
.ticksRandomly()
|
|
|
|
.strength(2)
|
|
|
|
.sounds(BlockSoundGroup.STONE)));
|
|
|
|
|
2021-12-31 13:54:51 +01:00
|
|
|
Block FROSTED_OBSIDIAN = register("frosted_obsidian", new FrostedObsidianBlock(FabricBlockSettings.copy(Blocks.OBSIDIAN).ticksRandomly()));
|
|
|
|
|
2022-09-25 00:14:29 +02:00
|
|
|
Block ZAP_LOG = register("zap_log", new ZapAppleLogBlock(Blocks.OAK_LOG, MapColor.GRAY, MapColor.DEEPSLATE_GRAY), ItemGroup.MATERIALS);
|
2022-09-25 01:55:29 +02:00
|
|
|
Block ZAP_WOOD = register("zap_wood", new ZapAppleLogBlock(Blocks.OAK_WOOD, MapColor.DEEPSLATE_GRAY, MapColor.DEEPSLATE_GRAY), ItemGroup.MATERIALS);
|
2022-09-25 00:14:29 +02:00
|
|
|
|
|
|
|
Block STRIPPED_ZAP_LOG = register("stripped_zap_log", new ZapAppleLogBlock(Blocks.STRIPPED_OAK_LOG, MapColor.LIGHT_GRAY, MapColor.GRAY), ItemGroup.MATERIALS);
|
2022-09-25 01:55:29 +02:00
|
|
|
Block STRIPPED_ZAP_WOOD = register("stripped_zap_wood", new ZapAppleLogBlock(Blocks.STRIPPED_OAK_WOOD, MapColor.GRAY, MapColor.GRAY), ItemGroup.MATERIALS);
|
2022-09-23 23:25:00 +02:00
|
|
|
|
2022-09-25 00:14:29 +02:00
|
|
|
Block ZAP_LEAVES = register("zap_leaves", new ZapAppleLeavesBlock(), ItemGroup.DECORATIONS);
|
2022-09-23 23:25:00 +02:00
|
|
|
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));
|
|
|
|
|
2022-09-25 00:14:29 +02:00
|
|
|
Block GREEN_APPLE_LEAVES = register("green_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES),
|
|
|
|
0xE5FFFF88,
|
|
|
|
() -> UBlocks.GREEN_APPLE,
|
|
|
|
() -> UItems.GREEN_APPLE.getDefaultStack()
|
|
|
|
), ItemGroup.DECORATIONS);
|
|
|
|
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));
|
2022-09-25 01:55:29 +02:00
|
|
|
Block GREEN_APPLE_SPROUT = register("green_apple_sprout", new SproutBlock(0xE5FFFF88, () -> UItems.GREEN_APPLE_SEEDS, () -> UTreeGen.GREEN_APPLE_TREE.sapling().map(Block::getDefaultState).get()));
|
2022-09-25 00:14:29 +02:00
|
|
|
|
|
|
|
static <T extends Block> T register(String name, T item) {
|
|
|
|
return register(Unicopia.id(name), item);
|
|
|
|
}
|
|
|
|
|
|
|
|
static <T extends Block> T register(String name, T block, ItemGroup group) {
|
|
|
|
return register(Unicopia.id(name), block, group);
|
2021-09-02 19:11:51 +02:00
|
|
|
}
|
|
|
|
|
2022-09-25 00:14:29 +02:00
|
|
|
static <T extends Block> T register(Identifier id, T block, ItemGroup group) {
|
|
|
|
UItems.register(id, new BlockItem(block, new Item.Settings().group(group)));
|
|
|
|
return register(id, block);
|
|
|
|
}
|
2022-09-23 23:25:00 +02:00
|
|
|
|
2022-09-25 00:14:29 +02:00
|
|
|
static <T extends Block> T register(Identifier id, T block) {
|
|
|
|
if (block instanceof TintedBlock) {
|
|
|
|
TintedBlock.REGISTRY.add(block);
|
|
|
|
}
|
2022-09-25 01:55:29 +02:00
|
|
|
if (block instanceof SaplingBlock || block instanceof SproutBlock || block instanceof FruitBlock) {
|
|
|
|
TRANSLUCENT_BLOCKS.add(block);
|
|
|
|
}
|
2022-09-25 00:14:29 +02:00
|
|
|
return Registry.register(Registry.BLOCK, id, block);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2022-09-23 23:25:00 +02:00
|
|
|
|
|
|
|
static boolean never(BlockState state, BlockView world, BlockPos pos) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Boolean canSpawnOnLeaves(BlockState state, BlockView world, BlockPos pos, EntityType<?> type) {
|
|
|
|
return type == EntityType.OCELOT || type == EntityType.PARROT;
|
|
|
|
}
|
2021-09-02 19:11:51 +02:00
|
|
|
}
|