Compare commits

...

2 Commits

Author SHA1 Message Date
b3515c1e07 clear cache
Some checks failed
构建 / build (push) Failing after 2m32s
2025-03-21 20:48:41 +08:00
db7efdf7ba Update NonBlock blocks 2025-03-21 20:44:34 +08:00
19 changed files with 139 additions and 73 deletions

View File

@ -1,7 +0,0 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/FabricLearningRecipeProvider
909cf34a9dd2590a5904c5c305eb6627e4007e16 data/learning/advancement/recipes/food/baked_toast_from_smelting_toast.json
48e4de17c89453877299044a387ab270980a73f0 data/learning/advancement/recipes/food/overcooked_toast_from_smelting_baked_toast.json
3f312674e372bc99fef50332fe3b73ad2f0b8e8c data/learning/advancement/recipes/misc/damage_block.json
fa465ec49923885685cd0d0d97d1a8a8f86a6f9b data/learning/recipe/baked_toast_from_smelting_toast.json
4f79f807a401252843d3deab2fd21c0426477f21 data/learning/recipe/damage_block.json
073bdd46b2248dd3adcfda31d2ccfacef839d5a2 data/learning/recipe/overcooked_toast_from_smelting_baked_toast.json

View File

@ -1,13 +0,0 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/FabricDocsReference Model Provider
9b929e7065d522bc2f535cbf0be27b781747764c assets/learning/blockstates/damage_block.json
ae0d992c57701b5c4cfa1f74886b0c6643382dde assets/learning/blockstates/transform_block.json
7e8a7842ae92f24d68423d756ce6a9a33187439b assets/learning/items/baked_toast.json
d9cfa06092e4a6b79cf7d701c70deeb937b88155 assets/learning/items/damage_block.json
a47afe35b341d49ea1af4b9039c7ee7c5747fa5d assets/learning/items/overcooked_toast.json
bc0cb59f5b489dfdf541e42499fb4a28b9bacea0 assets/learning/items/toast.json
296544cf2c1bf4c18575d1637bd95cccd86bd6ba assets/learning/items/transform_block.json
61b7662769db9c343a2b01449f74b47dee072d69 assets/learning/models/block/damage_block.json
afa3a162ab44856a979f7206b9d9047fba19d45b assets/learning/models/block/transform_block.json
4f29a35228f6e93e29262172a11e8aaa145a10f9 assets/learning/models/item/baked_toast.json
7ac95480ea0a3b708095eda1fbff11ab770450b1 assets/learning/models/item/overcooked_toast.json
0ee68562153eab4dd8756c1c0d14ed8e67fd692f assets/learning/models/item/toast.json

View File

@ -1,2 +0,0 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/Tags for minecraft:block
38a917b5f6cf798e0cf0c65180771a0f310de0da data/minecraft/tags/block/mineable/pickaxe.json

View File

@ -1,3 +0,0 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/Block Loot Tables
0098930b7ed8d4f99711b81a043962b5a29d992b data/learning/loot_table/blocks/damage_block.json
3c5485c4b7890adb359efda5037235e72e85c33a data/learning/loot_table/blocks/transform_block.json

View File

@ -1,2 +0,0 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/Tags for minecraft:item
5930563a7f50b4e9c1f59dedf432c4fba846138c data/learning/tags/item/diamond_transformable.json

View File

@ -5,7 +5,6 @@ import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistryEvents;
import net.minecraft.item.FuelRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -33,11 +32,11 @@ public class Learning implements ModInitializer {
LOGGER.info("Adding Fuel registries...");
FuelRegistryEvents.BUILD.register(((builder, context) -> {
builder.add(CustomItems.overcookedToast, 6000);
builder.add(CustomItems.OVERCOOKED_TOAST, 6000);
}));
LOGGER.info("Adding Compostable registries...");
CompostingChanceRegistry.INSTANCE.add(CustomItems.toast, 0.3f);
CompostingChanceRegistry.INSTANCE.add(CustomItems.bakedToast, 0.5f);
CompostingChanceRegistry.INSTANCE.add(CustomItems.TOAST, 0.3f);
CompostingChanceRegistry.INSTANCE.add(CustomItems.BAKED_TOAST, 0.5f);
}
}

View 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());
}
}

View File

@ -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,47 @@ 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().requiresTool());
public static final Block transformBlock = register("transform_block", TransformBlock::new);
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 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());
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)));
}
public static Block register(RegistryKey<Block> key, Block block) {
return Registry.register(Registries.BLOCK, key, block);
}
private static RegistryKey<Block> keyOf(String blockId) {

View File

@ -37,7 +37,9 @@ public class DamageBlock extends Block {
@Override
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
player.sendMessage(Text.translatable("block.learning.damage_block.on_use"), false);
if (!world.isClient()) {
player.sendMessage(Text.translatable("block.learning.damage_block.on_use"), false);
}
return ActionResult.SUCCESS;
}
}

View File

@ -1,12 +1,8 @@
package com.learning.datagen;
import com.learning.block.CustomBlocks;
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.RegistryKey;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.BlockTags;
@ -21,6 +17,9 @@ public class ModBlockTagProvider extends FabricTagProvider.BlockTagProvider {
@Override
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(BlockTags.PICKAXE_MINEABLE)
.add(CustomBlocks.damageBlock);
.add(CustomBlocks.DAMAGE_BLOCK);
getOrCreateTagBuilder(BlockTags.FENCE_GATES).add(CustomBlocks.DENSITY_GLASS_FENCE_GATE);
getOrCreateTagBuilder(BlockTags.FENCES).add(CustomBlocks.DENSITY_GLASS_FENCE);
}
}

View File

@ -18,6 +18,6 @@ public class ModItemTagProvider extends FabricTagProvider.ItemTagProvider {
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(ModTags.ItemTags.DIAMOND_TRANSFORMABLE)
.add(Items.DIAMOND)
.add(CustomItems.bakedToast);
.add(CustomItems.BAKED_TOAST);
}
}

View File

@ -14,7 +14,12 @@ public class ModLootTableProvider extends FabricBlockLootTableProvider {
@Override
public void generate() {
addDrop(CustomBlocks.transformBlock);
addDrop(CustomBlocks.damageBlock);
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));
}
}

View File

@ -23,15 +23,23 @@ public class ModModelProvider extends FabricModelProvider {
@Override
public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
blockStateModelGenerator.registerSingleton(CustomBlocks.damageBlock, TexturedModel.makeFactory(this::blockOnlySideTop, Models.CUBE_BOTTOM_TOP));
blockStateModelGenerator.registerSingleton(CustomBlocks.transformBlock, TexturedModel.makeFactory(this::blockOnlySideTop, Models.CUBE_BOTTOM_TOP));
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.overcookedToast, Models.GENERATED);
itemModelGenerator.register(CustomItems.bakedToast, Models.GENERATED);
itemModelGenerator.register(CustomItems.toast, Models.GENERATED);
itemModelGenerator.register(CustomItems.OVERCOOKED_TOAST, Models.GENERATED);
itemModelGenerator.register(CustomItems.BAKED_TOAST, Models.GENERATED);
itemModelGenerator.register(CustomItems.TOAST, Models.GENERATED);
}
@Override

View File

@ -3,14 +3,10 @@ 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.CookingRecipeJsonBuilder;
import net.minecraft.data.recipe.RecipeExporter;
import net.minecraft.data.recipe.RecipeGenerator;
import net.minecraft.data.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.Items;
import net.minecraft.recipe.*;
import net.minecraft.recipe.book.CookingRecipeCategory;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.RegistryWrapper;
@ -28,10 +24,10 @@ public class ModRecipeProvider extends FabricRecipeProvider {
@Override
public void generate() {
offerSmelting(List.of(CustomItems.toast), RecipeCategory.FOOD, CustomItems.bakedToast, 0.35f, 200, "toast_furnace");
offerSmelting(List.of(CustomItems.bakedToast), RecipeCategory.FOOD, CustomItems.overcookedToast, 0.35f, 200, "toast_furnace");
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.damageBlock, 4)
createShaped(RecipeCategory.MISC, CustomItems.DAMAGE_BLOCK, 4)
.pattern("SSS")
.pattern("BRB")
.pattern("BBB")
@ -40,6 +36,27 @@ public class ModRecipeProvider extends FabricRecipeProvider {
.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);
}
};
}

View File

@ -28,9 +28,11 @@ 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 overcookedToast = register(keyOf("overcooked_toast"), new Item(new Item.Settings().registryKey(keyOf("overcooked_toast"))) {
public static Item TEST_ITEM = register("test_item");
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));
@ -38,10 +40,18 @@ public class CustomItems {
}
});
public static Item damageBlock = register(CustomBlocks.damageBlock, false);
public static Item transformBlock = register(CustomBlocks.transformBlock, false);
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) {
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);

View File

@ -18,19 +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.overcookedToast);
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());

View File

@ -6,6 +6,12 @@
"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...",

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

View File

@ -18,6 +18,9 @@
"main": [
"com.learning.Learning"
],
"client": [
"com.learning.LearningClient"
],
"fabric-datagen": [
"com.learning.LearningDataGenerator"
]