Compare commits
5 Commits
c6be33d99c
...
main
Author | SHA1 | Date | |
---|---|---|---|
b3515c1e07 | |||
db7efdf7ba | |||
bcdb41d6ac | |||
14e11bd458 | |||
877f0378a7 |
@@ -65,6 +65,10 @@ jar {
|
||||
}
|
||||
}
|
||||
|
||||
//tasks.withType(Copy).all {
|
||||
// duplicatesStrategy 'exclude'
|
||||
//}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
|
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "learning:block/damage_block"
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "learning:block/transform_block"
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "learning:item/overcooked_toast"
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/cube_bottom_top",
|
||||
"textures": {
|
||||
"bottom": "learning:block/white_block_bottom",
|
||||
"side": "learning:block/damage_block_side",
|
||||
"top": "learning:block/damage_block_top"
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"parent": "minecraft:block/cube_bottom_top",
|
||||
"textures": {
|
||||
"bottom": "learning:block/white_block_bottom",
|
||||
"side": "learning:block/transform_block_side",
|
||||
"top": "learning:block/transform_block_top"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "learning:item/baked_toast"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "learning:item/overcooked_toast"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "learning:item/toast"
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "minecraft:baked_toast_from_smelting_toast"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
},
|
||||
"has_toast": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "learning:toast"
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_the_recipe",
|
||||
"has_toast"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"minecraft:baked_toast_from_smelting_toast"
|
||||
]
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_baked_toast": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "learning:baked_toast"
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "minecraft:overcooked_toast_from_smelting_baked_toast"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_the_recipe",
|
||||
"has_baked_toast"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"minecraft:overcooked_toast_from_smelting_baked_toast"
|
||||
]
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_iron_sword": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "minecraft:iron_sword"
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "learning:damage_block"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_the_recipe",
|
||||
"has_iron_sword"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"learning:damage_block"
|
||||
]
|
||||
}
|
||||
}
|
@@ -16,6 +16,5 @@
|
||||
],
|
||||
"rolls": 1.0
|
||||
}
|
||||
],
|
||||
"random_sequence": "learning:blocks/damage_block"
|
||||
]
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"bonus_rolls": 0.0,
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
],
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "learning:transform_block"
|
||||
}
|
||||
],
|
||||
"rolls": 1.0
|
||||
}
|
||||
]
|
||||
}
|
@@ -3,6 +3,7 @@
|
||||
"category": "food",
|
||||
"cookingtime": 200,
|
||||
"experience": 0.35,
|
||||
"group": "toast_furnace",
|
||||
"ingredient": "learning:toast",
|
||||
"result": {
|
||||
"id": "learning:baked_toast"
|
18
src/main/generated/data/learning/recipe/damage_block.json
Normal file
18
src/main/generated/data/learning/recipe/damage_block.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "misc",
|
||||
"key": {
|
||||
"B": "minecraft:iron_block",
|
||||
"R": "minecraft:red_dye",
|
||||
"S": "minecraft:iron_sword"
|
||||
},
|
||||
"pattern": [
|
||||
"SSS",
|
||||
"BRB",
|
||||
"BBB"
|
||||
],
|
||||
"result": {
|
||||
"count": 4,
|
||||
"id": "learning:damage_block"
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"type": "minecraft:smelting",
|
||||
"category": "misc",
|
||||
"cookingtime": 200,
|
||||
"experience": 0.35,
|
||||
"group": "toast_furnace",
|
||||
"ingredient": "learning:baked_toast",
|
||||
"result": {
|
||||
"id": "learning:overcooked_toast"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"values": [
|
||||
"minecraft:diamond",
|
||||
"learning:baked_toast"
|
||||
]
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"values": [
|
||||
"learning:damage_block"
|
||||
]
|
||||
}
|
@@ -3,6 +3,8 @@ package com.learning;
|
||||
import com.learning.block.CustomBlocks;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistryEvents;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -27,5 +29,14 @@ public class Learning implements ModInitializer {
|
||||
CustomBlocks.registerBlocks();
|
||||
CustomItems.registerItems();
|
||||
CustomItemGroup.registerItemGroup();
|
||||
|
||||
LOGGER.info("Adding Fuel registries...");
|
||||
FuelRegistryEvents.BUILD.register(((builder, context) -> {
|
||||
builder.add(CustomItems.OVERCOOKED_TOAST, 6000);
|
||||
}));
|
||||
|
||||
LOGGER.info("Adding Compostable registries...");
|
||||
CompostingChanceRegistry.INSTANCE.add(CustomItems.TOAST, 0.3f);
|
||||
CompostingChanceRegistry.INSTANCE.add(CustomItems.BAKED_TOAST, 0.5f);
|
||||
}
|
||||
}
|
||||
|
12
src/main/java/com/learning/LearningClient.java
Normal file
12
src/main/java/com/learning/LearningClient.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.learning;
|
||||
|
||||
import com.learning.block.CustomBlocks;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
|
||||
public class LearningClient implements ClientModInitializer {
|
||||
public void onInitializeClient() {
|
||||
BlockRenderLayerMap.INSTANCE.putBlock(CustomBlocks.DENSITY_GLASS_DOOR, RenderLayer.getCutout());
|
||||
}
|
||||
}
|
@@ -1,11 +1,17 @@
|
||||
package com.learning;
|
||||
|
||||
import com.learning.datagen.*;
|
||||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
|
||||
public class LearningDataGenerator implements DataGeneratorEntrypoint {
|
||||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
|
||||
|
||||
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
|
||||
pack.addProvider(ModModelProvider::new);
|
||||
pack.addProvider(ModRecipeProvider::new);
|
||||
pack.addProvider(ModItemTagProvider::new);
|
||||
pack.addProvider(ModBlockTagProvider::new);
|
||||
pack.addProvider(ModLootTableProvider::new);
|
||||
}
|
||||
}
|
||||
|
@@ -2,14 +2,14 @@ package com.learning.block;
|
||||
|
||||
import com.learning.Learning;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class CustomBlocks {
|
||||
@@ -17,21 +17,50 @@ public class CustomBlocks {
|
||||
Learning.LOGGER.info("Registering blocks...");
|
||||
}
|
||||
|
||||
public static final Block testBlock = register("test_block");
|
||||
public static final Block damageBlock = register("damage_block", DamageBlock::new, AbstractBlock.Settings.create());
|
||||
public static final Block transformBlock = register("transform_block", TransformBlock::new, AbstractBlock.Settings.create());
|
||||
public static final Block TEST_BLOCK = register("test_block");
|
||||
public static final Block DAMAGE_BLOCK = register("damage_block", DamageBlock::new, AbstractBlock.Settings.create().requiresTool());
|
||||
public static final Block TRANSFORM_BLOCK = register("transform_block", TransformBlock::new);
|
||||
public static final Block DENSITY_GLASS = register("density_glass");
|
||||
|
||||
public static final Block register(String blockId) {
|
||||
return register(blockId, Block::new, AbstractBlock.Settings.create());
|
||||
public static final Block DENSITY_GLASS_STAIRS = register("density_glass_stairs", StairsBlock::new,
|
||||
DENSITY_GLASS.getDefaultState(), AbstractBlock.Settings.create().requiresTool().strength(2f));
|
||||
public static final Block DENSITY_GLASS_FENCE = register("density_glass_fence", FenceBlock::new, AbstractBlock.Settings.create().requiresTool().strength(2f));
|
||||
public static final Block DENSITY_GLASS_FENCE_GATE = register("density_glass_gate", FenceGateBlock::new,
|
||||
WoodType.OAK, AbstractBlock.Settings.create().requiresTool().strength(2f));
|
||||
public static final Block DENSITY_GLASS_SLAB = register("density_glass_slab", SlabBlock::new, AbstractBlock.Settings.create().requiresTool().strength(2f).noCollision());
|
||||
public static final Block DENSITY_GLASS_DOOR = register("density_glass_door", (AbstractBlock.Settings blockSettings) -> new DoorBlock(BlockSetType.IRON, blockSettings),
|
||||
AbstractBlock.Settings.create().requiresTool().strength(2f).nonOpaque());
|
||||
|
||||
public static Block register(String blockId) {
|
||||
return register(blockId, Block::new, AbstractBlock.Settings.create().strength(2f));
|
||||
}
|
||||
|
||||
public static Block register(String blockId, Function<AbstractBlock.Settings, Block> factory) {
|
||||
return register(blockId, factory, AbstractBlock.Settings.create());
|
||||
}
|
||||
|
||||
// for BlockState, BlockSettings register
|
||||
public static Block register(String blockId, BiFunction<BlockState, AbstractBlock.Settings, Block> factory, BlockState blockState, AbstractBlock.Settings settings) {
|
||||
RegistryKey<Block> key = keyOf(blockId);
|
||||
return register(key, factory.apply(blockState, settings.registryKey(key)));
|
||||
}
|
||||
|
||||
// for WoodType, BlockSettings register
|
||||
public static Block register(String blockId, BiFunction<WoodType, AbstractBlock.Settings, Block> factory, WoodType woodType, AbstractBlock.Settings settings) {
|
||||
RegistryKey<Block> key = keyOf(blockId);
|
||||
return register(key, factory.apply(woodType, settings.registryKey(key)));
|
||||
}
|
||||
|
||||
public static Block register(String blockId, Function<AbstractBlock.Settings, Block> factory, AbstractBlock.Settings settings) {
|
||||
RegistryKey<Block> key = keyOf(blockId);
|
||||
return Registry.register(Registries.BLOCK, key, factory.apply(settings.registryKey(key)));
|
||||
|
||||
return register(key, factory.apply(settings.registryKey(key)));
|
||||
}
|
||||
|
||||
private static final RegistryKey<Block> keyOf(String blockId) {
|
||||
public static Block register(RegistryKey<Block> key, Block block) {
|
||||
return Registry.register(Registries.BLOCK, key, block);
|
||||
}
|
||||
|
||||
private static RegistryKey<Block> keyOf(String blockId) {
|
||||
return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(Learning.MOD_ID, blockId));
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,10 @@ import java.util.List;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -31,4 +34,12 @@ public class DamageBlock extends Block {
|
||||
super.appendTooltip(stack, context, tooltip, type);
|
||||
tooltip.add(Text.translatable("toolTip.learning.damage_block"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
|
||||
if (!world.isClient()) {
|
||||
player.sendMessage(Text.translatable("block.learning.damage_block.on_use"), false);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
25
src/main/java/com/learning/datagen/ModBlockTagProvider.java
Normal file
25
src/main/java/com/learning/datagen/ModBlockTagProvider.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.learning.datagen;
|
||||
|
||||
import com.learning.block.CustomBlocks;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ModBlockTagProvider extends FabricTagProvider.BlockTagProvider {
|
||||
|
||||
public ModBlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
|
||||
super(output, registriesFuture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
getOrCreateTagBuilder(BlockTags.PICKAXE_MINEABLE)
|
||||
.add(CustomBlocks.DAMAGE_BLOCK);
|
||||
|
||||
getOrCreateTagBuilder(BlockTags.FENCE_GATES).add(CustomBlocks.DENSITY_GLASS_FENCE_GATE);
|
||||
getOrCreateTagBuilder(BlockTags.FENCES).add(CustomBlocks.DENSITY_GLASS_FENCE);
|
||||
}
|
||||
}
|
23
src/main/java/com/learning/datagen/ModItemTagProvider.java
Normal file
23
src/main/java/com/learning/datagen/ModItemTagProvider.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.learning.datagen;
|
||||
|
||||
import com.learning.item.CustomItems;
|
||||
import com.learning.util.ModTags;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ModItemTagProvider extends FabricTagProvider.ItemTagProvider {
|
||||
public ModItemTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) {
|
||||
super(output, completableFuture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
|
||||
getOrCreateTagBuilder(ModTags.ItemTags.DIAMOND_TRANSFORMABLE)
|
||||
.add(Items.DIAMOND)
|
||||
.add(CustomItems.BAKED_TOAST);
|
||||
}
|
||||
}
|
25
src/main/java/com/learning/datagen/ModLootTableProvider.java
Normal file
25
src/main/java/com/learning/datagen/ModLootTableProvider.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.learning.datagen;
|
||||
|
||||
import com.learning.block.CustomBlocks;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ModLootTableProvider extends FabricBlockLootTableProvider {
|
||||
|
||||
public ModLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||
super(dataOutput, registryLookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
addDrop(CustomBlocks.TRANSFORM_BLOCK);
|
||||
addDrop(CustomBlocks.DAMAGE_BLOCK);
|
||||
addDrop(CustomBlocks.DENSITY_GLASS_FENCE_GATE);
|
||||
addDrop(CustomBlocks.DENSITY_GLASS_FENCE);
|
||||
addDrop(CustomBlocks.DENSITY_GLASS_DOOR, doorDrops(CustomBlocks.DENSITY_GLASS_DOOR));
|
||||
addDrop(CustomBlocks.DENSITY_GLASS_STAIRS);
|
||||
addDrop(CustomBlocks.DENSITY_GLASS_SLAB, slabDrops(CustomBlocks.DENSITY_GLASS_SLAB));
|
||||
}
|
||||
}
|
49
src/main/java/com/learning/datagen/ModModelProvider.java
Normal file
49
src/main/java/com/learning/datagen/ModModelProvider.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.learning.datagen;
|
||||
|
||||
import com.learning.Learning;
|
||||
import com.learning.block.CustomBlocks;
|
||||
import com.learning.item.CustomItems;
|
||||
import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.data.*;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ModModelProvider extends FabricModelProvider {
|
||||
public ModModelProvider(FabricDataOutput output) {
|
||||
super(output);
|
||||
}
|
||||
|
||||
public TextureMap blockOnlySideTop(Block block) {
|
||||
return new TextureMap()
|
||||
.put(TextureKey.TOP, ModelIds.getBlockSubModelId(block, "_top"))
|
||||
.put(TextureKey.BOTTOM, Identifier.of(Learning.MOD_ID, "block/white_block_bottom"))
|
||||
.put(TextureKey.SIDE, ModelIds.getBlockSubModelId(block, "_side"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
|
||||
blockStateModelGenerator.registerSingleton(CustomBlocks.DAMAGE_BLOCK, TexturedModel.makeFactory(this::blockOnlySideTop, Models.CUBE_BOTTOM_TOP));
|
||||
blockStateModelGenerator.registerSingleton(CustomBlocks.TRANSFORM_BLOCK, TexturedModel.makeFactory(this::blockOnlySideTop, Models.CUBE_BOTTOM_TOP));
|
||||
|
||||
BlockStateModelGenerator.BlockTexturePool densityGlassPool = blockStateModelGenerator.registerCubeAllModelTexturePool(CustomBlocks.DENSITY_GLASS);
|
||||
densityGlassPool.fence(CustomBlocks.DENSITY_GLASS_FENCE);
|
||||
densityGlassPool.slab(CustomBlocks.DENSITY_GLASS_SLAB);
|
||||
densityGlassPool.fenceGate(CustomBlocks.DENSITY_GLASS_FENCE_GATE);
|
||||
densityGlassPool.stairs(CustomBlocks.DENSITY_GLASS_STAIRS);
|
||||
blockStateModelGenerator.registerDoor(CustomBlocks.DENSITY_GLASS_DOOR);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateItemModels(ItemModelGenerator itemModelGenerator) {
|
||||
itemModelGenerator.register(CustomItems.OVERCOOKED_TOAST, Models.GENERATED);
|
||||
itemModelGenerator.register(CustomItems.BAKED_TOAST, Models.GENERATED);
|
||||
itemModelGenerator.register(CustomItems.TOAST, Models.GENERATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "FabricDocsReference Model Provider";
|
||||
}
|
||||
}
|
68
src/main/java/com/learning/datagen/ModRecipeProvider.java
Normal file
68
src/main/java/com/learning/datagen/ModRecipeProvider.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.learning.datagen;
|
||||
|
||||
import com.learning.item.CustomItems;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
|
||||
import net.minecraft.data.recipe.RecipeExporter;
|
||||
import net.minecraft.data.recipe.RecipeGenerator;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.book.RecipeCategory;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ModRecipeProvider extends FabricRecipeProvider {
|
||||
public ModRecipeProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
|
||||
super(output, registriesFuture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RecipeGenerator getRecipeGenerator(RegistryWrapper.WrapperLookup wrapperLookup, RecipeExporter recipeExporter) {
|
||||
return new RecipeGenerator(wrapperLookup, recipeExporter) {
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
offerSmelting(List.of(CustomItems.TOAST), RecipeCategory.FOOD, CustomItems.BAKED_TOAST, 0.35f, 200, "toast_furnace");
|
||||
offerSmelting(List.of(CustomItems.BAKED_TOAST), RecipeCategory.FOOD, CustomItems.OVERCOOKED_TOAST, 0.35f, 200, "toast_furnace");
|
||||
|
||||
createShaped(RecipeCategory.MISC, CustomItems.DAMAGE_BLOCK, 4)
|
||||
.pattern("SSS")
|
||||
.pattern("BRB")
|
||||
.pattern("BBB")
|
||||
.input('S', Items.IRON_SWORD)
|
||||
.input('B', Items.IRON_BLOCK)
|
||||
.input('R', Items.RED_DYE)
|
||||
.criterion(hasItem(Items.IRON_SWORD), conditionsFromItem(Items.IRON_SWORD))
|
||||
.offerTo(exporter);
|
||||
|
||||
createShapeless(RecipeCategory.BUILDING_BLOCKS, CustomItems.DENSITY_GLASS)
|
||||
.input(Items.GLASS)
|
||||
.input(Items.OBSIDIAN)
|
||||
.criterion(hasItem(Items.OBSIDIAN), conditionsFromItem(Items.OBSIDIAN))
|
||||
.offerTo(exporter);
|
||||
|
||||
createFenceRecipe(CustomItems.DENSITY_GLASS_FENCE, Ingredient.ofItem(CustomItems.DENSITY_GLASS))
|
||||
.criterion(hasItem(CustomItems.DENSITY_GLASS), conditionsFromItem(CustomItems.DENSITY_GLASS))
|
||||
.offerTo(exporter);
|
||||
createFenceGateRecipe(CustomItems.DENSITY_GLASS_FENCE_GATE, Ingredient.ofItem(CustomItems.DENSITY_GLASS))
|
||||
.criterion(hasItem(CustomItems.DENSITY_GLASS), conditionsFromItem(CustomItems.DENSITY_GLASS))
|
||||
.offerTo(exporter);
|
||||
createStairsRecipe(CustomItems.DENSITY_GLASS_STAIRS, Ingredient.ofItem(CustomItems.DENSITY_GLASS))
|
||||
.criterion(hasItem(CustomItems.DENSITY_GLASS), conditionsFromItem(CustomItems.DENSITY_GLASS))
|
||||
.offerTo(exporter);
|
||||
offerSlabRecipe(RecipeCategory.BUILDING_BLOCKS, CustomItems.DENSITY_GLASS_SLAB, CustomItems.DENSITY_GLASS);
|
||||
createDoorRecipe(CustomItems.DENSITY_GLASS_DOOR, Ingredient.ofItem(CustomItems.DENSITY_GLASS))
|
||||
.criterion(hasItem(CustomItems.DENSITY_GLASS), conditionsFromItem(CustomItems.DENSITY_GLASS))
|
||||
.offerTo(exporter);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "FabricLearningRecipeProvider";
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.consume.UseAction;
|
||||
import net.minecraft.item.tooltip.TooltipType;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.learning.item;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.learning.Learning;
|
||||
@@ -9,10 +10,15 @@ import com.learning.component.Foods;
|
||||
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.tooltip.TooltipType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.component.type.ConsumableComponents;
|
||||
@@ -22,19 +28,39 @@ public class CustomItems {
|
||||
Learning.LOGGER.info("Registering Items...");
|
||||
}
|
||||
|
||||
public static Item toast = register("toast", Toast::new, new Item.Settings().food(Foods.toastFood));
|
||||
public static Item bakedToast = register("baked_toast", BakedToast::new, new Item.Settings().food(Foods.bakedToastFood, ConsumableComponents.food().consumeSeconds(0.8f).build()));
|
||||
public static Item damageBlock = register(CustomBlocks.damageBlock, false);
|
||||
public static Item transformBlock = register(CustomBlocks.transformBlock, false);
|
||||
public static Item TEST_ITEM = register("test_item");
|
||||
|
||||
private static Item register(Block block, Boolean useItemTranslateKey) {
|
||||
public static Item TOAST = register("toast", Toast::new, new Item.Settings().food(Foods.toastFood));
|
||||
public static Item BAKED_TOAST = register("baked_toast", BakedToast::new, new Item.Settings().food(Foods.bakedToastFood, ConsumableComponents.food().consumeSeconds(0.8f).build()));
|
||||
public static Item OVERCOOKED_TOAST = register(keyOf("overcooked_toast"), new Item(new Item.Settings().registryKey(keyOf("overcooked_toast"))) {
|
||||
@Override
|
||||
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
|
||||
tooltip.add(Text.translatable("toolTip.learning.overcooked_toast").formatted(Formatting.GRAY));
|
||||
super.appendTooltip(stack, context, tooltip, type);
|
||||
}
|
||||
});
|
||||
|
||||
public static Item DAMAGE_BLOCK = register(CustomBlocks.DAMAGE_BLOCK, false);
|
||||
public static Item TRANSFORM_BLOCK = register(CustomBlocks.TRANSFORM_BLOCK, false);
|
||||
public static Item DENSITY_GLASS = register(CustomBlocks.DENSITY_GLASS, false);
|
||||
public static Item DENSITY_GLASS_DOOR = register(CustomBlocks.DENSITY_GLASS_DOOR, false);
|
||||
public static Item DENSITY_GLASS_STAIRS = register(CustomBlocks.DENSITY_GLASS_STAIRS, false);
|
||||
public static Item DENSITY_GLASS_FENCE = register(CustomBlocks.DENSITY_GLASS_FENCE, false);
|
||||
public static Item DENSITY_GLASS_SLAB = register(CustomBlocks.DENSITY_GLASS_SLAB, false);
|
||||
public static Item DENSITY_GLASS_FENCE_GATE = register(CustomBlocks.DENSITY_GLASS_FENCE_GATE, false);
|
||||
|
||||
|
||||
|
||||
private static Item register(Block block, Boolean useItemTranslateKey) { // Block register
|
||||
if (Registries.BLOCK.getKey(block).isPresent()) {
|
||||
RegistryKey<Item> key = keyOf(Registries.BLOCK.getKey(block).get());
|
||||
Item.Settings settings = new Item.Settings().registryKey(key);
|
||||
if (!useItemTranslateKey) {
|
||||
settings.useBlockPrefixedTranslationKey();
|
||||
}
|
||||
return register(key, new BlockItem(block, settings));
|
||||
|
||||
}
|
||||
return Items.AIR;
|
||||
}
|
||||
|
||||
private static Item register(String itemId) {
|
||||
@@ -56,7 +82,6 @@ public class CustomItems {
|
||||
|
||||
private static Item register(RegistryKey<Item> key, Item item) {
|
||||
return Registry.register(Registries.ITEM, key, item);
|
||||
|
||||
}
|
||||
|
||||
private static RegistryKey<Item> keyOf(String itemId) {
|
||||
|
@@ -18,18 +18,25 @@ public class CustomItemGroup {
|
||||
Learning.LOGGER.info("Registering ItemGroup...");
|
||||
Learning.LOGGER.info("Registering item into ItemGroups...");
|
||||
ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register(
|
||||
register -> register.add(CustomItems.toast)
|
||||
register -> register.add(CustomItems.TOAST)
|
||||
);
|
||||
}
|
||||
|
||||
public static ItemGroup customItemGroup = register("custom_itemgroup", ItemGroup.create(null, -1)
|
||||
.icon(() -> new ItemStack(CustomItems.toast))
|
||||
.icon(() -> new ItemStack(CustomItems.TOAST))
|
||||
.displayName(Text.translatable("itemGroup.learning.custom_itemgroup"))
|
||||
.entries((displayContext, entries) -> {
|
||||
entries.add(CustomItems.toast);
|
||||
entries.add(CustomItems.bakedToast);
|
||||
entries.add(CustomItems.damageBlock);
|
||||
entries.add(CustomItems.transformBlock);
|
||||
entries.add(CustomItems.TOAST);
|
||||
entries.add(CustomItems.BAKED_TOAST);
|
||||
entries.add(CustomItems.OVERCOOKED_TOAST);
|
||||
entries.add(CustomItems.DAMAGE_BLOCK);
|
||||
entries.add(CustomItems.TRANSFORM_BLOCK);
|
||||
entries.add(CustomItems.DENSITY_GLASS);
|
||||
entries.add(CustomItems.DENSITY_GLASS_DOOR);
|
||||
entries.add(CustomItems.DENSITY_GLASS_FENCE);
|
||||
entries.add(CustomItems.DENSITY_GLASS_FENCE_GATE);
|
||||
entries.add(CustomItems.DENSITY_GLASS_STAIRS);
|
||||
entries.add(CustomItems.DENSITY_GLASS_SLAB);
|
||||
})
|
||||
.build());
|
||||
|
||||
|
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "learning:block/damage_block"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "learning:block/transform_block"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,17 @@
|
||||
{
|
||||
"item.learning.toast": "Toast",
|
||||
"item.learning.baked_toast": "Baked Toast",
|
||||
"item.learning.overcooked_toast": "Overcooked Toast",
|
||||
|
||||
"block.learning.damage_block": "Damage Block",
|
||||
"block.learning.damage_block.on_use": "Make 5 damage per hurt.",
|
||||
"block.learning.transform_block": "Transform Block",
|
||||
"block.learning.density_glass": "Density Glass",
|
||||
"block.learning.density_glass_gate": "Density Glass",
|
||||
"block.learning.density_glass_fence": "Density Glass Fence",
|
||||
"block.learning.density_glass_door": "Density Glass Door",
|
||||
"block.learning.density_glass_slab": "Density Glass Slab",
|
||||
"block.learning.density_glass_stairs": "Density Glass Stairs",
|
||||
|
||||
"itemGroup.learning.custom_itemgroup": "My Dear...",
|
||||
|
||||
@@ -12,6 +20,7 @@
|
||||
"toolTip.learning.toast1": "Will be tastier after baking in the furnace!",
|
||||
"toolTip.learning.baked_toast": "Yummy!",
|
||||
"toolTip.learning.damage_block": "Will hurt entities which stands on this block.",
|
||||
"toolTip.learning.overcooked_toast": "It turns to coal, totally...",
|
||||
|
||||
"toolTip.learning.hold_control": "Hold §6Control §rto show more information.",
|
||||
"toolTip.learning.hold_shift": "Hold §6Shift §rto show more information."
|
||||
|
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"bottom": "learning:block/white_block_bottom",
|
||||
"top": "learning:block/damage_block_top",
|
||||
"side": "learning:block/damage_block_side"
|
||||
}
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"parent": "block/cube_bottom_top",
|
||||
"textures": {
|
||||
"bottom": "learning:block/white_block_bottom",
|
||||
"top": "learning:block/transformblock_top",
|
||||
"side": "learning:block/transformblock_side"
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "learning:item/baked_toast"
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "learning:item/toast"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 237 B |
Before Width: | Height: | Size: 298 B After Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 232 B After Width: | Height: | Size: 232 B |
Binary file not shown.
After Width: | Height: | Size: 108 B |
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"type": "minecraft:smoking",
|
||||
"category": "food",
|
||||
"cookingtime": 100,
|
||||
"experience": 0.35,
|
||||
"ingredient": "learning:toast",
|
||||
"result": {
|
||||
"id": "learning:baked_toast"
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"values": [
|
||||
"minecraft:coal",
|
||||
"learning:baked_toast"
|
||||
]
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
schemaVersion": 1,
|
||||
"schemaVersion": 1,
|
||||
"id": "learning",
|
||||
"version": "${version}",
|
||||
"name": "Learning",
|
||||
@@ -18,6 +18,9 @@
|
||||
"main": [
|
||||
"com.learning.Learning"
|
||||
],
|
||||
"client": [
|
||||
"com.learning.LearningClient"
|
||||
],
|
||||
"fabric-datagen": [
|
||||
"com.learning.LearningDataGenerator"
|
||||
]
|
||||
|
Reference in New Issue
Block a user