Merge branch '1.18'

# Conflicts:
#	build.gradle
#	src/main/java/de/ellpeck/prettypipes/Registry.java
#	src/main/java/de/ellpeck/prettypipes/misc/ItemFilter.java
#	src/main/java/de/ellpeck/prettypipes/pipe/modules/retrieval/RetrievalModuleItem.java
#	src/main/java/de/ellpeck/prettypipes/terminal/containers/CraftingTerminalGui.java
#	src/main/java/de/ellpeck/prettypipes/terminal/containers/ItemTerminalGui.java
This commit is contained in:
Ell 2022-07-04 13:17:48 +02:00
commit 69fa29aa46
20 changed files with 272 additions and 75 deletions

View file

@ -1,9 +1,11 @@
package de.ellpeck.prettypipes.items; package de.ellpeck.prettypipes.items;
import de.ellpeck.prettypipes.misc.DirectionSelector;
import de.ellpeck.prettypipes.misc.ItemFilter; import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity; import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -17,9 +19,9 @@ public interface IModule {
void tick(ItemStack module, PipeBlockEntity tile); void tick(ItemStack module, PipeBlockEntity tile);
boolean canNetworkSee(ItemStack module, PipeBlockEntity tile); boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler);
boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack); boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination);
int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination); int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination);
@ -44,4 +46,6 @@ public interface IModule {
Integer getCustomNextNode(ItemStack module, PipeBlockEntity tile, List<BlockPos> nodes, int index); Integer getCustomNextNode(ItemStack module, PipeBlockEntity tile, List<BlockPos> nodes, int index);
ItemFilter getItemFilter(ItemStack module, PipeBlockEntity tile); ItemFilter getItemFilter(ItemStack module, PipeBlockEntity tile);
DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile);
} }

View file

@ -2,10 +2,12 @@ package de.ellpeck.prettypipes.items;
import de.ellpeck.prettypipes.Registry; import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.Utility; import de.ellpeck.prettypipes.Utility;
import de.ellpeck.prettypipes.misc.DirectionSelector;
import de.ellpeck.prettypipes.misc.ItemFilter; import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity; import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -45,12 +47,12 @@ public abstract class ModuleItem extends Item implements IModule {
} }
@Override @Override
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile) { public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler) {
return true; return true;
} }
@Override @Override
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) { public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
return true; return true;
} }
@ -103,4 +105,9 @@ public abstract class ModuleItem extends Item implements IModule {
public ItemFilter getItemFilter(ItemStack module, PipeBlockEntity tile) { public ItemFilter getItemFilter(ItemStack module, PipeBlockEntity tile) {
return null; return null;
} }
@Override
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
return null;
}
} }

View file

@ -0,0 +1,107 @@
package de.ellpeck.prettypipes.misc;
import de.ellpeck.prettypipes.PrettyPipes;
import de.ellpeck.prettypipes.packets.PacketButton;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.gui.widget.ExtendedButton;
import org.apache.commons.lang3.ArrayUtils;
public class DirectionSelector {
private static final Direction[] ALL = ArrayUtils.addAll(Direction.values(), (Direction) null);
// null means old behavior, which is all directions
private Direction direction;
private boolean modified;
private final ItemStack stack;
private final PipeBlockEntity pipe;
public DirectionSelector(ItemStack stack, PipeBlockEntity pipe) {
this.stack = stack;
this.pipe = pipe;
this.load();
}
@OnlyIn(Dist.CLIENT)
public AbstractWidget getButton(int x, int y) {
return new ExtendedButton(x, y, 100, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".populate"), button ->
PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.DIRECTION_SELECTOR)) {
@Override
public Component getMessage() {
var pipe = DirectionSelector.this.pipe;
var dir = DirectionSelector.this.direction;
MutableComponent msg = new TranslatableComponent("dir." + PrettyPipes.ID + "." + (dir != null ? dir.getName() : "all"));
if (dir != null) {
var blockName = pipe.getItemHandler(dir) != null ? pipe.getLevel().getBlockState(pipe.getBlockPos().relative(dir)).getBlock().getName() : null;
if (blockName != null)
msg = msg.append(" (").append(blockName).append(")");
}
return msg;
}
};
}
public void onButtonPacket() {
var dir = this.direction;
do {
dir = DirectionSelector.ALL[(ArrayUtils.indexOf(DirectionSelector.ALL, dir) + 1) % DirectionSelector.ALL.length];
} while (!this.isDirectionValid(dir));
if (this.direction != dir) {
this.direction = dir;
this.modified = true;
}
}
public void save() {
if (!this.modified)
return;
this.modified = false;
var tag = new CompoundTag();
if (this.direction != null)
tag.putString("direction", this.direction.getName());
this.stack.getOrCreateTag().put("direction_selector", tag);
}
public void load() {
if (this.stack.hasTag()) {
var tag = this.stack.getTag().getCompound("direction_selector");
this.direction = Direction.byName(tag.getString("direction"));
}
}
public Direction[] directions() {
return this.direction != null ? new Direction[]{this.direction} : Direction.values();
}
public boolean has(Direction dir) {
return this.direction == null || this.direction == dir;
}
private boolean isDirectionValid(Direction dir) {
if (dir == null)
return true;
if (this.pipe.getItemHandler(dir) == null)
return false;
return this.pipe.streamModules()
.filter(p -> p.getLeft() != this.stack)
.map(p -> p.getRight().getDirectionSelector(p.getLeft(), this.pipe))
.noneMatch(p -> p != null && p.direction == dir);
}
public interface IDirectionContainer {
DirectionSelector getSelector();
}
}

View file

@ -11,7 +11,7 @@ import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.inventory.Slot; import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -48,20 +48,25 @@ public class ItemFilter extends ItemStackHandler {
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public List<AbstractWidget> getButtons(Screen gui, int x, int y) { public List<AbstractWidget> getButtons(Screen gui, int x, int y, boolean rightAligned) {
List<AbstractWidget> buttons = new ArrayList<>(); List<AbstractWidget> buttons = new ArrayList<>();
if (this.canModifyWhitelist) { if (this.canModifyWhitelist) {
Supplier<Component> whitelistText = () -> Component.translatable("info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist")); var whitelistText = (Supplier<String>) () -> "info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist");
buttons.add(new Button(x, y, 70, 20, whitelistText.get(), button -> { buttons.add(new Button(x - 20, y, 20, 20, new TranslatableComponent(whitelistText.get()), button -> {
PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0); PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0);
button.setMessage(whitelistText.get()); button.setMessage(new TranslatableComponent(whitelistText.get()));
})); }) {
}
if (this.canPopulateFromInventories) {
buttons.add(new Button(x + 72, y, 70, 20, Component.translatable("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)) {
@Override @Override
public void renderToolTip(PoseStack matrix, int x, int y) { public void renderToolTip(PoseStack matrix, int x, int y) {
gui.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY), x, y); gui.renderTooltip(matrix, new TranslatableComponent(whitelistText.get() + ".description").withStyle(ChatFormatting.GRAY), x, y);
}
});
}
if (this.canPopulateFromInventories) {
buttons.add(new Button(x - 42, y, 20, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)) {
@Override
public void renderToolTip(PoseStack matrix, int x, int y) {
gui.renderTooltip(matrix, new TranslatableComponent("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY), x, y);
} }
}); });
} }

View file

@ -147,7 +147,7 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundTag>, GraphL
if (!this.world.isLoaded(pipePos)) if (!this.world.isLoaded(pipePos))
continue; continue;
var pipe = this.getPipe(pipePos); var pipe = this.getPipe(pipePos);
var dest = pipe.getAvailableDestination(stack, false, preventOversending); var dest = pipe.getAvailableDestination(Direction.values(), stack, false, preventOversending);
if (dest == null || dest.getLeft().equals(startInventory)) if (dest == null || dest.getLeft().equals(startInventory))
continue; continue;
var sup = (Function<Float, IPipeItem>) speed -> itemSupplier.apply(dest.getRight(), speed); var sup = (Function<Float, IPipeItem>) speed -> itemSupplier.apply(dest.getRight(), speed);
@ -324,11 +324,9 @@ public class PipeNetwork implements ICapabilitySerializable<CompoundTag>, GraphL
if (!this.world.isLoaded(dest)) if (!this.world.isLoaded(dest))
continue; continue;
var pipe = this.getPipe(dest); var pipe = this.getPipe(dest);
if (!pipe.canNetworkSee())
continue;
for (var dir : Direction.values()) { for (var dir : Direction.values()) {
var handler = pipe.getItemHandler(dir); var handler = pipe.getItemHandler(dir);
if (handler == null) if (handler == null || !pipe.canNetworkSee(dir, handler))
continue; continue;
// check if this handler already exists (double-connected pipes, double chests etc.) // check if this handler already exists (double-connected pipes, double chests etc.)
if (info.stream().anyMatch(l -> handler.equals(l.getItemHandler(this.world)))) if (info.stream().anyMatch(l -> handler.equals(l.getItemHandler(this.world))))

View file

@ -26,6 +26,8 @@ import org.apache.logging.log4j.util.TriConsumer;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.function.Supplier; import java.util.function.Supplier;
import static de.ellpeck.prettypipes.misc.DirectionSelector.IDirectionContainer;
public class PacketButton { public class PacketButton {
private BlockPos pos; private BlockPos pos;
@ -121,6 +123,10 @@ public class PacketButton {
TAG_FILTER((pos, data, player) -> { TAG_FILTER((pos, data, player) -> {
var container = (FilterModifierModuleContainer) player.containerMenu; var container = (FilterModifierModuleContainer) player.containerMenu;
FilterModifierModuleItem.setFilterTag(container.moduleStack, container.getTags().get(data[0])); FilterModifierModuleItem.setFilterTag(container.moduleStack, container.getTags().get(data[0]));
}),
DIRECTION_SELECTOR((pos, data, player) -> {
if (player.containerMenu instanceof IDirectionContainer filtered)
filtered.getSelector().onButtonPacket();
}); });
public final TriConsumer<BlockPos, int[], Player> action; public final TriConsumer<BlockPos, int[], Player> action;

View file

@ -166,7 +166,7 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
} }
public Pair<BlockPos, ItemStack> getAvailableDestinationOrConnectable(ItemStack stack, boolean force, boolean preventOversending) { public Pair<BlockPos, ItemStack> getAvailableDestinationOrConnectable(ItemStack stack, boolean force, boolean preventOversending) {
var dest = this.getAvailableDestination(stack, force, preventOversending); var dest = this.getAvailableDestination(Direction.values(), stack, force, preventOversending);
if (dest != null) if (dest != null)
return dest; return dest;
// if there's no available destination, try inserting into terminals etc. // if there's no available destination, try inserting into terminals etc.
@ -184,15 +184,15 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
return null; return null;
} }
public Pair<BlockPos, ItemStack> getAvailableDestination(ItemStack stack, boolean force, boolean preventOversending) { public Pair<BlockPos, ItemStack> getAvailableDestination(Direction[] directions, ItemStack stack, boolean force, boolean preventOversending) {
if (!this.canWork()) if (!this.canWork())
return null; return null;
if (!force && this.streamModules().anyMatch(m -> !m.getRight().canAcceptItem(m.getLeft(), this, stack))) for (var dir : directions) {
return null;
for (var dir : Direction.values()) {
var handler = this.getItemHandler(dir); var handler = this.getItemHandler(dir);
if (handler == null) if (handler == null)
continue; continue;
if (!force && this.streamModules().anyMatch(m -> !m.getRight().canAcceptItem(m.getLeft(), this, stack, dir, handler)))
continue;
var remain = ItemHandlerHelper.insertItem(handler, stack, true); var remain = ItemHandlerHelper.insertItem(handler, stack, true);
// did we insert anything? // did we insert anything?
if (remain.getCount() == stack.getCount()) if (remain.getCount() == stack.getCount())
@ -314,13 +314,9 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
return null; return null;
} }
public boolean isConnectedInventory(Direction dir) {
return this.getItemHandler(dir) != null;
}
public boolean canHaveModules() { public boolean canHaveModules() {
for (var dir : Direction.values()) { for (var dir : Direction.values()) {
if (this.isConnectedInventory(dir)) if (this.getItemHandler(dir) != null)
return true; return true;
var connectable = this.getPipeConnectable(dir); var connectable = this.getPipeConnectable(dir);
if (connectable != null && connectable.allowsModules(this.worldPosition, dir)) if (connectable != null && connectable.allowsModules(this.worldPosition, dir))
@ -329,8 +325,8 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
return false; return false;
} }
public boolean canNetworkSee() { public boolean canNetworkSee(Direction direction, IItemHandler handler) {
return this.streamModules().allMatch(m -> m.getRight().canNetworkSee(m.getLeft(), this)); return this.streamModules().allMatch(m -> m.getRight().canNetworkSee(m.getLeft(), this, direction, handler));
} }
public Stream<Pair<ItemStack, IModule>> streamModules() { public Stream<Pair<ItemStack, IModule>> streamModules() {

View file

@ -13,10 +13,12 @@ import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
import de.ellpeck.prettypipes.terminal.CraftingTerminalBlockEntity; import de.ellpeck.prettypipes.terminal.CraftingTerminalBlockEntity;
import de.ellpeck.prettypipes.terminal.ItemTerminalBlockEntity; import de.ellpeck.prettypipes.terminal.ItemTerminalBlockEntity;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -54,12 +56,12 @@ public class CraftingModuleItem extends ModuleItem {
} }
@Override @Override
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile) { public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler) {
return false; return false;
} }
@Override @Override
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) { public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
return false; return false;
} }
@ -73,7 +75,7 @@ public class CraftingModuleItem extends ModuleItem {
network.startProfile("crafting_ingredients"); network.startProfile("crafting_ingredients");
var request = tile.craftIngredientRequests.peek(); var request = tile.craftIngredientRequests.peek();
var equalityTypes = ItemFilter.getEqualityTypes(tile); var equalityTypes = ItemFilter.getEqualityTypes(tile);
var dest = tile.getAvailableDestination(request.stack, true, true); var dest = tile.getAvailableDestination(Direction.values(), request.stack, true, true);
if (dest != null) { if (dest != null) {
var requestRemain = network.requestExistingItem(request.location, tile.getBlockPos(), dest.getLeft(), request, dest.getRight(), equalityTypes); var requestRemain = network.requestExistingItem(request.location, tile.getBlockPos(), dest.getLeft(), request, dest.getRight(), equalityTypes);
network.resolveNetworkLock(request); network.resolveNetworkLock(request);

View file

@ -1,5 +1,7 @@
package de.ellpeck.prettypipes.pipe.modules.extraction; package de.ellpeck.prettypipes.pipe.modules.extraction;
import de.ellpeck.prettypipes.misc.DirectionSelector;
import de.ellpeck.prettypipes.misc.DirectionSelector.IDirectionContainer;
import de.ellpeck.prettypipes.misc.ItemFilter; import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer; import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
@ -9,9 +11,10 @@ import net.minecraft.world.inventory.MenuType;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class ExtractionModuleContainer extends AbstractPipeContainer<ExtractionModuleItem> implements IFilteredContainer { public class ExtractionModuleContainer extends AbstractPipeContainer<ExtractionModuleItem> implements IFilteredContainer, IDirectionContainer {
public ItemFilter filter; public ItemFilter filter;
public DirectionSelector directionSelector;
public ExtractionModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) { public ExtractionModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
super(type, id, player, pos, moduleIndex); super(type, id, player, pos, moduleIndex);
@ -20,6 +23,8 @@ public class ExtractionModuleContainer extends AbstractPipeContainer<ExtractionM
@Override @Override
protected void addSlots() { protected void addSlots() {
this.filter = this.module.getItemFilter(this.moduleStack, this.tile); this.filter = this.module.getItemFilter(this.moduleStack, this.tile);
this.directionSelector = this.module.getDirectionSelector(this.moduleStack, this.tile);
for (var slot : this.filter.getSlots((176 - this.module.filterSlots * 18) / 2 + 1, 17 + 32)) for (var slot : this.filter.getSlots((176 - this.module.filterSlots * 18) / 2 + 1, 17 + 32))
this.addSlot(slot); this.addSlot(slot);
} }
@ -28,10 +33,16 @@ public class ExtractionModuleContainer extends AbstractPipeContainer<ExtractionM
public void removed(Player playerIn) { public void removed(Player playerIn) {
super.removed(playerIn); super.removed(playerIn);
this.filter.save(); this.filter.save();
this.directionSelector.save();
} }
@Override @Override
public ItemFilter getFilter() { public ItemFilter getFilter() {
return this.filter; return this.filter;
} }
@Override
public DirectionSelector getSelector() {
return this.directionSelector;
}
} }

View file

@ -13,7 +13,8 @@ public class ExtractionModuleGui extends AbstractPipeGui<ExtractionModuleContain
@Override @Override
protected void init() { protected void init() {
super.init(); super.init();
for (var widget : this.menu.filter.getButtons(this, this.leftPos + 7, this.topPos + 17 + 32 + 20)) for (var widget : this.menu.filter.getButtons(this, this.leftPos + this.imageWidth - 7, this.topPos + 17 + 32 + 20, true))
this.addRenderableWidget(widget); this.addRenderableWidget(widget);
this.addRenderableWidget(this.menu.directionSelector.getButton(this.leftPos + 7, this.topPos + 17 + 32 + 20));
} }
} }

View file

@ -4,6 +4,7 @@ import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.items.IModule; import de.ellpeck.prettypipes.items.IModule;
import de.ellpeck.prettypipes.items.ModuleItem; import de.ellpeck.prettypipes.items.ModuleItem;
import de.ellpeck.prettypipes.items.ModuleTier; import de.ellpeck.prettypipes.items.ModuleTier;
import de.ellpeck.prettypipes.misc.DirectionSelector;
import de.ellpeck.prettypipes.misc.ItemFilter; import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.network.PipeNetwork; import de.ellpeck.prettypipes.network.PipeNetwork;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity; import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
@ -12,6 +13,7 @@ import net.minecraft.core.Direction;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class ExtractionModuleItem extends ModuleItem { public class ExtractionModuleItem extends ModuleItem {
@ -33,12 +35,12 @@ public class ExtractionModuleItem extends ModuleItem {
if (!tile.shouldWorkNow(this.speed) || !tile.canWork()) if (!tile.shouldWorkNow(this.speed) || !tile.canWork())
return; return;
var filter = this.getItemFilter(module, tile); var filter = this.getItemFilter(module, tile);
var dirSelector = this.getDirectionSelector(module, tile);
var network = PipeNetwork.get(tile.getLevel()); for (var dir : dirSelector.directions()) {
for (var dir : Direction.values()) {
var handler = tile.getItemHandler(dir); var handler = tile.getItemHandler(dir);
if (handler == null) if (handler == null)
continue; continue;
var network = PipeNetwork.get(tile.getLevel());
for (var j = 0; j < handler.getSlots(); j++) { for (var j = 0; j < handler.getSlots(); j++) {
var stack = handler.extractItem(j, this.maxExtraction, true); var stack = handler.extractItem(j, this.maxExtraction, true);
if (stack.isEmpty()) if (stack.isEmpty())
@ -55,13 +57,13 @@ public class ExtractionModuleItem extends ModuleItem {
} }
@Override @Override
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile) { public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler) {
return false; return !this.getDirectionSelector(module, tile).has(direction);
} }
@Override @Override
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) { public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
return false; return !this.getDirectionSelector(module, tile).has(direction);
} }
@Override @Override
@ -83,4 +85,9 @@ public class ExtractionModuleItem extends ModuleItem {
public ItemFilter getItemFilter(ItemStack module, PipeBlockEntity tile) { public ItemFilter getItemFilter(ItemStack module, PipeBlockEntity tile) {
return new ItemFilter(this.filterSlots, module, tile); return new ItemFilter(this.filterSlots, module, tile);
} }
@Override
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
return new DirectionSelector(module, tile);
}
} }

View file

@ -1,5 +1,7 @@
package de.ellpeck.prettypipes.pipe.modules.insertion; package de.ellpeck.prettypipes.pipe.modules.insertion;
import de.ellpeck.prettypipes.misc.DirectionSelector;
import de.ellpeck.prettypipes.misc.DirectionSelector.IDirectionContainer;
import de.ellpeck.prettypipes.misc.ItemFilter; import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer; import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
@ -9,9 +11,10 @@ import net.minecraft.world.inventory.MenuType;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class FilterModuleContainer extends AbstractPipeContainer<FilterModuleItem> implements IFilteredContainer { public class FilterModuleContainer extends AbstractPipeContainer<FilterModuleItem> implements IFilteredContainer, IDirectionContainer {
public ItemFilter filter; public ItemFilter filter;
public DirectionSelector directionSelector;
public FilterModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) { public FilterModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
super(type, id, player, pos, moduleIndex); super(type, id, player, pos, moduleIndex);
@ -26,6 +29,8 @@ public class FilterModuleContainer extends AbstractPipeContainer<FilterModuleIte
@Override @Override
protected void addSlots() { protected void addSlots() {
this.filter = this.module.getItemFilter(this.moduleStack, this.tile); this.filter = this.module.getItemFilter(this.moduleStack, this.tile);
this.directionSelector = this.module.getDirectionSelector(this.moduleStack, this.tile);
for (var slot : this.filter.getSlots((176 - Math.min(this.module.filterSlots, 9) * 18) / 2 + 1, 17 + 32)) for (var slot : this.filter.getSlots((176 - Math.min(this.module.filterSlots, 9) * 18) / 2 + 1, 17 + 32))
this.addSlot(slot); this.addSlot(slot);
} }
@ -34,10 +39,17 @@ public class FilterModuleContainer extends AbstractPipeContainer<FilterModuleIte
public void removed(Player playerIn) { public void removed(Player playerIn) {
super.removed(playerIn); super.removed(playerIn);
this.filter.save(); this.filter.save();
this.directionSelector.save();
} }
@Override @Override
public ItemFilter getFilter() { public ItemFilter getFilter() {
return this.filter; return this.filter;
} }
@Override
public DirectionSelector getSelector() {
return this.directionSelector;
}
} }

View file

@ -14,7 +14,9 @@ public class FilterModuleGui extends AbstractPipeGui<FilterModuleContainer> {
@Override @Override
protected void init() { protected void init() {
super.init(); super.init();
for (var widget : this.menu.filter.getButtons(this, this.leftPos + 7, this.topPos + 17 + 32 + 18 * Mth.ceil(this.menu.filter.getSlots() / 9F) + 2)) var buttonsY = this.topPos + 17 + 32 + 18 * Mth.ceil(this.menu.filter.getSlots() / 9F) + 2;
for (var widget : this.menu.filter.getButtons(this, this.leftPos + this.imageWidth - 7, buttonsY, true))
this.addRenderableWidget(widget); this.addRenderableWidget(widget);
this.addRenderableWidget(this.menu.directionSelector.getButton(this.leftPos + 7, buttonsY));
} }
} }

View file

@ -4,12 +4,15 @@ import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.items.IModule; import de.ellpeck.prettypipes.items.IModule;
import de.ellpeck.prettypipes.items.ModuleItem; import de.ellpeck.prettypipes.items.ModuleItem;
import de.ellpeck.prettypipes.items.ModuleTier; import de.ellpeck.prettypipes.items.ModuleTier;
import de.ellpeck.prettypipes.misc.DirectionSelector;
import de.ellpeck.prettypipes.misc.ItemFilter; import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity; import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class FilterModuleItem extends ModuleItem { public class FilterModuleItem extends ModuleItem {
@ -23,9 +26,8 @@ public class FilterModuleItem extends ModuleItem {
} }
@Override @Override
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) { public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
var filter = this.getItemFilter(module, tile); return !this.getDirectionSelector(module, tile).has(direction) || this.getItemFilter(module, tile).isAllowed(stack);
return filter.isAllowed(stack);
} }
@Override @Override
@ -49,4 +51,9 @@ public class FilterModuleItem extends ModuleItem {
filter.canPopulateFromInventories = this.canPopulateFromInventories; filter.canPopulateFromInventories = this.canPopulateFromInventories;
return filter; return filter;
} }
@Override
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
return new DirectionSelector(module, tile);
}
} }

View file

@ -1,5 +1,7 @@
package de.ellpeck.prettypipes.pipe.modules.retrieval; package de.ellpeck.prettypipes.pipe.modules.retrieval;
import de.ellpeck.prettypipes.misc.DirectionSelector;
import de.ellpeck.prettypipes.misc.DirectionSelector.IDirectionContainer;
import de.ellpeck.prettypipes.misc.ItemFilter; import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer; import de.ellpeck.prettypipes.misc.ItemFilter.IFilteredContainer;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
@ -9,9 +11,10 @@ import net.minecraft.world.inventory.MenuType;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class RetrievalModuleContainer extends AbstractPipeContainer<RetrievalModuleItem> implements IFilteredContainer { public class RetrievalModuleContainer extends AbstractPipeContainer<RetrievalModuleItem> implements IFilteredContainer, IDirectionContainer {
public ItemFilter filter; public ItemFilter filter;
public DirectionSelector directionSelector;
public RetrievalModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) { public RetrievalModuleContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
super(type, id, player, pos, moduleIndex); super(type, id, player, pos, moduleIndex);
@ -20,6 +23,8 @@ public class RetrievalModuleContainer extends AbstractPipeContainer<RetrievalMod
@Override @Override
protected void addSlots() { protected void addSlots() {
this.filter = this.module.getItemFilter(this.moduleStack, this.tile); this.filter = this.module.getItemFilter(this.moduleStack, this.tile);
this.directionSelector = this.module.getDirectionSelector(this.moduleStack, this.tile);
for (var slot : this.filter.getSlots((176 - this.module.filterSlots * 18) / 2 + 1, 17 + 32)) for (var slot : this.filter.getSlots((176 - this.module.filterSlots * 18) / 2 + 1, 17 + 32))
this.addSlot(slot); this.addSlot(slot);
} }
@ -28,10 +33,16 @@ public class RetrievalModuleContainer extends AbstractPipeContainer<RetrievalMod
public void removed(Player playerIn) { public void removed(Player playerIn) {
super.removed(playerIn); super.removed(playerIn);
this.filter.save(); this.filter.save();
this.directionSelector.save();
} }
@Override @Override
public ItemFilter getFilter() { public ItemFilter getFilter() {
return this.filter; return this.filter;
} }
@Override
public DirectionSelector getSelector() {
return this.directionSelector;
}
} }

View file

@ -13,7 +13,8 @@ public class RetrievalModuleGui extends AbstractPipeGui<RetrievalModuleContainer
@Override @Override
protected void init() { protected void init() {
super.init(); super.init();
for (var widget : this.menu.filter.getButtons(this, this.leftPos + 7, this.topPos + 17 + 32 + 20)) for (var widget : this.menu.filter.getButtons(this, this.leftPos + this.imageWidth - 7, this.topPos + 17 + 32 + 20, true))
this.addRenderableWidget(widget); this.addRenderableWidget(widget);
this.addRenderableWidget(this.menu.directionSelector.getButton(this.leftPos + 7, this.topPos + 17 + 32 + 20));
} }
} }

View file

@ -4,13 +4,16 @@ import de.ellpeck.prettypipes.Registry;
import de.ellpeck.prettypipes.items.IModule; import de.ellpeck.prettypipes.items.IModule;
import de.ellpeck.prettypipes.items.ModuleItem; import de.ellpeck.prettypipes.items.ModuleItem;
import de.ellpeck.prettypipes.items.ModuleTier; import de.ellpeck.prettypipes.items.ModuleTier;
import de.ellpeck.prettypipes.misc.DirectionSelector;
import de.ellpeck.prettypipes.misc.ItemFilter; import de.ellpeck.prettypipes.misc.ItemFilter;
import de.ellpeck.prettypipes.network.PipeNetwork; import de.ellpeck.prettypipes.network.PipeNetwork;
import de.ellpeck.prettypipes.pipe.PipeBlockEntity; import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer; import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class RetrievalModuleItem extends ModuleItem { public class RetrievalModuleItem extends ModuleItem {
@ -31,8 +34,8 @@ public class RetrievalModuleItem extends ModuleItem {
public void tick(ItemStack module, PipeBlockEntity tile) { public void tick(ItemStack module, PipeBlockEntity tile) {
if (!tile.shouldWorkNow(this.speed) || !tile.canWork()) if (!tile.shouldWorkNow(this.speed) || !tile.canWork())
return; return;
var directions = this.getDirectionSelector(module, tile).directions();
var network = PipeNetwork.get(tile.getLevel()); var network = PipeNetwork.get(tile.getLevel());
var equalityTypes = ItemFilter.getEqualityTypes(tile); var equalityTypes = ItemFilter.getEqualityTypes(tile);
// loop through filters to see which items to pull // loop through filters to see which items to pull
for (var subFilter : tile.getFilters()) { for (var subFilter : tile.getFilters()) {
@ -42,8 +45,8 @@ public class RetrievalModuleItem extends ModuleItem {
continue; continue;
var copy = filtered.copy(); var copy = filtered.copy();
copy.setCount(this.maxExtraction); copy.setCount(this.maxExtraction);
var dest = tile.getAvailableDestination(copy, true, this.preventOversending); var dest = tile.getAvailableDestination(directions, copy, true, this.preventOversending);
if (dest == null) if (dest.getRight().isEmpty())
continue; continue;
var remain = dest.getRight().copy(); var remain = dest.getRight().copy();
// are we already waiting for crafting results? If so, don't request those again // are we already waiting for crafting results? If so, don't request those again
@ -55,13 +58,13 @@ public class RetrievalModuleItem extends ModuleItem {
} }
@Override @Override
public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile) { public boolean canNetworkSee(ItemStack module, PipeBlockEntity tile, Direction direction, IItemHandler handler) {
return false; return !this.getDirectionSelector(module, tile).has(direction);
} }
@Override @Override
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack) { public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
return false; return !this.getDirectionSelector(module, tile).has(direction);
} }
@Override @Override
@ -86,4 +89,9 @@ public class RetrievalModuleItem extends ModuleItem {
filter.isWhitelist = true; filter.isWhitelist = true;
return filter; return filter;
} }
@Override
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
return new DirectionSelector(module, tile);
}
} }

View file

@ -8,6 +8,7 @@ import de.ellpeck.prettypipes.packets.PacketHandler;
import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -24,7 +25,7 @@ public class CraftingTerminalGui extends ItemTerminalGui {
@Override @Override
protected void init() { protected void init() {
super.init(); super.init();
this.requestButton = this.addRenderableWidget(new Button(this.leftPos + 8, this.topPos + 100, 50, 20, Component.translatable("info." + PrettyPipes.ID + ".request"), button -> { this.requestButton = this.addRenderableWidget(new Button(this.leftPos + 8, this.topPos + 100, 50, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".request"), button -> {
var amount = ItemTerminalGui.requestModifier(); var amount = ItemTerminalGui.requestModifier();
// also allow holding backspace instead of alt for people whose alt key is inaccessible (linux?) // also allow holding backspace instead of alt for people whose alt key is inaccessible (linux?)
var force = Screen.hasAltDown() || InputConstants.isKeyDown(this.minecraft.getWindow().getWindow(), 259) ? 1 : 0; var force = Screen.hasAltDown() || InputConstants.isKeyDown(this.minecraft.getWindow().getWindow(), 259) ? 1 : 0;

View file

@ -20,6 +20,8 @@ import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.resources.language.I18n; import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
@ -64,13 +66,13 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
protected void init() { protected void init() {
super.init(); super.init();
this.search = this.addRenderableWidget(new EditBox(this.font, this.leftPos + this.getXOffset() + 97, this.topPos + 6, 86, 8, Component.literal(""))); this.search = this.addRenderableWidget(new EditBox(this.font, this.leftPos + this.getXOffset() + 97, this.topPos + 6, 86, 8, new TextComponent("")));
this.search.setBordered(false); this.search.setBordered(false);
this.lastSearchText = ""; this.lastSearchText = "";
if (this.items != null) if (this.items != null)
this.updateWidgets(); this.updateWidgets();
this.plusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 + 12, this.topPos + 103, 12, 12, Component.literal("+"), button -> { this.plusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 + 12, this.topPos + 103, 12, 12, new TextComponent("+"), button -> {
var modifier = ItemTerminalGui.requestModifier(); var modifier = ItemTerminalGui.requestModifier();
if (modifier > 1 && this.requestAmount == 1) { if (modifier > 1 && this.requestAmount == 1) {
this.requestAmount = modifier; this.requestAmount = modifier;
@ -81,15 +83,15 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
if (this.requestAmount > 384) if (this.requestAmount > 384)
this.requestAmount = 384; this.requestAmount = 384;
})); }));
this.minusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 24, this.topPos + 103, 12, 12, Component.literal("-"), button -> { this.minusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 24, this.topPos + 103, 12, 12, new TextComponent("-"), button -> {
this.requestAmount -= ItemTerminalGui.requestModifier(); this.requestAmount -= ItemTerminalGui.requestModifier();
if (this.requestAmount < 1) if (this.requestAmount < 1)
this.requestAmount = 1; this.requestAmount = 1;
})); }));
this.minusButton.active = false; this.minusButton.active = false;
this.requestButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 25, this.topPos + 115, 50, 20, Component.translatable("info." + PrettyPipes.ID + ".request"), button -> { this.requestButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 25, this.topPos + 115, 50, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".request"), button -> {
var widget = this.streamWidgets().filter(w -> w.selected).findFirst(); var widget = this.streamWidgets().filter(w -> w.selected).findFirst();
if (widget.isEmpty()) if (!widget.isPresent())
return; return;
var stack = widget.get().stack.copy(); var stack = widget.get().stack.copy();
stack.setCount(1); stack.setCount(1);
@ -97,7 +99,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
this.requestAmount = 1; this.requestAmount = 1;
})); }));
this.requestButton.active = false; this.requestButton.active = false;
this.orderButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos, 20, 20, Component.literal(""), button -> { this.orderButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos, 20, 20, new TextComponent(""), button -> {
if (this.sortedItems == null) if (this.sortedItems == null)
return; return;
var prefs = PlayerPrefs.get(); var prefs = PlayerPrefs.get();
@ -105,7 +107,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
prefs.save(); prefs.save();
this.updateWidgets(); this.updateWidgets();
})); }));
this.ascendingButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos + 22, 20, 20, Component.literal(""), button -> { this.ascendingButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos + 22, 20, 20, new TextComponent(""), button -> {
if (this.sortedItems == null) if (this.sortedItems == null)
return; return;
var prefs = PlayerPrefs.get(); var prefs = PlayerPrefs.get();
@ -113,7 +115,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
prefs.save(); prefs.save();
this.updateWidgets(); this.updateWidgets();
})); }));
this.cancelCraftingButton = this.addRenderableWidget(new Button(this.leftPos + this.imageWidth + 4, this.topPos + 4 + 64, 54, 20, Component.translatable("info." + PrettyPipes.ID + ".cancel_all"), b -> { this.cancelCraftingButton = this.addRenderableWidget(new Button(this.leftPos + this.imageWidth + 4, this.topPos + 4 + 64, 54, 20, new TranslatableComponent("info." + PrettyPipes.ID + ".cancel_all"), b -> {
})); }));
this.cancelCraftingButton.visible = false; this.cancelCraftingButton.visible = false;
for (var y = 0; y < 4; y++) { for (var y = 0; y < 4; y++) {
@ -206,8 +208,8 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
public void updateWidgets() { public void updateWidgets() {
var prefs = PlayerPrefs.get(); var prefs = PlayerPrefs.get();
this.ascendingButton.setMessage(Component.literal(prefs.terminalAscending ? "^" : "v")); this.ascendingButton.setMessage(new TextComponent(prefs.terminalAscending ? "^" : "v"));
this.orderButton.setMessage(Component.literal(prefs.terminalItemOrder.name().substring(0, 1))); this.orderButton.setMessage(new TextComponent(prefs.terminalItemOrder.name().substring(0, 1)));
this.cancelCraftingButton.visible = this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty(); this.cancelCraftingButton.visible = this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty();
var comparator = prefs.terminalItemOrder.comparator; var comparator = prefs.terminalItemOrder.comparator;
@ -279,13 +281,13 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
if (this.sortedItems != null) { if (this.sortedItems != null) {
var prefs = PlayerPrefs.get(); var prefs = PlayerPrefs.get();
if (this.orderButton.isHoveredOrFocused()) if (this.orderButton.isHoveredOrFocused())
this.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + ".order", I18n.get("info." + PrettyPipes.ID + ".order." + prefs.terminalItemOrder.name().toLowerCase(Locale.ROOT))), mouseX, mouseY); this.renderTooltip(matrix, new TranslatableComponent("info." + PrettyPipes.ID + ".order", I18n.get("info." + PrettyPipes.ID + ".order." + prefs.terminalItemOrder.name().toLowerCase(Locale.ROOT))), mouseX, mouseY);
if (this.ascendingButton.isHoveredOrFocused()) if (this.ascendingButton.isHoveredOrFocused())
this.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY); this.renderTooltip(matrix, new TranslatableComponent("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
} }
if (this.cancelCraftingButton.visible && this.cancelCraftingButton.isHoveredOrFocused()) { if (this.cancelCraftingButton.visible && this.cancelCraftingButton.isHoveredOrFocused()) {
var tooltip = I18n.get("info." + PrettyPipes.ID + ".cancel_all.desc").split("\n"); var tooltip = I18n.get("info." + PrettyPipes.ID + ".cancel_all.desc").split("\n");
this.renderComponentTooltip(matrix, Arrays.stream(tooltip).map(Component::literal).collect(Collectors.toList()), mouseX, mouseY); this.renderComponentTooltip(matrix, Arrays.stream(tooltip).map(TextComponent::new).collect(Collectors.toList()), mouseX, mouseY);
} }
if (!this.hoveredCrafting.isEmpty()) if (!this.hoveredCrafting.isEmpty())
this.renderTooltip(matrix, this.hoveredCrafting, mouseX, mouseY); this.renderTooltip(matrix, this.hoveredCrafting, mouseX, mouseY);

View file

@ -62,11 +62,13 @@
"container.prettypipes.item_terminal": "Item Terminal", "container.prettypipes.item_terminal": "Item Terminal",
"container.prettypipes.crafting_terminal": "Crafting Terminal", "container.prettypipes.crafting_terminal": "Crafting Terminal",
"container.prettypipes.pressurizer": "Pipe Pressurizer", "container.prettypipes.pressurizer": "Pipe Pressurizer",
"info.prettypipes.whitelist": "Allowed", "info.prettypipes.whitelist": "\u00A72A",
"info.prettypipes.blacklist": "Disallowed", "info.prettypipes.blacklist": "\u00A74D",
"info.prettypipes.whitelist.description": "Items in filter slots are allowed",
"info.prettypipes.blacklist.description": "Items in filter slots are disallowed",
"info.prettypipes.shift": "Hold Shift for info", "info.prettypipes.shift": "Hold Shift for info",
"info.prettypipes.populate": "Populate", "info.prettypipes.populate": "P",
"info.prettypipes.populate.description": "Filters items from adjacent inventories", "info.prettypipes.populate.description": "Populate filter slots with items from adjacent inventories",
"info.prettypipes.max_stack_size": "Maximum item amount", "info.prettypipes.max_stack_size": "Maximum item amount",
"info.prettypipes.limit_to_max_on": "Limit to one stack", "info.prettypipes.limit_to_max_on": "Limit to one stack",
"info.prettypipes.limit_to_max_off": "Don't limit to one stack", "info.prettypipes.limit_to_max_off": "Don't limit to one stack",
@ -88,5 +90,12 @@
"info.prettypipes.cancel_all": "Cancel", "info.prettypipes.cancel_all": "Cancel",
"info.prettypipes.cancel_all.desc": "Stops waiting for current crafting outputs\nDoesn't remove inputs from blocks", "info.prettypipes.cancel_all.desc": "Stops waiting for current crafting outputs\nDoesn't remove inputs from blocks",
"info.prettypipes.no_pipe_connected": "The terminal needs to be connected to a pipe network", "info.prettypipes.no_pipe_connected": "The terminal needs to be connected to a pipe network",
"info.prettypipes.too_many_pipes_connected": "The terminal can only be connected to a single pipe at a time" "info.prettypipes.too_many_pipes_connected": "The terminal can only be connected to a single pipe at a time",
"dir.prettypipes.up": "Up",
"dir.prettypipes.down": "Down",
"dir.prettypipes.north": "North",
"dir.prettypipes.east": "East",
"dir.prettypipes.south": "South",
"dir.prettypipes.west": "West",
"dir.prettypipes.all": "All Sides"
} }