Skip to content

Commit

Permalink
Changes to be committed:
Browse files Browse the repository at this point in the history
	modified:   src/main/java/com/megatrex4/ukrainian_dlight/item/ModFoodComponents.java
	modified:   src/main/java/com/megatrex4/ukrainian_dlight/item/StatusEffectUtil.java
	new file:   src/main/java/com/megatrex4/ukrainian_dlight/item/ToolTipHelper.java
	modified:   src/main/resources/assets/farmersdelight/lang/uk_ua.json
	modified:   src/main/resources/assets/minecraft/lang/uk_ua.json
	modified:   src/main/resources/assets/ukrainian_delight/lang/en_us.json
	modified:   src/main/resources/assets/ukrainian_delight/lang/uk_ua.json
	modified:   src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json
	modified:   src/main/resources/data/minecraft/tags/blocks/mineable/shovel.json
	modified:   src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.json
	modified:   src/main/resources/data/minecraft/tags/blocks/needs_stone_tool.json
	modified:   src/main/resources/data/ukrainian_delight/loot_tables/blocks/salt_block.json
MEGATREX4 committed Jun 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent d0d3370 commit df673c7
Showing 12 changed files with 156 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -25,9 +25,9 @@ public class ModFoodComponents {
public static final FoodComponent BORSCHT = new FoodComponent.Builder()
.hunger(15)
.saturationModifier(1f)
.statusEffect(new StatusEffectInstance(NOURISHMENT, 3*60*20, 0), 1.0F)
.statusEffect(new StatusEffectInstance(COMFORT, 2*60*20, 0), 1.0F)
.statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 3*20, 5), 1.0f)
.statusEffect(new StatusEffectInstance(NOURISHMENT, 5*60*20, 0), 1.0F)
.statusEffect(new StatusEffectInstance(COMFORT, 5*60*20, 0), 1.0F)
// .statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 3*20, 3), 1.0f)
.build();

public static final FoodComponent HORSERADISH = new FoodComponent.Builder()
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ public static String formatAmplifier(int amplifier) {
}

// Handle amplifiers greater than 5 by returning the number itself
if (amplifier > 5) {
if (amplifier > 10) {
return " " + amplifier;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.megatrex4.ukrainian_dlight.item;

import java.util.List;

import com.megatrex4.ukrainian_dlight.UkrainianDelight;
import com.mojang.datafixers.util.Pair;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

public class ToolTipHelper extends Item {

public ToolTipHelper(Settings settings) {
super(settings);
}

// This method adds tooltip information to the item when hovered over in the inventory
@Override
@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
super.appendTooltip(stack, world, tooltip, context);

// Retrieve the FoodComponent of the item
FoodComponent foodComponent = this.getFoodComponent();

// Check if the FoodComponent exists and if it has any status effects
if (foodComponent != null && !foodComponent.getStatusEffects().isEmpty()) {
// Call a method to add the status effects to the tooltip
addFoodEffectTooltip(stack, tooltip, foodComponent.getStatusEffects());
}
}

// This method adds status effect information to the tooltip
public static void addFoodEffectTooltip(ItemStack itemStack, List<Text> tooltip, List<Pair<StatusEffectInstance, Float>> effects) {
// If there are no effects, add a message indicating that there are no effects
if (effects.isEmpty()) {
tooltip.add(Text.translatable("tooltip.ukrainian_delight.no_effects").formatted(Formatting.GRAY));
} else {
// Iterate through each effect and add its information to the tooltip
for (Pair<StatusEffectInstance, Float> pair : effects) {
StatusEffectInstance effect = pair.getFirst();
String name = effect.getEffectType().getTranslationKey();
int duration = effect.getDuration() / 20; // Convert ticks to seconds
int amplifier = effect.getAmplifier() + 1;
String amplifierString = StatusEffectUtil.formatAmplifier(amplifier);
String durationString = formatDuration(duration);

// Combine the effect name and duration, formatting them as blue text
Text tooltipText = Text.translatable(name).formatted(Formatting.BLUE).append(Text.of(amplifierString))
.append(Text.of(" (" + durationString + ") "));

// Add the tooltip text to the list
tooltip.add(tooltipText);
}
}
}


// This method formats the duration of an effect
private static String formatDuration(int duration) {
int minutes = duration / 60;
int seconds = duration % 60;

return String.format("%d:%02d", minutes, seconds);
}

public static void RegisterTooltip() {
UkrainianDelight.LOGGER.info("Registering ToolTip for " + UkrainianDelight.MOD_ID + " items");
}


}
3 changes: 1 addition & 2 deletions src/main/resources/assets/farmersdelight/lang/uk_ua.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"item.farmersdelight.cabbage_rolls": "Капустяні рулетики",
"farmersdelight.container.cooking_pot.served_on": "Подається в: %s"
"item.farmersdelight.cabbage_rolls": "Капустяні рулетики"
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/minecraft/lang/uk_ua.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"item.minecraft.beetroot_soup": "Суп з буряка"
}
}
8 changes: 6 additions & 2 deletions src/main/resources/assets/ukrainian_delight/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -13,11 +13,15 @@
"tooltip.ukrainian_delight.no_effects": "No effects",

"amplifier.none": "",
"amplifier.1": " I",
"amplifier.1": "",
"amplifier.2": " II",
"amplifier.3": " III",
"amplifier.4": " IV",
"amplifier.5": " V",
"amplifier.6": " VI",
"amplifier.7": " VII"
"amplifier.7": " VII",
"amplifier.8": " VIII",
"amplifier.9": " IX",
"amplifier.10": " X"

}
Original file line number Diff line number Diff line change
@@ -11,4 +11,5 @@
"block.ukrainian_delight.salt_block": "Солевий блок",

"tooltip.ukrainian_delight.no_effects": "Немає ефектів"

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"replace": false,
"values": [
"test:ruby_block",
"test:raw_ruby_block",
"test:ruby_ore",
"test:deepslate_ruby_ore",
"test:nether_ruby_ore",
"test:end_stone_ruby_ore"

]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"replace": false,
"values": [

"ukrainian_delight:salt_block"
]
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"replace": false,
"values": [
"test:raw_ruby_block",
"test:ruby_ore",
"test:ruby_ore",
"test:deepslate_ruby_ore",
"test:nether_ruby_ore",
"test:end_stone_ruby_ore"
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"replace": false,
"values": [
"test:ruby_block"

]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
],
"name": "ukrainian_delight:salt_block"
},
{
"type": "minecraft:item",
"functions": [
{
"add": false,
"count": {
"type": "minecraft:uniform",
"max": 5.0,
"min": 2.0
},
"function": "minecraft:set_count"
},
{
"enchantment": "minecraft:fortune",
"formula": "minecraft:ore_drops",
"function": "minecraft:apply_bonus"
},
{
"function": "minecraft:explosion_decay"
}
],
"name": "ukrainian_delight:salt"
}
]
}
],
"rolls": 1.0
}
],
"random_sequence": "ukrainian_delight:blocks/salt_block"
}

0 comments on commit df673c7

Please sign in to comment.