-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from SKZGx/master
Master
- Loading branch information
Showing
27 changed files
with
246 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/megatrex4/ukrainian_dlight/item/FoodBlockComponents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.megatrex4.ukrainian_dlight.item; | ||
|
||
import net.minecraft.entity.effect.StatusEffectInstance; | ||
import net.minecraft.entity.effect.StatusEffects; | ||
import net.minecraft.item.FoodComponent; | ||
|
||
public class FoodBlockComponents { | ||
public static final FoodComponent APPLE_JAM = new FoodComponent.Builder().hunger(4).saturationModifier(0.3f).build(); | ||
public static final FoodComponent JARRED_TOMATOES = new FoodComponent.Builder().hunger(6).saturationModifier(0.6f) | ||
.statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 3*20, 3), 1.0f).build(); | ||
|
||
} |
45 changes: 44 additions & 1 deletion
45
src/main/java/com/megatrex4/ukrainian_dlight/item/FoodBlockItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,55 @@ | ||
package com.megatrex4.ukrainian_dlight.item; | ||
|
||
import com.megatrex4.ukrainian_dlight.util.StatusEffectUtil; | ||
import com.mojang.datafixers.util.Pair; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.client.item.TooltipContext; | ||
import net.minecraft.entity.effect.StatusEffectInstance; | ||
import net.minecraft.item.BlockItem; | ||
import net.minecraft.item.FoodComponent; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
import net.minecraft.world.World; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
|
||
public class FoodBlockItem extends BlockItem { | ||
private final FoodComponent foodComponent; | ||
|
||
public FoodBlockItem(Block block, FoodComponent foodComponent) { | ||
super(block, new Item.Settings().food(foodComponent)); | ||
this.foodComponent = foodComponent; | ||
} | ||
|
||
@Override | ||
public void appendTooltip(ItemStack stack, World world, List<Text> tooltip, TooltipContext context) { | ||
super.appendTooltip(stack, world, tooltip, context); | ||
|
||
// Add food component tooltip | ||
if (foodComponent != null) { | ||
// Check for status effects and add them to the tooltip | ||
if (!foodComponent.getStatusEffects().isEmpty()) { | ||
for (Pair<StatusEffectInstance, Float> effect : foodComponent.getStatusEffects()) { | ||
StatusEffectInstance instance = effect.getFirst(); | ||
String effectName = instance.getEffectType().getName().getString(); | ||
int duration = effect.getFirst().getDuration() / 20; | ||
int amplifier = effect.getFirst().getAmplifier() + 1; | ||
String amplifierString = StatusEffectUtil.formatAmplifier(amplifier); | ||
String durationString = formatDuration(duration); | ||
tooltip.add(Text.translatable(effectName).append(Text.of(amplifierString)).append(Text.of(" (" + durationString + ") ")).formatted(Formatting.BLUE)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static String formatDuration(int duration) { | ||
int minutes = duration / 60; | ||
int seconds = duration % 60; | ||
|
||
return String.format("%d:%02d", minutes, seconds); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 24 additions & 4 deletions
28
src/main/resources/assets/ukrainian_delight/blockstates/apple_jam.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
{ | ||
"variants": { | ||
"jars=1": { "model": "ukrainian_delight:block/jars/one_jar_apple_jam" }, | ||
"jars=2": { "model": "ukrainian_delight:block/jars/two_jar_apple_jam" }, | ||
"jars=3": { "model": "ukrainian_delight:block/jars/three_jar_apple_jam" }, | ||
"jars=4": { "model": "ukrainian_delight:block/jars/four_jar_apple_jam" } | ||
"jars=1": [ | ||
{ "model": "ukrainian_delight:block/jars/one_jar_apple_jam" }, | ||
{ "model": "ukrainian_delight:block/jars/one_jar_apple_jam", "y": 90 }, | ||
{ "model": "ukrainian_delight:block/jars/one_jar_apple_jam", "y": 180 }, | ||
{ "model": "ukrainian_delight:block/jars/one_jar_apple_jam", "y": 270 } | ||
], | ||
"jars=2": [ | ||
{ "model": "ukrainian_delight:block/jars/two_jar_apple_jam" }, | ||
{ "model": "ukrainian_delight:block/jars/two_jar_apple_jam", "y": 90 }, | ||
{ "model": "ukrainian_delight:block/jars/two_jar_apple_jam", "y": 180 }, | ||
{ "model": "ukrainian_delight:block/jars/two_jar_apple_jam", "y": 270 } | ||
], | ||
"jars=3": [ | ||
{ "model": "ukrainian_delight:block/jars/three_jar_apple_jam" }, | ||
{ "model": "ukrainian_delight:block/jars/three_jar_apple_jam", "y": 90 }, | ||
{ "model": "ukrainian_delight:block/jars/three_jar_apple_jam", "y": 180 }, | ||
{ "model": "ukrainian_delight:block/jars/three_jar_apple_jam", "y": 270 } | ||
], | ||
"jars=4": [ | ||
{ "model": "ukrainian_delight:block/jars/four_jar_apple_jam" }, | ||
{ "model": "ukrainian_delight:block/jars/four_jar_apple_jam", "y": 90 }, | ||
{ "model": "ukrainian_delight:block/jars/four_jar_apple_jam", "y": 180 }, | ||
{ "model": "ukrainian_delight:block/jars/four_jar_apple_jam", "y": 270 } | ||
] | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
src/main/resources/assets/ukrainian_delight/blockstates/canned_tomatoes.json
This file was deleted.
Oops, something went wrong.
28 changes: 24 additions & 4 deletions
28
src/main/resources/assets/ukrainian_delight/blockstates/jar.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
{ | ||
"variants": { | ||
"jars=1": { "model": "ukrainian_delight:block/jars/one_jar" }, | ||
"jars=2": { "model": "ukrainian_delight:block/jars/two_jar" }, | ||
"jars=3": { "model": "ukrainian_delight:block/jars/three_jar" }, | ||
"jars=4": { "model": "ukrainian_delight:block/jars/four_jar" } | ||
"jars=1": [ | ||
{ "model": "ukrainian_delight:block/jars/one_jar", "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/one_jar", "y": 90, "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/one_jar", "y": 180, "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/one_jar", "y": 270, "particles": "minecraft:block/glass" } | ||
], | ||
"jars=2": [ | ||
{ "model": "ukrainian_delight:block/jars/two_jar", "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/two_jar", "y": 90, "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/two_jar", "y": 180, "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/two_jar", "y": 270, "particles": "minecraft:block/glass" } | ||
], | ||
"jars=3": [ | ||
{ "model": "ukrainian_delight:block/jars/three_jar", "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/three_jar", "y": 90, "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/three_jar", "y": 180, "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/three_jar", "y": 270, "particles": "minecraft:block/glass" } | ||
], | ||
"jars=4": [ | ||
{ "model": "ukrainian_delight:block/jars/four_jar", "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/four_jar", "y": 90, "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/four_jar", "y": 180, "particles": "minecraft:block/glass" }, | ||
{ "model": "ukrainian_delight:block/jars/four_jar", "y": 270, "particles": "minecraft:block/glass" } | ||
] | ||
} | ||
} |
Oops, something went wrong.