Created Test Block & DataGen
This commit is contained in:
@ -0,0 +1,2 @@
|
||||
// 1.21.5 -999999999-01-01T00:00:00 SurvivalEnhanced/Block Loot Tables
|
||||
6d3d52fa8e565a8270b6ed73f2d41c45eb8f8ae1 data/survivalenhanced/loot_table/blocks/test_block.json
|
@ -0,0 +1 @@
|
||||
// 1.21.5 -999999999-01-01T00:00:00 SurvivalEnhanced/Tags for minecraft:item
|
@ -0,0 +1,2 @@
|
||||
// 1.21.5 -999999999-01-01T00:00:00 SurvivalEnhanced/Tags for minecraft:block
|
||||
5bfebfdb385a11ef08214d202811caf3d2ece770 data/minecraft/tags/block/mineable/pickaxe.json
|
@ -0,0 +1,4 @@
|
||||
// 1.21.5 -999999999-01-01T00:00:00 SurvivalEnhanced/Model Definitions
|
||||
8a4568413ceea79afb6cd12a04d134475dc0a5dd assets/survivalenhanced/blockstates/test_block.json
|
||||
4bf1b27ded399c3be7cd77d2c4687ea7771cd9eb assets/survivalenhanced/items/test_block.json
|
||||
2c21fa4746f154853402115ecd8a85816b163592 assets/survivalenhanced/models/block/test_block.json
|
@ -0,0 +1,2 @@
|
||||
// 1.21.5 -999999999-01-01T00:00:00 SurvivalEnhanced/Language (en_us)
|
||||
f92cdd9c2f07e8456fcc5d8040adfbcc626bbdcb assets/survivalenhanced/lang/en_us.json
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "survivalenhanced:block/test_block"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "survivalenhanced:block/test_block"
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"item.survivalenhanced.test_block": "Test Block"
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:block/cube_all",
|
||||
"textures": {
|
||||
"all": "survivalenhanced:block/test_block"
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"values": [
|
||||
"survivalenhanced:test_block"
|
||||
]
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"bonus_rolls": 0.0,
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
],
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "survivalenhanced:test_block"
|
||||
}
|
||||
],
|
||||
"rolls": 1.0
|
||||
}
|
||||
]
|
||||
}
|
@ -4,21 +4,15 @@ import net.fabricmc.api.ModInitializer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import wtf.hak.blocks.ModBlocks;
|
||||
|
||||
public class SurvivalEnhanced implements ModInitializer {
|
||||
public static final String MOD_ID = "survivalenhanced";
|
||||
|
||||
// This logger is used to write text to the console and the log file.
|
||||
// It is considered best practice to use your mod id as the logger's name.
|
||||
// That way, it's clear which mod wrote info, warnings, and errors.
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||
// However, some things (like resources) may still be uninitialized.
|
||||
// Proceed with mild caution.
|
||||
|
||||
LOGGER.info("Hello Fabric world!");
|
||||
ModBlocks.registerBlocks();
|
||||
}
|
||||
}
|
62
src/main/java/wtf/hak/blocks/ModBlocks.java
Normal file
62
src/main/java/wtf/hak/blocks/ModBlocks.java
Normal file
@ -0,0 +1,62 @@
|
||||
package wtf.hak.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ChestBlock;
|
||||
import net.minecraft.block.TestBlock;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroups;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
import wtf.hak.SurvivalEnhanced;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ModBlocks {
|
||||
|
||||
public static Block TEST_BLOCK;
|
||||
|
||||
private static Block register(String name, Function<AbstractBlock.Settings, Block> blockFactory, AbstractBlock.Settings settings, boolean shouldRegisterItem) {
|
||||
// Create a registry key for the block
|
||||
RegistryKey<Block> blockKey = keyOfBlock(name);
|
||||
// Create the block instance
|
||||
Block block = blockFactory.apply(settings.registryKey(blockKey));
|
||||
|
||||
// Sometimes, you may not want to register an item for the block.
|
||||
// Eg: if it's a technical block like `minecraft:moving_piston` or `minecraft:end_gateway`
|
||||
if (shouldRegisterItem) {
|
||||
// Items need to be registered with a different type of registry key, but the ID
|
||||
// can be the same.
|
||||
RegistryKey<Item> itemKey = keyOfItem(name);
|
||||
|
||||
BlockItem blockItem = new BlockItem(block, new Item.Settings().registryKey(itemKey));
|
||||
Registry.register(Registries.ITEM, itemKey, blockItem);
|
||||
}
|
||||
|
||||
return Registry.register(Registries.BLOCK, blockKey, block);
|
||||
}
|
||||
|
||||
private static RegistryKey<Block> keyOfBlock(String name) {
|
||||
return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(SurvivalEnhanced.MOD_ID, name));
|
||||
}
|
||||
|
||||
private static RegistryKey<Item> keyOfItem(String name) {
|
||||
return RegistryKey.of(RegistryKeys.ITEM, Identifier.of(SurvivalEnhanced.MOD_ID, name));
|
||||
}
|
||||
|
||||
public static void registerBlocks(){
|
||||
TEST_BLOCK = register("test_block",
|
||||
TestBlock::new,
|
||||
AbstractBlock.Settings.create().strength(1f).requiresTool(),
|
||||
true);
|
||||
|
||||
ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(entries -> entries.add(TEST_BLOCK));
|
||||
}
|
||||
|
||||
}
|
10
src/main/java/wtf/hak/blocks/TestBlock.java
Normal file
10
src/main/java/wtf/hak/blocks/TestBlock.java
Normal file
@ -0,0 +1,10 @@
|
||||
package wtf.hak.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class TestBlock extends Block {
|
||||
|
||||
public TestBlock(Settings settings) {
|
||||
super(settings);
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 269 B |
Reference in New Issue
Block a user