Skip to content

Commit

Permalink
dont use ItemComponent static fields
Browse files Browse the repository at this point in the history
closes #241
  • Loading branch information
deirn committed Nov 22, 2023
1 parent 7263ed0 commit 084db45
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import java.util.List;

import mcp.mobius.waila.api.ITooltipComponent;
import mcp.mobius.waila.api.__internal__.ApiSide;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;

/**
* Component that renders items that dynamically grow based on available space.
*/
@ApiSide.ClientOnly
public class ItemListComponent implements ITooltipComponent.HorizontalGrowing {

public ItemListComponent(List<ItemStack> items) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/mcp/mobius/waila/service/ApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public Path getConfigDir() {
return Waila.CONFIG_DIR;
}


@Override
public <T> IRegistryFilter.Builder<T> createRegistryFilterBuilder(ResourceKey<? extends Registry<T>> registryKey) {
return new RegistryFilter.Builder<>(registryKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public enum PlantProvider implements IBlockComponentProvider {

INSTANCE;

static final ITooltipComponent WHEAT_STACK = new ItemComponent(Items.WHEAT);
static final ITooltipComponent BEETROOT_STACK = new ItemComponent(Items.BEETROOT);

private static void addMaturityTooltip(ITooltip tooltip, float growthValue) {
growthValue *= 100.0F;
if (growthValue < 100.0F) {
Expand All @@ -38,10 +35,10 @@ private static void addMaturityTooltip(ITooltip tooltip, float growthValue) {
@Override
public ITooltipComponent getIcon(IBlockAccessor accessor, IPluginConfig config) {
if (accessor.getBlock() == Blocks.WHEAT)
return WHEAT_STACK;
return new ItemComponent(Items.WHEAT);

if (accessor.getBlock() == Blocks.BEETROOTS)
return BEETROOT_STACK;
return new ItemComponent(Items.BEETROOT);

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import mcp.mobius.waila.plugin.vanilla.config.Options;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -18,17 +19,17 @@ public enum PlayerHeadProvider implements IBlockComponentProvider {

INSTANCE;

static final ItemComponent PLAYER_HEAD_STACK = new ItemComponent(Items.PLAYER_HEAD);
static final ItemStack PLAYER_HEAD_STACK = new ItemStack(Items.PLAYER_HEAD);

@Nullable
@Override
public ITooltipComponent getIcon(IBlockAccessor accessor, IPluginConfig config) {
SkullBlockEntity skull = accessor.getBlockEntity();
if (skull != null && skull.getOwnerProfile() != null) {
var tag = PLAYER_HEAD_STACK.stack.getOrCreateTag();
var tag = PLAYER_HEAD_STACK.getOrCreateTag();
var skullOwner = tag.getCompound("SkullOwner");
tag.put("SkullOwner", NbtUtils.writeGameProfile(skullOwner, skull.getOwnerProfile()));
return PLAYER_HEAD_STACK;
return new ItemComponent(PLAYER_HEAD_STACK);
}
return null;
}
Expand Down

0 comments on commit 084db45

Please sign in to comment.