Skip to content

Commit

Permalink
added jarred_tomatoes
Browse files Browse the repository at this point in the history
added jarred_beetroot
added jarred_cabbage
  • Loading branch information
MEGATREX4 committed Jun 17, 2024
1 parent 51fe8a9 commit 871a8b4
Show file tree
Hide file tree
Showing 22 changed files with 628 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public void onInitialize() {
ModItemGroups.registerItemGroups();
ToolTipHelper.registerTooltip();

BlockRenderLayerMap.INSTANCE.putBlock(FoodBlocks.JAR, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(FoodBlocks.APPLE_JAM, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(FoodBlocks.JARRED_TOMATOES, RenderLayer.getCutout());


LOGGER.info("Hello Fabric world it's " + MOD_ID + "!");
}
}
29 changes: 23 additions & 6 deletions src/main/java/com/megatrex4/ukrainian_dlight/block/FoodBlocks.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.megatrex4.ukrainian_dlight.block;

import com.megatrex4.ukrainian_dlight.UkrainianDelight;
import com.megatrex4.ukrainian_dlight.item.FoodBlockComponents;
import com.megatrex4.ukrainian_dlight.item.FoodBlockItem; // Import the FoodBlockItem class
import com.megatrex4.ukrainian_dlight.item.FoodBlockItem;
import net.minecraft.block.Block;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
Expand All @@ -15,15 +16,31 @@ public class FoodBlocks {

// New Jar Blocks
public static final Block JAR = registerBlock("jar", new JarBlock(), null);
public static final Block APPLE_JAM = registerBlock("apple_jam", new JarBlock(), FoodBlockComponents.APPLE_JAM);
public static final Block JARRED_TOMATOES = registerBlock("jarred_tomatoes", new JarBlock(), FoodBlockComponents.JARRED_TOMATOES);

private static Block registerBlock(String name, Block block, FoodComponent foodComponent){
//JAMS
public static final Block APPLE_JAM = registerBlock("apple_jam", new JarBlock(), new FoodComponent.Builder().hunger(4).saturationModifier(0.3f).build());

//JARRED VEGETABLES
public static final Block JARRED_TOMATOES = registerBlock("jarred_tomatoes", new JarBlock(), new FoodComponent.Builder()
.hunger(6).saturationModifier(0.6f)
.statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 3 * 20, 3), 1.0f)
.build());

public static final Block JARRED_CABBAGE = registerBlock("jarred_cabbage", new JarBlock(), new FoodComponent.Builder()
.hunger(6).saturationModifier(0.6f)
.statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 3 * 20, 3), 1.0f).build());

public static final Block JARRED_BEETROOT = registerBlock("jarred_beetroot", new JarBlock(), new FoodComponent.Builder()
.hunger(6).saturationModifier(0.6f)
.statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 3 * 20, 3), 1.0f).build());


private static Block registerBlock(String name, Block block, FoodComponent foodComponent) {
registerBlockItem(name, block, foodComponent);
return Registry.register(Registries.BLOCK, new Identifier(UkrainianDelight.MOD_ID, name), block);
}

private static Item registerBlockItem(String name, Block block, FoodComponent foodComponent){
private static Item registerBlockItem(String name, Block block, FoodComponent foodComponent) {
Item item;
if (foodComponent != null) {
item = new FoodBlockItem(block, foodComponent);
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/megatrex4/ukrainian_dlight/block/JarBlock.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.megatrex4.ukrainian_dlight.block;

import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShapeContext;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageType;
Expand Down Expand Up @@ -42,8 +44,6 @@ public class JarBlock extends Block {
private static final Map<Integer, VoxelShape> SHAPES = new HashMap<>();
private static final ThreadLocal<Boolean> isRemovingJar = ThreadLocal.withInitial(() -> false);



static {
SHAPES.put(1, Block.createCuboidShape(6, 0, 6, 10, 8, 10));
SHAPES.put(2, Block.createCuboidShape(1, 0, 3, 14, 8, 12));
Expand All @@ -54,8 +54,14 @@ public class JarBlock extends Block {
public JarBlock() {
super(FabricBlockSettings.copyOf(Blocks.GLASS).strength(0.2F).nonOpaque().sounds(BlockSoundGroup.GLASS));
this.setDefaultState(this.stateManager.getDefaultState().with(JARS, 1).with(FACING, Direction.NORTH)); // Start with 1 jar facing north
setRenderLayer();
}

private void setRenderLayer() {
BlockRenderLayerMap.INSTANCE.putBlock(this, RenderLayer.getCutout());
}


@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(JARS, FACING);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ public class ModItemGroups {
.displayName(Text.translatable("itemgroup.ingredients_ukrainian_delight"))
.icon(() -> new ItemStack(ModItems.CUCUMBER))
.entries((displayContext, entries) -> {
entries.add(FoodBlocks.JAR);
entries.add(FoodBlocks.APPLE_JAM);
entries.add(FoodBlocks.JARRED_TOMATOES);
entries.add(ModBlock.SALT_BLOCK);
entries.add(ModItems.SALT);

Expand All @@ -44,6 +41,18 @@ public class ModItemGroups {
entries.add(ModItems.DRIED_APPLE_SLICE);
}).build());

public static final ItemGroup JARS_UKRAINIAN_DELIGHT = Registry.register(Registries.ITEM_GROUP,
new Identifier(UkrainianDelight.MOD_ID, "jars_ukrainian_delight"),
FabricItemGroup.builder()
.displayName(Text.translatable("itemgroup.jars_ukrainian_delight"))
.icon(() -> new ItemStack(FoodBlocks.JARRED_TOMATOES))
.entries((displayContext, entries) -> {
entries.add(FoodBlocks.JAR);
entries.add(FoodBlocks.APPLE_JAM);
entries.add(FoodBlocks.JARRED_TOMATOES);
entries.add(FoodBlocks.JARRED_CABBAGE);
entries.add(FoodBlocks.JARRED_BEETROOT);
}).build());

public static void registerItemGroups() {
UkrainianDelight.LOGGER.info("Registering Item Groups for " + UkrainianDelight.MOD_ID);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"variants": {
"jars=1": [
{ "model": "ukrainian_delight:block/jars/one_jar_jarred_beetroot" },
{ "model": "ukrainian_delight:block/jars/one_jar_jarred_beetroot", "y": 90 },
{ "model": "ukrainian_delight:block/jars/one_jar_jarred_beetroot", "y": 180 },
{ "model": "ukrainian_delight:block/jars/one_jar_jarred_beetroot", "y": 270 }
],
"jars=2": [
{ "model": "ukrainian_delight:block/jars/two_jar_jarred_beetroot" },
{ "model": "ukrainian_delight:block/jars/two_jar_jarred_beetroot", "y": 90 },
{ "model": "ukrainian_delight:block/jars/two_jar_jarred_beetroot", "y": 180 },
{ "model": "ukrainian_delight:block/jars/two_jar_jarred_beetroot", "y": 270 }
],
"jars=3": [
{ "model": "ukrainian_delight:block/jars/three_jar_jarred_beetroot" },
{ "model": "ukrainian_delight:block/jars/three_jar_jarred_beetroot", "y": 90 },
{ "model": "ukrainian_delight:block/jars/three_jar_jarred_beetroot", "y": 180 },
{ "model": "ukrainian_delight:block/jars/three_jar_jarred_beetroot", "y": 270 }
],
"jars=4": [
{ "model": "ukrainian_delight:block/jars/four_jar_jarred_beetroot" },
{ "model": "ukrainian_delight:block/jars/four_jar_jarred_beetroot", "y": 90 },
{ "model": "ukrainian_delight:block/jars/four_jar_jarred_beetroot", "y": 180 },
{ "model": "ukrainian_delight:block/jars/four_jar_jarred_beetroot", "y": 270 }
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"variants": {
"jars=1": [
{ "model": "ukrainian_delight:block/jars/one_jar_jarred_cabbage" },
{ "model": "ukrainian_delight:block/jars/one_jar_jarred_cabbage", "y": 90 },
{ "model": "ukrainian_delight:block/jars/one_jar_jarred_cabbage", "y": 180 },
{ "model": "ukrainian_delight:block/jars/one_jar_jarred_cabbage", "y": 270 }
],
"jars=2": [
{ "model": "ukrainian_delight:block/jars/two_jar_jarred_cabbage" },
{ "model": "ukrainian_delight:block/jars/two_jar_jarred_cabbage", "y": 90 },
{ "model": "ukrainian_delight:block/jars/two_jar_jarred_cabbage", "y": 180 },
{ "model": "ukrainian_delight:block/jars/two_jar_jarred_cabbage", "y": 270 }
],
"jars=3": [
{ "model": "ukrainian_delight:block/jars/three_jar_jarred_cabbage" },
{ "model": "ukrainian_delight:block/jars/three_jar_jarred_cabbage", "y": 90 },
{ "model": "ukrainian_delight:block/jars/three_jar_jarred_cabbage", "y": 180 },
{ "model": "ukrainian_delight:block/jars/three_jar_jarred_cabbage", "y": 270 }
],
"jars=4": [
{ "model": "ukrainian_delight:block/jars/four_jar_jarred_cabbage" },
{ "model": "ukrainian_delight:block/jars/four_jar_jarred_cabbage", "y": 90 },
{ "model": "ukrainian_delight:block/jars/four_jar_jarred_cabbage", "y": 180 },
{ "model": "ukrainian_delight:block/jars/four_jar_jarred_cabbage", "y": 270 }
]
}
}
4 changes: 4 additions & 0 deletions src/main/resources/assets/ukrainian_delight/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"_comment1": "groups",
"itemgroup.meals_ukrainian_delight": "Ukrainian Delight",
"itemgroup.ingredients_ukrainian_delight": "Ukrainian Delight Ingredients",
"itemgroup.jars_ukrainian_delight": "Ukrainian Delight Jars",
"rei.ukrainian_delight": "Ukrainian Delight",

"_comment2": "ingredients",
Expand All @@ -22,7 +23,10 @@
"_comment4": "jars",
"block.ukrainian_delight.jar": "Jar",
"block.ukrainian_delight.apple_jam": "Apple Jam",

"block.ukrainian_delight.jarred_tomatoes": "Jarred Tomatoes",
"block.ukrainian_delight.jarred_cabbage": "Jarred Cabbage",
"block.ukrainian_delight.jarred_beetroot": "Jarred Beetroot",

"_comment5": "blocks",
"block.ukrainian_delight.salt_block": "Salt Block",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"_comment1": "groups",
"itemgroup.meals_ukrainian_delight": "Українська насолода страви",
"itemgroup.ingredients_ukrainian_delight": "Українська насолода складові",
"itemgroup.jars_ukrainian_delight": "Українська насолода банки",
"rei.ukrainian_delight": "Українська насолода",

"_comment2": "ingredients",
Expand Down
Loading

0 comments on commit 871a8b4

Please sign in to comment.