Compare commits

...

12 Commits

Author SHA1 Message Date
71b835b66e added ore generation 2025-06-09 14:19:35 +02:00
6ca6b35be4 added deepslate ruby ore 2025-06-09 12:06:44 +02:00
291d46b4e6 stub recipe 2025-05-28 17:27:41 +02:00
6867bbdc4d added block state property 2025-04-18 15:41:09 +02:00
1cff2526b9 custom food 2025-04-06 17:53:36 +02:00
f516aba128 adding custom item 2025-04-06 17:33:48 +02:00
075f2d718f added recipes and loot tables 2025-03-09 18:02:03 +01:00
d10a6df9e7 added ruby ore 2025-03-09 16:40:53 +01:00
61f495acd3 first block 2025-03-09 16:05:21 +01:00
2e885ab8bd added rubyball 2025-01-04 18:26:23 +01:00
bd1d872a52 custom items 2025-01-03 22:59:02 +01:00
61bf4a2d2a setup 2025-01-03 22:16:38 +01:00
49 changed files with 590 additions and 34 deletions

View File

@ -9,8 +9,8 @@ yarn_mappings=1.21.4+build.4
loader_version=0.16.9
# Mod Properties
mod_version=1.0.0
maven_group=de.jottyfan.gta.dgp
mod_version=0.0.1
maven_group=de.jottyfan.gta.gdp
archives_base_name=gtagdp
# Dependencies

View File

@ -1,24 +0,0 @@
package de.jottyfan.gta.dgp;
import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GTAGDP implements ModInitializer {
public static final String MOD_ID = "gtagdp";
// 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!");
}
}

View File

@ -0,0 +1,26 @@
package de.jottyfan.gta.gdp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.jottyfan.gta.gdp.block.ModBlocks;
import de.jottyfan.gta.gdp.item.ModItems;
import de.jottyfan.gta.gdp.world.gen.ModOreGeneration;
import net.fabricmc.api.ModInitializer;
/**
*
* @author jotty
*
*/
public class GTAGDP implements ModInitializer {
public static final String MOD_ID = "gtagdp";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
@Override
public void onInitialize() {
ModItems.registerModItems();
ModBlocks.registerModBlocks();
ModOreGeneration.generateOres();
}
}

View File

@ -0,0 +1,14 @@
package de.jottyfan.gta.gdp;
import net.fabricmc.api.ClientModInitializer;
/**
*
* @author jotty
*
*/
public class GTAGDPClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
}
}

View File

@ -0,0 +1,58 @@
package de.jottyfan.gta.gdp.block;
import de.jottyfan.gta.gdp.GTAGDP;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
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.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
/**
*
* @author jotty
*
*/
public class ModBlocks {
public static final Block RUBY_BLOCK = registerRubyBlock(Identifier.of(GTAGDP.MOD_ID, "ruby_block"),
AbstractBlock.Settings.create().strength(4f).requiresTool().sounds(BlockSoundGroup.AMETHYST_BLOCK)
.luminance(state -> state.get(RubyBlock.ACTIVATED) ? 15 : 0));
public static final Block RUBY_ORE = registerBlock(Identifier.of(GTAGDP.MOD_ID, "ruby_ore"),
AbstractBlock.Settings.create().strength(3f).requiresTool());
public static final Block RUBY_DEEPSLATE_ORE = registerBlock(Identifier.of(GTAGDP.MOD_ID, "ruby_deepslate_ore"),
AbstractBlock.Settings.create().strength(3f).requiresTool());
private static Block registerRubyBlock(Identifier identifier, Block.Settings settings) {
Block block = new RubyBlock(settings.registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
registerBlockItem(identifier, block, new Item.Settings());
return Registry.register(Registries.BLOCK, identifier, block);
}
private static Block registerBlock(Identifier identifier, Block.Settings settings) {
Block block = new Block(settings.registryKey(RegistryKey.of(RegistryKeys.BLOCK, identifier)));
registerBlockItem(identifier, block, new Item.Settings());
return Registry.register(Registries.BLOCK, identifier, block);
}
private static void registerBlockItem(Identifier identifier, Block block, Item.Settings settings) {
Registry.register(Registries.ITEM, identifier, new BlockItem(block,
settings.useBlockPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier))));
}
public static void registerModBlocks() {
GTAGDP.LOGGER.info("Registering Mod Blocks for {}", GTAGDP.MOD_ID);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(entries -> {
entries.add(RUBY_BLOCK);
entries.add(RUBY_ORE);
entries.add(RUBY_DEEPSLATE_ORE);
});
}
}

View File

@ -0,0 +1,39 @@
package de.jottyfan.gta.gdp.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.StateManager.Builder;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class RubyBlock extends Block {
public static final BooleanProperty ACTIVATED = BooleanProperty.of("activated");
public RubyBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(ACTIVATED, false));
}
@Override
protected void appendProperties(Builder<Block, BlockState> builder) {
builder.add(ACTIVATED);
}
@Override
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
if (!world.isClient()) {
world.setBlockState(pos, state.cycle(ACTIVATED));
}
return ActionResult.SUCCESS;
}
}

View File

@ -0,0 +1,14 @@
package de.jottyfan.gta.gdp.item;
import net.minecraft.component.type.FoodComponent;
/**
*
* @author jotty
*
*/
public class ModFoodComponents {
public static final FoodComponent DELICIOUS_STUB = new FoodComponent.Builder().nutrition(1).saturationModifier(0.1f)
.build();
}

View File

@ -0,0 +1,45 @@
package de.jottyfan.gta.gdp.item;
import de.jottyfan.gta.gdp.GTAGDP;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.Item;
import net.minecraft.item.Item.Settings;
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;
/**
*
* @author jotty
*
*/
public class ModItems {
public static final Item STUB = registerStubItem(
Identifier.of(GTAGDP.MOD_ID, "stub"),
new Item.Settings().food(ModFoodComponents.DELICIOUS_STUB));
public static final Item RUBYBALL = registerItem(Identifier.of(GTAGDP.MOD_ID, "rubyball"), new Item.Settings());
private static Item registerItem(Identifier identifier, Settings settings) {
return Registry.register(Registries.ITEM, identifier,
new Item(settings.useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier))));
}
private static Item registerStubItem(Identifier identifier, Settings settings) {
return Registry.register(Registries.ITEM, identifier, new StubItem(
settings.useItemPrefixedTranslationKey().registryKey(RegistryKey.of(RegistryKeys.ITEM, identifier))));
}
public static void registerModItems() {
GTAGDP.LOGGER.info("registering mod items for " + GTAGDP.MOD_ID);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(entries -> {
entries.add(STUB);
entries.add(RUBYBALL);
});
}
}

View File

@ -0,0 +1,58 @@
package de.jottyfan.gta.gdp.item;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.item.Items;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
*
* @author jotty
*
*/
public class StubItem extends Item {
private static final Map<Block, Item> SLASH_MAP = Map.of(
Blocks.HAY_BLOCK, Items.WHEAT,
Blocks.DRIED_KELP_BLOCK, Items.DRIED_KELP);
public StubItem(Settings settings) {
super(settings);
}
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
World world = context.getWorld();
BlockPos pos = context.getBlockPos();
Block clickedBlock = world.getBlockState(pos).getBlock();
if (SLASH_MAP.containsKey(clickedBlock)) {
if (!world.isClient()) {
world.setBlockState(pos, Blocks.AIR.getDefaultState());
world.playSound(null, pos, SoundEvents.ITEM_HOE_TILL,
SoundCategory.BLOCKS);
for (int i = 0; i < 9; i++) {
ItemStack stack = new ItemStack(SLASH_MAP.get(clickedBlock));
float xScatter = new Random().nextFloat();
float yScatter = new Random().nextFloat();
ItemEntity entity = new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(),
stack, xScatter, yScatter, 0.2);
world.spawnEntity(entity);
}
}
}
return ActionResult.SUCCESS;
}
}

View File

@ -1,4 +1,4 @@
package de.jottyfan.gta.dgp.mixin;
package de.jottyfan.gta.gdp.mixin;
import net.minecraft.server.MinecraftServer;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -0,0 +1,19 @@
package de.jottyfan.gta.gdp.world;
import de.jottyfan.gta.gdp.GTAGDP;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.feature.ConfiguredFeature;
/**
* @author jotty
*/
public class ModConfiguredFeatures {
public static final RegistryKey<ConfiguredFeature<?, ?>> RUBY_ORE_CF = registerKey("ruby_ore_cf");
public static RegistryKey<ConfiguredFeature<?, ?>> registerKey(String name) {
return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, Identifier.of(GTAGDP.MOD_ID, name));
}
}

View File

@ -0,0 +1,19 @@
package de.jottyfan.gta.gdp.world;
import de.jottyfan.gta.gdp.GTAGDP;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.feature.PlacedFeature;
/**
* @author jotty
*/
public class ModPlacedFeatures {
public static final RegistryKey<PlacedFeature> RUBY_ORE_PF = registerKey("ruby_ore_pf");
public static RegistryKey<PlacedFeature> registerKey(String name) {
return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier.of(GTAGDP.MOD_ID, name));
}
}

View File

@ -0,0 +1,16 @@
package de.jottyfan.gta.gdp.world.gen;
import de.jottyfan.gta.gdp.world.ModPlacedFeatures;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.minecraft.world.gen.GenerationStep;
/**
* @author jotty
*/
public class ModOreGeneration {
public static void generateOres() {
BiomeModifications.addFeature(BiomeSelectors.foundInOverworld(), GenerationStep.Feature.UNDERGROUND_ORES,
ModPlacedFeatures.RUBY_ORE_PF);
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "gtagdp:block/ruby_block"
}
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "gtagdp:block/ruby_deepslate_ore"
}
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "gtagdp:block/ruby_ore"
}
}
}

View File

@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "gtagdp:block/ruby_block"
}
}

View File

@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "gtagdp:block/ruby_deepslate_ore"
}
}

View File

@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "gtagdp:block/ruby_ore"
}
}

View File

@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "gtagdp:item/rubyball"
}
}

View File

@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "gtagdp:item/stub"
}
}

View File

@ -0,0 +1,8 @@
{
"item.gtagdp.stub": "Stummel",
"item.gtagdp.rubyball": "Rubinball",
"block.gtagdp.ruby_block": "Rubinblock",
"block.gtagdp.ruby_ore": "Rubinerz",
"block.gtagdp.ruby_deepslate_ore": "Rubinerzklumpen"
}

View File

@ -0,0 +1,8 @@
{
"item.gtagdp.stub": "Stub",
"item.gtagdp.rubyball": "Ruby ball",
"block.gtagdp.ruby_block": "Ruby block",
"block.gtagdp.ruby_ore": "Ruby ore",
"block.gtagdp.ruby_deepslate_ore": "Ruby ore lump"
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "gtagdp:block/ruby_block"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "gtagdp:block/ruby_deepslate_ore"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "gtagdp:block/ruby_ore"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "gtagdp:block/ruby_block"
}

View File

@ -0,0 +1,3 @@
{
"parent": "gtagdp:block/ruby_deepslate_ore"
}

View File

@ -0,0 +1,3 @@
{
"parent": "gtagdp:block/ruby_ore"
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "gtagdp:item/rubyball"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "gtagdp:item/stub"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

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

View File

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

View File

@ -0,0 +1,9 @@
{
"type": "minecraft:blasting",
"ingredient": "gtagdp:ruby_ore",
"result": {
"id": "gtagdp:rubyball"
},
"experience": 0.1,
"cookingtime": 200
}

View File

@ -0,0 +1,9 @@
{
"type": "minecraft:campfire_cooking",
"ingredient": "gtagdp:stub",
"result": {
"id": "minecraft:torch"
},
"experience": 0.1,
"cookingtime": 20
}

View File

@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"###",
"###",
"###"
],
"key": {
"#": "gtagdp:rubyball"
},
"result": {
"id": "gtagdp:ruby_block",
"count": 1
}
}

View File

@ -0,0 +1,10 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
"gtagdp:ruby_block"
],
"result": {
"id": "gtagdp:rubyball",
"count": 9
}
}

View File

@ -0,0 +1,10 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
"minecraft:stick"
],
"result": {
"id": "gtagdp:stub",
"count": 4
}
}

View File

@ -0,0 +1,27 @@
{
"type": "minecraft:ore",
"config": {
"discard_chance_on_air_exposure": 0.0,
"size": 20,
"targets": [
{
"state": {
"Name": "gtagdp:ruby_ore"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:stone_ore_replaceables"
}
},
{
"state": {
"Name": "gtagdp:ruby_deepslate_ore"
},
"target": {
"predicate_type": "minecraft:tag_match",
"tag": "minecraft:deepslate_ore_replaceables"
}
}
]
}
}

View File

@ -0,0 +1,27 @@
{
"feature": "gtagdp:ruby_ore_cf",
"placement": [
{
"type": "minecraft:count",
"count": 16
},
{
"type": "minecraft:in_square"
},
{
"type": "minecraft:height_range",
"height": {
"type": "minecraft:trapezoid",
"max_inclusive": {
"absolute": 80
},
"min_inclusive": {
"absolute": -80
}
}
},
{
"type": "minecraft:biome"
}
]
}

View File

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"gtagdp:ruby_block",
"gtagdp:ruby_ore",
"gtagdp:ruby_deepslate_ore"
]
}

View File

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"gtagdp:ruby_block",
"gtagdp:ruby_ore",
"gtagdp:ruby_deepslate_ore"
]
}

View File

@ -3,20 +3,23 @@
"id": "gtagdp",
"version": "${version}",
"name": "GTAGDP",
"description": "This is an example description! Tell everyone what your mod is about!",
"description": "The reference repository for the Minecraft Fabric Mod Development GTA",
"authors": [
"Me!"
"jotty"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
"homepage": "https://git.jottyfan.de/GTA_Minecraft_Fabric_Mod_Development/GTAGDP",
"sources": "https://git.jottyfan.de/GTA_Minecraft_Fabric_Mod_Development/GTAGDP"
},
"license": "CC0-1.0",
"license": "GNU AFFERO GENERAL PUBLIC LICENSE",
"icon": "assets/gtagdp/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"de.jottyfan.gta.dgp.GTAGDP"
"de.jottyfan.gta.gdp.GTAGDP"
],
"client": [
"de.jottyfan.gta.gdp.GTAGDPClient"
]
},
"mixins": [

View File

@ -1,6 +1,6 @@
{
"required": true,
"package": "de.jottyfan.gta.dgp.mixin",
"package": "de.jottyfan.gta.gdp.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
"ExampleMixin"