Skip to content

Commit

Permalink
show correct name for ominous banner
Browse files Browse the repository at this point in the history
closes #308
  • Loading branch information
deirn committed Mar 9, 2025
1 parent 07cfed3 commit 5e084bc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import mcp.mobius.waila.api.data.FluidData;
import mcp.mobius.waila.plugin.vanilla.fluid.LavaDescriptor;
import mcp.mobius.waila.plugin.vanilla.fluid.WaterDescriptor;
import mcp.mobius.waila.plugin.vanilla.provider.BannerProvider;
import mcp.mobius.waila.plugin.vanilla.provider.BeaconProvider;
import mcp.mobius.waila.plugin.vanilla.provider.BeeProvider;
import mcp.mobius.waila.plugin.vanilla.provider.BeehiveProvider;
Expand Down Expand Up @@ -64,6 +65,7 @@
import net.minecraft.world.level.block.StemBlock;
import net.minecraft.world.level.block.SweetBerryBushBlock;
import net.minecraft.world.level.block.TrappedChestBlock;
import net.minecraft.world.level.block.entity.BannerBlockEntity;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
Expand All @@ -76,6 +78,8 @@ public class VanillaClientPlugin implements IWailaClientPlugin {
public void register(IClientRegistrar registrar) {
registrar.body(BlockAttributesProvider.INSTANCE, Block.class, 950);

registrar.head(BannerProvider.INSTANCE, BannerBlockEntity.class, 950);

registrar.icon(ItemEntityProvider.INSTANCE, ItemEntity.class);
registrar.head(ItemEntityProvider.INSTANCE, ItemEntity.class, 950);
registrar.body(ItemEntityProvider.INSTANCE, ItemEntity.class, 950);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package mcp.mobius.waila.plugin.vanilla.provider;

import mcp.mobius.waila.api.IBlockAccessor;
import mcp.mobius.waila.api.IBlockComponentProvider;
import mcp.mobius.waila.api.IPluginConfig;
import mcp.mobius.waila.api.ITooltip;
import mcp.mobius.waila.api.IWailaConfig;
import mcp.mobius.waila.api.WailaConstants;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.level.block.entity.BannerBlockEntity;

public enum BannerProvider implements IBlockComponentProvider {

INSTANCE;

@Override
public void appendHead(ITooltip tooltip, IBlockAccessor accessor, IPluginConfig config) {
var data = accessor.getData().raw();

BannerBlockEntity be = accessor.getBlockEntity();
if (be == null) return;

var nameComponent = be.components().get(DataComponents.ITEM_NAME);
if (nameComponent == null) return;

var name = nameComponent.getString();
if (data.contains("customName")) {
name = data.getString("customName") + " (" + name + ")";
}

tooltip.setLine(WailaConstants.OBJECT_NAME_TAG, IWailaConfig.get().getFormatter().blockName(name));
}
}

0 comments on commit 5e084bc

Please sign in to comment.