Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public static void registerModdedBindings() {
.name(Component.translatable(keyMapping.getName()))
.description(Component.translatable("controlify.custom_binding.vanilla_description").withStyle(ChatFormatting.GRAY))
.category(/*? if >=1.21.9 {*/ keyMapping.getCategory().label() /*?} else {*/ /*Component.translatable(keyMapping.getCategory()) *//*?}*/)
.radialCandidate(RadialIcons.FABRIC_ICON)
.radialCandidate(RadialIcons.getModLoaderIcon())
.allowedContexts(BindContext.IN_GAME)
.keyEmulation(keyMapping));

Expand Down
22 changes: 19 additions & 3 deletions src/main/java/dev/isxander/controlify/bindings/RadialIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayDeque;
import java.util.Map;
Expand All @@ -24,7 +25,13 @@ public final class RadialIcons {
private static final Minecraft minecraft = Minecraft.getInstance();

public static final ResourceLocation EMPTY = CUtil.rl("empty");
public static final ResourceLocation FABRIC_ICON = ResourceLocation.fromNamespaceAndPath("fabric-resource-loader-v0", "icon.png");
private static final ResourceLocation _FABRIC_ICON = ResourceLocation.fromNamespaceAndPath("fabric-resource-loader-v0", "icon.png");
/**
* @deprecated This icon is not available on NeoForge.
* Use {@link RadialIcons#getModLoaderIcon()} instead.
*/
@Deprecated(forRemoval = true)
public static final ResourceLocation FABRIC_ICON = _FABRIC_ICON;

private static Map<ResourceLocation, RadialIcon> icons = null;
private static Queue<Runnable> deferredRegistrations = new ArrayDeque<>();
Expand Down Expand Up @@ -101,18 +108,27 @@ private static void addPotionEffects(Map<ResourceLocation, RadialIcon> map) {

private static Map<ResourceLocation, RadialIcon> registerIcons() {
Map<ResourceLocation, RadialIcon> map = new Object2ObjectOpenHashMap<>();
final ResourceLocation modLoaderIcon = getModLoaderIcon();

map.put(EMPTY, (graphics, x, y, tickDelta) -> {});
map.put(FABRIC_ICON, (graphics, x, y, tickDelta) -> {
map.put(modLoaderIcon, (graphics, x, y, tickDelta) -> {
var pose = CGuiPose.ofPush(graphics);
pose.translate(x, y);
pose.scale(0.5f, 0.5f);
Blit.tex(graphics, FABRIC_ICON, 0, 0, 0, 0, 32, 32, 32, 32);
Blit.tex(graphics, modLoaderIcon, 0, 0, 0, 0, 32, 32, 32, 32);
pose.pop();
});
addItems(map);
addPotionEffects(map);

return map;
}

public static @NotNull ResourceLocation getModLoaderIcon() {
//? if fabric {
return _FABRIC_ICON;
//?} else {
/*return getItem(net.minecraft.world.item.Items.BOOK);
*///?}
}
}