Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: separate insert/extract storage priorities #740

Merged
merged 1 commit into from
Dec 8, 2024
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Ability to differentiate between insert and extract storage priorities. By default, the extract priority will match the insert priority unless configured otherwise.

### Fixed

- Fixed External Fluid not connecting properly to fluid storages.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.refinedmods.refinedstorage.common.autocrafting.autocrafter;

import com.refinedmods.refinedstorage.common.support.amount.PriorityScreen;
import com.refinedmods.refinedstorage.common.support.containermenu.ClientProperty;
import com.refinedmods.refinedstorage.common.support.widget.AbstractSideButtonWidget;

import java.util.List;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;

import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createIdentifier;
import static com.refinedmods.refinedstorage.common.util.IdentifierUtil.createTranslation;

class AutocrafterPrioritySideButtonWidget extends AbstractSideButtonWidget {
private static final MutableComponent TITLE = createTranslation("gui", "priority");
private static final Component HELP = createTranslation("gui", "priority.autocrafter_help");
private static final ResourceLocation SPRITE = createIdentifier("widget/side_button/priority");

private final ClientProperty<Integer> property;

AutocrafterPrioritySideButtonWidget(final ClientProperty<Integer> property,
final Inventory playerInventory,
final Screen parent) {
super(createPressAction(property, playerInventory, parent));
this.property = property;
}

private static OnPress createPressAction(final ClientProperty<Integer> property,
final Inventory playerInventory,
final Screen parent) {
return btn -> Minecraft.getInstance().setScreen(
new PriorityScreen(TITLE, property.get(), property::setValue, parent, playerInventory)
);
}

@Override
protected ResourceLocation getSprite() {
return SPRITE;
}

@Override
protected MutableComponent getTitle() {
return TITLE;
}

@Override
protected List<MutableComponent> getSubText() {
return List.of(Component.literal(String.valueOf(property.getValue())).withStyle(ChatFormatting.GRAY));
}

@Override
protected Component getHelpText() {
return HELP;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.refinedmods.refinedstorage.common.support.AbstractFilterScreen;
import com.refinedmods.refinedstorage.common.support.tooltip.HelpClientTooltipComponent;
import com.refinedmods.refinedstorage.common.support.widget.History;
import com.refinedmods.refinedstorage.common.support.widget.PrioritySideButtonWidget;
import com.refinedmods.refinedstorage.common.support.widget.SearchFieldWidget;
import com.refinedmods.refinedstorage.common.support.widget.TextMarquee;

Expand Down Expand Up @@ -108,7 +107,7 @@ protected void init() {
});

addSideButton(new LockModeSideButtonWidget(getMenu().getProperty(AutocrafterPropertyTypes.LOCK_MODE)));
addSideButton(PrioritySideButtonWidget.forCrafter(
addSideButton(new AutocrafterPrioritySideButtonWidget(
getMenu().getProperty(AutocrafterPropertyTypes.PRIORITY),
playerInventory,
this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.refinedmods.refinedstorage.common.support.containermenu.ClientProperty;
import com.refinedmods.refinedstorage.common.support.widget.AbstractSideButtonWidget;

import java.util.List;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;

Expand Down Expand Up @@ -30,22 +33,24 @@ class LockModeSideButtonWidget extends AbstractSideButtonWidget {
"widget/side_button/autocrafter/lock_mode/lock_until_low_redstone_signal"
);

private static final MutableComponent NEVER_TITLE = createTranslation("gui", PREFIX + ".never");
private static final MutableComponent LOCK_UNTIL_REDSTONE_PULSE_RECEIVED_TITLE = createTranslation(
"gui", PREFIX + ".lock_until_redstone_pulse_received"
private static final List<MutableComponent> NEVER_TITLE = List.of(
createTranslation("gui", PREFIX + ".never").withStyle(ChatFormatting.GRAY)
);
private static final MutableComponent LOCK_UNTIL_CONNECTED_MACHINE_IS_EMPTY_TITLE = createTranslation(
private static final List<MutableComponent> LOCK_UNTIL_REDSTONE_PULSE_RECEIVED_TITLE = List.of(createTranslation(
"gui", PREFIX + ".lock_until_redstone_pulse_received"
).withStyle(ChatFormatting.GRAY));
private static final List<MutableComponent> LOCK_UNTIL_CONNECTED_MACHINE_IS_EMPTY_TITLE = List.of(createTranslation(
"gui", PREFIX + ".lock_until_connected_machine_is_empty"
);
private static final MutableComponent LOCK_UNTIL_ALL_OUTPUTS_ARE_RECEIVED_TITLE = createTranslation(
).withStyle(ChatFormatting.GRAY));
private static final List<MutableComponent> LOCK_UNTIL_ALL_OUTPUTS_ARE_RECEIVED_TITLE = List.of(createTranslation(
"gui", PREFIX + ".lock_until_all_outputs_are_received"
);
private static final MutableComponent LOCK_UNTIL_HIGH_REDSTONE_SIGNAL_TITLE = createTranslation(
).withStyle(ChatFormatting.GRAY));
private static final List<MutableComponent> LOCK_UNTIL_HIGH_REDSTONE_SIGNAL_TITLE = List.of(createTranslation(
"gui", PREFIX + ".lock_until_high_redstone_signal"
);
private static final MutableComponent LOCK_UNTIL_LOW_REDSTONE_SIGNAL_TITLE = createTranslation(
).withStyle(ChatFormatting.GRAY));
private static final List<MutableComponent> LOCK_UNTIL_LOW_REDSTONE_SIGNAL_TITLE = List.of(createTranslation(
"gui", PREFIX + ".lock_until_low_redstone_signal"
);
).withStyle(ChatFormatting.GRAY));

private final ClientProperty<LockMode> property;

Expand Down Expand Up @@ -76,7 +81,7 @@ protected MutableComponent getTitle() {
}

@Override
protected MutableComponent getSubText() {
protected List<MutableComponent> getSubText() {
return switch (property.getValue()) {
case NEVER -> NEVER_TITLE;
case LOCK_UNTIL_REDSTONE_PULSE_RECEIVED -> LOCK_UNTIL_REDSTONE_PULSE_RECEIVED_TITLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.refinedmods.refinedstorage.common.support.containermenu.ClientProperty;
import com.refinedmods.refinedstorage.common.support.widget.AbstractYesNoSideButtonWidget;

import javax.annotation.Nullable;

import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -26,7 +24,6 @@ class VisibleToTheAutocrafterManagerSideButtonWidget extends AbstractYesNoSideBu
super(property, TITLE, YES, NO);
}

@Nullable
@Override
protected Component getHelpText() {
return HELP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.refinedmods.refinedstorage.common.support.widget.AbstractSideButtonWidget;

import java.util.List;
import java.util.function.Supplier;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -13,13 +15,18 @@

class SearchModeSideButtonWidget extends AbstractSideButtonWidget {
private static final MutableComponent TITLE = createTranslation("gui", "autocrafter_manager.search_mode");
private static final MutableComponent SUBTEXT_ALL = createTranslation("gui", "autocrafter_manager.search_mode.all");
private static final MutableComponent SUBTEXT_PATTERN_INPUTS =
createTranslation("gui", "autocrafter_manager.search_mode.pattern_inputs");
private static final MutableComponent SUBTEXT_PATTERN_OUTPUTS =
createTranslation("gui", "autocrafter_manager.search_mode.pattern_outputs");
private static final MutableComponent SUBTEXT_AUTOCRAFTER_NAMES =
createTranslation("gui", "autocrafter_manager.search_mode.autocrafter_names");
private static final List<MutableComponent> SUBTEXT_ALL = List.of(
createTranslation("gui", "autocrafter_manager.search_mode.all").withStyle(ChatFormatting.GRAY)
);
private static final List<MutableComponent> SUBTEXT_PATTERN_INPUTS = List.of(
createTranslation("gui", "autocrafter_manager.search_mode.pattern_inputs").withStyle(ChatFormatting.GRAY)
);
private static final List<MutableComponent> SUBTEXT_PATTERN_OUTPUTS = List.of(
createTranslation("gui", "autocrafter_manager.search_mode.pattern_outputs").withStyle(ChatFormatting.GRAY)
);
private static final List<MutableComponent> SUBTEXT_AUTOCRAFTER_NAMES = List.of(
createTranslation("gui", "autocrafter_manager.search_mode.autocrafter_names").withStyle(ChatFormatting.GRAY)
);
private static final ResourceLocation SPRITE_ALL =
createIdentifier("widget/side_button/autocrafter_manager/search_mode/all");
private static final ResourceLocation SPRITE_PATTERN_INPUTS =
Expand Down Expand Up @@ -59,7 +66,7 @@ protected MutableComponent getTitle() {
}

@Override
protected MutableComponent getSubText() {
protected List<MutableComponent> getSubText() {
return switch (containerMenu.getSearchMode()) {
case ALL -> SUBTEXT_ALL;
case PATTERN_INPUTS -> SUBTEXT_PATTERN_INPUTS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.refinedmods.refinedstorage.common.support.widget.AbstractSideButtonWidget;

import java.util.List;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -11,16 +14,19 @@

class ViewTypeSideButtonWidget extends AbstractSideButtonWidget {
private static final MutableComponent TITLE = createTranslation("gui", "autocrafter_manager.view_type");
private static final MutableComponent SUBTEXT_VISIBLE =
createTranslation("gui", "autocrafter_manager.view_type.visible");
private static final List<MutableComponent> SUBTEXT_VISIBLE = List.of(
createTranslation("gui", "autocrafter_manager.view_type.visible").withStyle(ChatFormatting.GRAY)
);
private static final MutableComponent HELP_VISIBLE =
createTranslation("gui", "autocrafter_manager.view_type.visible.help");
private static final MutableComponent SUBTEXT_NOT_FULL =
createTranslation("gui", "autocrafter_manager.view_type.not_full");
private static final List<MutableComponent> SUBTEXT_NOT_FULL = List.of(
createTranslation("gui", "autocrafter_manager.view_type.not_full").withStyle(ChatFormatting.GRAY)
);
private static final MutableComponent HELP_NOT_FULL =
createTranslation("gui", "autocrafter_manager.view_type.not_full.help");
private static final MutableComponent SUBTEXT_ALL =
createTranslation("gui", "autocrafter_manager.view_type.all");
private static final List<MutableComponent> SUBTEXT_ALL = List.of(
createTranslation("gui", "autocrafter_manager.view_type.all").withStyle(ChatFormatting.GRAY)
);
private static final MutableComponent HELP_ALL =
createTranslation("gui", "autocrafter_manager.view_type.all.help");
private static final ResourceLocation SPRITE_VISIBLE =
Expand Down Expand Up @@ -56,7 +62,7 @@ protected MutableComponent getTitle() {
}

@Override
protected MutableComponent getSubText() {
protected List<MutableComponent> getSubText() {
return switch (containerMenu.getViewType()) {
case VISIBLE -> SUBTEXT_VISIBLE;
case NOT_FULL -> SUBTEXT_NOT_FULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.refinedmods.refinedstorage.common.support.containermenu.ClientProperty;
import com.refinedmods.refinedstorage.common.support.widget.AbstractSideButtonWidget;

import java.util.List;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;

Expand All @@ -12,9 +15,15 @@

class DetectorModeSideButtonWidget extends AbstractSideButtonWidget {
private static final MutableComponent TITLE = createTranslation("gui", "detector.mode");
private static final MutableComponent SUBTEXT_EQUAL = createTranslation("gui", "detector.mode.equal");
private static final MutableComponent SUBTEXT_ABOVE = createTranslation("gui", "detector.mode.above");
private static final MutableComponent SUBTEXT_UNDER = createTranslation("gui", "detector.mode.under");
private static final List<MutableComponent> SUBTEXT_EQUAL = List.of(
createTranslation("gui", "detector.mode.equal").withStyle(ChatFormatting.GRAY)
);
private static final List<MutableComponent> SUBTEXT_ABOVE = List.of(
createTranslation("gui", "detector.mode.above").withStyle(ChatFormatting.GRAY)
);
private static final List<MutableComponent> SUBTEXT_UNDER = List.of(
createTranslation("gui", "detector.mode.under").withStyle(ChatFormatting.GRAY)
);
private static final ResourceLocation EQUAL = createIdentifier("widget/side_button/detector_mode/equal");
private static final ResourceLocation ABOVE = createIdentifier("widget/side_button/detector_mode/above");
private static final ResourceLocation UNDER = createIdentifier("widget/side_button/detector_mode/under");
Expand Down Expand Up @@ -53,7 +62,7 @@ protected MutableComponent getTitle() {
}

@Override
protected MutableComponent getSubText() {
protected List<MutableComponent> getSubText() {
return switch (property.getValue()) {
case UNDER -> SUBTEXT_UNDER;
case EQUAL -> SUBTEXT_EQUAL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.refinedmods.refinedstorage.common.grid.AbstractGridContainerMenu;
import com.refinedmods.refinedstorage.common.support.widget.AbstractSideButtonWidget;

import java.util.List;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;

Expand All @@ -12,7 +15,8 @@

class ResourceTypeSideButtonWidget extends AbstractSideButtonWidget {
private static final MutableComponent TITLE = createTranslation("gui", "grid.resource_type");
private static final MutableComponent SUBTEXT_ALL = createTranslation("gui", "grid.resource_type.all");
private static final List<MutableComponent> SUBTEXT_ALL =
List.of(createTranslation("gui", "grid.resource_type.all").withStyle(ChatFormatting.GRAY));
private static final ResourceLocation ALL = createIdentifier("widget/side_button/resource_type/all");

private final AbstractGridContainerMenu menu;
Expand Down Expand Up @@ -41,11 +45,11 @@ protected MutableComponent getTitle() {
}

@Override
protected MutableComponent getSubText() {
protected List<MutableComponent> getSubText() {
final ResourceType resourceType = menu.getResourceType();
if (resourceType == null) {
return SUBTEXT_ALL;
}
return resourceType.getTitle();
return List.of(resourceType.getTitle().withStyle(ChatFormatting.GRAY));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.refinedmods.refinedstorage.common.grid.AbstractGridContainerMenu;
import com.refinedmods.refinedstorage.common.support.widget.AbstractSideButtonWidget;

import java.util.List;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;

Expand All @@ -12,10 +15,10 @@

class SortingDirectionSideButtonWidget extends AbstractSideButtonWidget {
private static final MutableComponent TITLE = createTranslation("gui", "grid.sorting.direction");
private static final MutableComponent SUBTEXT_ASCENDING =
createTranslation("gui", "grid.sorting.direction.ascending");
private static final MutableComponent SUBTEXT_DESCENDING =
createTranslation("gui", "grid.sorting.direction.descending");
private static final List<MutableComponent> SUBTEXT_ASCENDING = List.of(
createTranslation("gui", "grid.sorting.direction.ascending").withStyle(ChatFormatting.GRAY));
private static final List<MutableComponent> SUBTEXT_DESCENDING = List.of(
createTranslation("gui", "grid.sorting.direction.descending").withStyle(ChatFormatting.GRAY));
private static final ResourceLocation ASCENDING =
createIdentifier("widget/side_button/grid/sorting_direction/ascending");
private static final ResourceLocation DESCENDING =
Expand Down Expand Up @@ -49,7 +52,7 @@ protected MutableComponent getTitle() {
}

@Override
protected MutableComponent getSubText() {
protected List<MutableComponent> getSubText() {
return switch (menu.getSortingDirection()) {
case ASCENDING -> SUBTEXT_ASCENDING;
case DESCENDING -> SUBTEXT_DESCENDING;
Expand Down
Loading
Loading