Skip to content

Commit

Permalink
Dynamic gate tooltip (#9873)
Browse files Browse the repository at this point in the history
Makes the tooltip for the gates use the correct size limits.
  • Loading branch information
Raycoms committed Mar 27, 2024
1 parent 9df076b commit 269cb2a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public AbstractBlockGate(final String name, final float hardness, final int maxW
this.hardness = hardness;
}

public int getMaxWidth()
{
return maxWidth;
}

public int getMaxHeight()
{
return maxHeight;
}

@Override
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit)
{
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/minecolonies/core/items/ItemGate.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.minecolonies.core.items;

import com.minecolonies.api.blocks.decorative.AbstractBlockGate;
import com.minecolonies.api.util.constant.TranslationConstants;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -32,8 +33,12 @@ public ItemGate(
public void appendHoverText(
@NotNull final ItemStack stack, @Nullable final Level worldIn, @NotNull final List<Component> tooltip, @NotNull final TooltipFlag flagIn)
{
final MutableComponent guiHint2 = Component.translatableEscape(TranslationConstants.GATE_PLACEMENT_TOOLTIP);
guiHint2.setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_AQUA));
tooltip.add(guiHint2);
if (getBlock() instanceof final AbstractBlockGate gate)
{
final MutableComponent guiHint2 = Component.translatable(TranslationConstants.GATE_PLACEMENT_TOOLTIP,
gate.getMaxWidth(), gate.getMaxHeight(), gate.getMaxWidth() * gate.getMaxHeight());
guiHint2.setStyle(Style.EMPTY.withColor(ChatFormatting.DARK_AQUA));
tooltip.add(guiHint2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@
"enchantment.minecolonies.raider_damage_enchant": "Raider's Bane",
"enchantment.minecolonies.raider_damage_enchant.desc": "Increases damage against MineColonies raiders.",

"com.minecolonies.coremod.item.gate.place": "Autoplaces parts. The max size is 5x4 which needs a stack of 20.",
"com.minecolonies.coremod.item.gate.place": "Autoplaces parts. The max size is %sx%s which needs a stack of %s.",

"com.minecolonies.coremod.gui.workerhuts.buildprio": "Pickup Prio.: ",
"item.supplychestdeployer.invalid": "You must place it in a fitting ocean or river.",
Expand Down

0 comments on commit 269cb2a

Please # to comment.