-
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.
Loading status checks…
Changes to be committed:
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
Showing
12 changed files
with
156 additions
and
23 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
81 changes: 81 additions & 0 deletions
81
src/main/java/com/megatrex4/ukrainian_dlight/item/ToolTipHelper.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,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"); | ||
} | ||
|
||
|
||
} |
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,4 +1,3 @@ | ||
{ | ||
"item.farmersdelight.cabbage_rolls": "Капустяні рулетики", | ||
"farmersdelight.container.cooking_pot.served_on": "Подається в: %s" | ||
"item.farmersdelight.cabbage_rolls": "Капустяні рулетики" | ||
} |
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,3 +1,3 @@ | ||
{ | ||
"item.minecraft.beetroot_soup": "Суп з буряка" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ | |
"block.ukrainian_delight.salt_block": "Солевий блок", | ||
|
||
"tooltip.ukrainian_delight.no_effects": "Немає ефектів" | ||
|
||
} |
7 changes: 1 addition & 6 deletions
7
src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.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,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" | ||
|
||
] | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/resources/data/minecraft/tags/blocks/mineable/shovel.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,6 +1,6 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
|
||
"ukrainian_delight:salt_block" | ||
] | ||
} |
6 changes: 0 additions & 6 deletions
6
src/main/resources/data/minecraft/tags/blocks/needs_iron_tool.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,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" | ||
] | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/resources/data/minecraft/tags/blocks/needs_stone_tool.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,6 +1,6 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"test:ruby_block" | ||
|
||
] | ||
} |
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,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" | ||
} |