Skip to content

Commit

Permalink
hide actions according to Action#showInSelectAction
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Mar 16, 2024
1 parent c6dea82 commit 65a6083
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static <T extends IFactionPlayer<T>> boolean isEnabled(T player, @NotNul
}

private static <T extends IFactionPlayer<T>> ItemOrdering<IAction<?>> getOrdering(T player) {
return new ItemOrdering<>(ClientConfigHelper.getActionOrder(player.getFaction()), new ArrayList<>(), () -> ModRegistries.ACTIONS.stream().filter(action -> action.matchesFaction(player.getFaction())).collect(Collectors.toList()));
return new ItemOrdering<>(ClientConfigHelper.getActionOrder(player.getFaction()).stream().filter(s -> s.showInSelectAction(player.asEntity())).toList(), new ArrayList<>(), () -> ModRegistries.ACTIONS.stream().filter(action -> action.matchesFaction(player.getFaction())).filter(s -> s.showInSelectAction(player.asEntity())).collect(Collectors.toList()));
}

private static <T extends IFactionPlayer<T>> void saveOrdering(T player, ItemOrdering<IAction<?>> ordering) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -56,7 +57,8 @@ public static void show(KeyMapping keyMapping) {
}

private static RadialMenu<IAction<?>> getRadialMenu(List<IAction<?>> actions) {
List<IRadialMenuSlot<IAction<?>>> parts = actions.stream().map(a -> (IRadialMenuSlot<IAction<?>>)new RadialMenuSlot<IAction<?>>(a.getName(), a, Collections.emptyList())).toList();
Player player = Minecraft.getInstance().player;
List<IRadialMenuSlot<IAction<?>>> parts = actions.stream().filter(s -> s.showInSelectAction(player)).map(a -> (IRadialMenuSlot<IAction<?>>)new RadialMenuSlot<IAction<?>>(a.getName(), a, Collections.emptyList())).toList();
return new RadialMenu<>((i) -> {
VampirismMod.proxy.sendToServer(ServerboundToggleActionPacket.createFromRaytrace(RegUtil.id(parts.get(i).primarySlotIcon()), Minecraft.getInstance().hitResult));
}, parts , SelectActionRadialScreen::drawActionPart,0);
Expand Down

0 comments on commit 65a6083

Please sign in to comment.