Skip to content

Commit

Permalink
Fix FoodStats tooltip (#2161)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuiceyBeans authored Oct 13, 2024
1 parent 4209e6d commit 05416db
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/generated/resources/assets/gtceu/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -3947,7 +3947,7 @@
"gtceu.tooltip.fluid_pipe_hold_shift": "oɟuI ʇuǝɯuıɐʇuoƆ pınןℲ ʍoɥs oʇ ⟘ℲIHS pןoHㄥ§",
"gtceu.tooltip.hold_ctrl": "oɟuı ǝɹoɯ ɹoɟ Ꞁᴚ⟘Ɔ pןoHㄥ§",
"gtceu.tooltip.hold_shift": "oɟuı ǝɹoɯ ɹoɟ ⟘ℲIHS pןoHㄥ§",
"gtceu.tooltip.potion.each": "buıuǝddɐɥ ɟo ǝɔuɐɥɔ ɹ§%s%%ɐ§ ɐ ɥʇıʍ sʞɔıʇ ɹ§%sɔ§ ɹoɟ ɹ§%s %sǝ§ ",
"gtceu.tooltip.potion.each": "ɹ§buıuǝddɐɥ ɟo ǝɔuɐɥɔㄥ§ %s%% ɹ§ɐ ɥʇıʍ sʞɔıʇㄥ§ %s ɹ§ɹoɟㄥ§ %s %s",
"gtceu.tooltip.potion.header": ":sʇɔǝɟɟǝ suıɐʇuoƆ9§",
"gtceu.tooltip.proxy_bind": "%s %s %s ʇɐ ɹǝɟɟnᗺ uɹǝʇʇɐԀ ɐ oʇ buıpuıᗺɟ§",
"gtceu.tooltip.tool_fluid_hold_shift": "oɟuI ןoo⟘ puɐ ʇuǝɯuıɐʇuoƆ pınןℲ ʍoɥs oʇ ⟘ℲIHS pןoHㄥ§",
Expand Down
2 changes: 1 addition & 1 deletion src/generated/resources/assets/gtceu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -3947,7 +3947,7 @@
"gtceu.tooltip.fluid_pipe_hold_shift": "§7Hold SHIFT to show Fluid Containment Info",
"gtceu.tooltip.hold_ctrl": "§7Hold CTRL for more info",
"gtceu.tooltip.hold_shift": "§7Hold SHIFT for more info",
"gtceu.tooltip.potion.each": " §e%s %s§r for §c%s§r ticks with a §a%s%%§r chance of happening",
"gtceu.tooltip.potion.each": "%s %s §7for§r %s §7ticks with a§r %s%% §7chance of happening§r",
"gtceu.tooltip.potion.header": "§6Contains effects:",
"gtceu.tooltip.proxy_bind": "§fBinding to a Pattern Buffer at %s %s %s",
"gtceu.tooltip.tool_fluid_hold_shift": "§7Hold SHIFT to show Fluid Containment and Tool Info",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,28 @@ public class FoodStats implements IEdibleItem, IInteractionItem, IAddInformation
protected final FoodProperties properties;

protected final boolean isDrink;

@Nullable
protected final Supplier<ItemStack> containerItem;

public FoodStats(FoodProperties properties, boolean isDrink, boolean hasPotionEffects,
@Nullable Supplier<ItemStack> containerItem) {
this.properties = properties;
this.isDrink = isDrink;
this.containerItem = containerItem;
}

public FoodStats(FoodProperties properties, boolean isDrink, @Nullable Supplier<ItemStack> containerItem) {
this.properties = properties;
this.isDrink = isDrink;
this.containerItem = containerItem;
}

public FoodStats(FoodProperties properties) {
this.properties = properties;
this.isDrink = false;
this.containerItem = null;
}

@Override
public FoodProperties getFoodProperties(ItemStack stack, @Nullable LivingEntity entity) {
return properties;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/gregtechceu/gtceu/common/data/GTItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -2376,8 +2376,7 @@ public Component getItemName(ItemStack stack) {
new FoodProperties.Builder().nutrition(1)
.effect(() -> new MobEffectInstance(MobEffects.HUNGER, 400), .40f)
.effect(() -> new MobEffectInstance(MobEffects.POISON, 100), .05f)
.build(),
false, null)))
.build())))
.tag(CustomTags.DOUGHS)
.register();
public static ItemEntry<ComponentItem> PLANT_BALL = REGISTRATE.item("plant_ball", ComponentItem::create)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ public static void init(RegistrateLangProvider provider) {
provider.add("effect.gtceu.weak_poison", "Weak Poison");

provider.add("gtceu.tooltip.potion.header", "§6Contains effects:");
provider.add("gtceu.tooltip.potion.each", " §e%s %s§r for §c%s§r ticks with a §a%s%%§r chance of happening");
provider.add("gtceu.tooltip.potion.each", "%s %s §7for§r %s §7ticks with a§r %s%% §7chance of happening§r");
}

/**
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/com/gregtechceu/gtceu/utils/GTUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.lowdragmc.lowdraglib.side.fluid.FluidHelper;
import com.lowdragmc.lowdraglib.side.fluid.FluidStack;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand All @@ -24,6 +25,7 @@
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.util.RandomSource;
Expand Down Expand Up @@ -496,15 +498,21 @@ public static Tuple<ItemStack, MutableComponent> getMaintenanceText(byte flag) {
}

public static void addPotionTooltip(List<Pair<MobEffectInstance, Float>> effects, List<Component> list) {
list.add(Component.translatable("gtceu.tooltip.potion.header"));
if (!effects.isEmpty()) {
list.add(Component.translatable("gtceu.tooltip.potion.header"));
}
effects.forEach(pair -> {
var effect = pair.getFirst();
float probability = pair.getSecond();
list.add(Component.translatable("gtceu.tooltip.potion.each",
Component.translatable(effect.getDescriptionId()),
Component.translatable("enchantment.level." + (effect.getAmplifier() + 1)),
effect.getDuration(),
100 * probability));
Component.translatable(effect.getDescriptionId())
.setStyle(Style.EMPTY.withColor(ChatFormatting.YELLOW)),
Component.translatable("enchantment.level." + (effect.getAmplifier() + 1))
.setStyle(Style.EMPTY.withColor(ChatFormatting.YELLOW)),
Component.literal(String.valueOf(effect.getDuration()))
.setStyle(Style.EMPTY.withColor(ChatFormatting.RED)),
Component.literal(String.valueOf(100 * probability))
.setStyle(Style.EMPTY.withColor(ChatFormatting.GREEN))));
});
}
}

0 comments on commit 05416db

Please sign in to comment.