mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-27 05:38:33 +01:00
Compare commits
No commits in common. "21c0483a43867ebc77a90217ce032bab3c085eb1" and "f61178a098cd1f9f294a443ee6d3853d067f3129" have entirely different histories.
21c0483a43
...
f61178a098
12 changed files with 20 additions and 99 deletions
|
@ -52,7 +52,7 @@ mod_name=PrettyPipes
|
|||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=MIT
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.15.0
|
||||
mod_version=1.14.0
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
|
|
@ -4,7 +4,6 @@ import de.ellpeck.prettypipes.entities.PipeFrameEntity;
|
|||
import de.ellpeck.prettypipes.entities.PipeFrameRenderer;
|
||||
import de.ellpeck.prettypipes.items.*;
|
||||
import de.ellpeck.prettypipes.misc.ItemEquality;
|
||||
import de.ellpeck.prettypipes.misc.ModuleClearingRecipe;
|
||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||
import de.ellpeck.prettypipes.pipe.IPipeConnectable;
|
||||
|
@ -190,10 +189,6 @@ public final class Registry {
|
|||
.forEach(b -> output.accept(b.getValue()))).build()
|
||||
);
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.RECIPE_SERIALIZERS, h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "module_clearing"), ModuleClearingRecipe.SERIALIZER);
|
||||
});
|
||||
}
|
||||
|
||||
private static <T extends AbstractPipeContainer<?>> MenuType<T> registerPipeContainer(RegisterEvent.RegisterHelper<MenuType<?>> helper, String name) {
|
||||
|
@ -234,7 +229,5 @@ public final class Registry {
|
|||
MenuScreens.register(Registry.craftingModuleContainer, CraftingModuleGui::new);
|
||||
MenuScreens.register(Registry.filterModifierModuleContainer, FilterModifierModuleGui::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,14 +71,14 @@ public class ItemFilter extends ItemStackHandler {
|
|||
} else if (id == 1 && this.canPopulateFromInventories) {
|
||||
var changed = false;
|
||||
// populate filter from inventories
|
||||
var filters = this.pipe.getFilters(null);
|
||||
var filters = this.pipe.getFilters();
|
||||
for (var direction : Direction.values()) {
|
||||
var handler = this.pipe.getItemHandler(direction);
|
||||
if (handler == null)
|
||||
continue;
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var stack = handler.getStackInSlot(i);
|
||||
if (stack.isEmpty() || this.isFiltered(stack, null))
|
||||
if (stack.isEmpty() || this.isFiltered(stack))
|
||||
continue;
|
||||
var copy = stack.copy();
|
||||
copy.setCount(1);
|
||||
|
@ -97,14 +97,14 @@ public class ItemFilter extends ItemStackHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isAllowed(ItemStack stack, Direction direction) {
|
||||
return this.isFiltered(stack, direction) == this.isWhitelist;
|
||||
public boolean isAllowed(ItemStack stack) {
|
||||
return this.isFiltered(stack) == this.isWhitelist;
|
||||
}
|
||||
|
||||
private boolean isFiltered(ItemStack stack, Direction direction) {
|
||||
private boolean isFiltered(ItemStack stack) {
|
||||
var types = ItemFilter.getEqualityTypes(this.pipe);
|
||||
// also check if any filter increase modules have the item we need
|
||||
for (ItemStackHandler handler : this.pipe.getFilters(direction)) {
|
||||
for (ItemStackHandler handler : this.pipe.getFilters()) {
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var filter = handler.getStackInSlot(i);
|
||||
if (filter.isEmpty())
|
||||
|
@ -162,7 +162,5 @@ public class ItemFilter extends ItemStackHandler {
|
|||
|
||||
default void onFilterPopulated() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
package de.ellpeck.prettypipes.misc;
|
||||
|
||||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class ModuleClearingRecipe extends CustomRecipe {
|
||||
|
||||
public static final RecipeSerializer<ModuleClearingRecipe> SERIALIZER = new SimpleCraftingRecipeSerializer<>(ModuleClearingRecipe::new);
|
||||
|
||||
public ModuleClearingRecipe(ResourceLocation res, CraftingBookCategory cat) {
|
||||
super(res, cat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingContainer container, Level level) {
|
||||
var foundModule = false;
|
||||
for (var stack : container.getItems()) {
|
||||
if (!foundModule && stack.getItem() instanceof IModule) {
|
||||
foundModule = true;
|
||||
} else if (!stack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return foundModule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(CraftingContainer container, RegistryAccess access) {
|
||||
var module = container.getItems().stream().filter(i -> i.getItem() instanceof IModule).findFirst().orElse(ItemStack.EMPTY);
|
||||
if (!module.isEmpty())
|
||||
module = new ItemStack(module.getItem());
|
||||
return module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraftInDimensions(int x, int y) {
|
||||
return x >= 1 && y >= 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return ModuleClearingRecipe.SERIALIZER;
|
||||
}
|
||||
|
||||
}
|
|
@ -379,18 +379,13 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
|||
public int getNextNode(List<BlockPos> nodes, int index) {
|
||||
return this.streamModules()
|
||||
.map(m -> m.getRight().getCustomNextNode(m.getLeft(), this, nodes, index))
|
||||
.filter(m -> m != null && m >= 0).findFirst().orElse(index);
|
||||
.filter(Objects::nonNull).findFirst().orElse(index);
|
||||
}
|
||||
|
||||
public List<ItemFilter> getFilters(Direction direction) {
|
||||
return this.streamModules().map(p -> {
|
||||
if (direction != null) {
|
||||
var dir = p.getRight().getDirectionSelector(p.getLeft(), this);
|
||||
if (dir != null && !dir.has(direction))
|
||||
return null;
|
||||
}
|
||||
return p.getRight().getItemFilter(p.getLeft(), this);
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
public List<ItemFilter> getFilters() {
|
||||
return this.streamModules()
|
||||
.map(p -> p.getRight().getItemFilter(p.getLeft(), this))
|
||||
.filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ExtractionModuleItem extends ModuleItem {
|
|||
var stack = handler.extractItem(j, this.maxExtraction, true);
|
||||
if (stack.isEmpty())
|
||||
continue;
|
||||
if (!filter.isAllowed(stack, dir))
|
||||
if (!filter.isAllowed(stack))
|
||||
continue;
|
||||
var remain = network.routeItem(tile.getBlockPos(), tile.getBlockPos().relative(dir), stack, this.preventOversending);
|
||||
if (remain.getCount() != stack.getCount()) {
|
||||
|
@ -90,5 +90,4 @@ public class ExtractionModuleItem extends ModuleItem {
|
|||
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
|
||||
return new DirectionSelector(module, tile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class FilterModuleItem extends ModuleItem {
|
|||
|
||||
@Override
|
||||
public boolean canAcceptItem(ItemStack module, PipeBlockEntity tile, ItemStack stack, Direction direction, IItemHandler destination) {
|
||||
return !this.getDirectionSelector(module, tile).has(direction) || this.getItemFilter(module, tile).isAllowed(stack, direction);
|
||||
return !this.getDirectionSelector(module, tile).has(direction) || this.getItemFilter(module, tile).isAllowed(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,5 +56,4 @@ public class FilterModuleItem extends ModuleItem {
|
|||
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
|
||||
return new DirectionSelector(module, tile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class FilterModifierModuleContainer extends AbstractPipeContainer<FilterM
|
|||
|
||||
public List<ResourceLocation> getTags() {
|
||||
Set<ResourceLocation> unsortedTags = new HashSet<>();
|
||||
for (var filter : this.tile.getFilters(null)) {
|
||||
for (var filter : this.tile.getFilters()) {
|
||||
for (var i = 0; i < filter.getSlots(); i++) {
|
||||
var stack = filter.getStackInSlot(i);
|
||||
stack.getTags().forEach(t -> unsortedTags.add(t.location()));
|
||||
|
@ -33,5 +33,4 @@ public class FilterModifierModuleContainer extends AbstractPipeContainer<FilterM
|
|||
protected void addSlots() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RetrievalModuleItem extends ModuleItem {
|
||||
|
||||
private final int maxExtraction;
|
||||
|
@ -40,9 +38,9 @@ public class RetrievalModuleItem extends ModuleItem {
|
|||
var network = PipeNetwork.get(tile.getLevel());
|
||||
var equalityTypes = ItemFilter.getEqualityTypes(tile);
|
||||
// loop through filters to see which items to pull
|
||||
Arrays.stream(directions).flatMap(d -> tile.getFilters(d).stream()).distinct().forEach(f -> {
|
||||
for (var i = 0; i < f.getSlots(); i++) {
|
||||
var filtered = f.getStackInSlot(i);
|
||||
for (var subFilter : tile.getFilters()) {
|
||||
for (var f = 0; f < subFilter.getSlots(); f++) {
|
||||
var filtered = subFilter.getStackInSlot(f);
|
||||
if (filtered.isEmpty())
|
||||
continue;
|
||||
var copy = filtered.copy();
|
||||
|
@ -56,7 +54,7 @@ public class RetrievalModuleItem extends ModuleItem {
|
|||
if (network.requestItem(tile.getBlockPos(), dest.getLeft(), remain, equalityTypes).isEmpty())
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,5 +94,4 @@ public class RetrievalModuleItem extends ModuleItem {
|
|||
public DirectionSelector getDirectionSelector(ItemStack module, PipeBlockEntity tile) {
|
||||
return new DirectionSelector(module, tile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import de.ellpeck.prettypipes.Registry;
|
|||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import de.ellpeck.prettypipes.items.ModuleItem;
|
||||
import de.ellpeck.prettypipes.misc.ItemEquality;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
@ -43,7 +42,6 @@ public class StackSizeModuleItem extends ModuleItem {
|
|||
|
||||
@Override
|
||||
public int getMaxInsertionAmount(ItemStack module, PipeBlockEntity tile, ItemStack stack, IItemHandler destination) {
|
||||
var types = ItemFilter.getEqualityTypes(tile);
|
||||
var max = StackSizeModuleItem.getMaxStackSizeForModule(module);
|
||||
if (StackSizeModuleItem.getLimitToMaxStackSize(module))
|
||||
max = Math.min(max, stack.getMaxStackSize());
|
||||
|
@ -52,7 +50,7 @@ public class StackSizeModuleItem extends ModuleItem {
|
|||
var stored = destination.getStackInSlot(i);
|
||||
if (stored.isEmpty())
|
||||
continue;
|
||||
if (!ItemEquality.compareItems(stored, stack, types))
|
||||
if (!ItemEquality.compareItems(stored, stack))
|
||||
continue;
|
||||
amount += stored.getCount();
|
||||
if (amount >= max)
|
||||
|
@ -75,5 +73,4 @@ public class StackSizeModuleItem extends ModuleItem {
|
|||
public AbstractPipeContainer<?> getContainer(ItemStack module, PipeBlockEntity tile, int windowId, Inventory inv, Player player, int moduleIndex) {
|
||||
return new StackSizeModuleContainer(Registry.stackSizeModuleContainer, windowId, player, tile.getBlockPos(), moduleIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -161,7 +161,6 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
|
|||
// don't compare with nbt equality here or the whole hashing thing is pointless
|
||||
.filter(s -> ItemEquality.compareItems(s, filter) && s.hasTag() && s.getTag().hashCode() == nbtHash)
|
||||
.findFirst().orElse(filter);
|
||||
stack.setCount(filter.getCount());
|
||||
}
|
||||
var requested = this.requestItemImpl(stack, ItemTerminalBlockEntity.onItemUnavailable(player, false));
|
||||
if (requested > 0) {
|
||||
|
@ -322,5 +321,4 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
|
|||
player.sendSystemMessage(Component.translatable("info." + PrettyPipes.ID + ".not_found", s.getHoverName()).setStyle(Style.EMPTY.applyFormat(ChatFormatting.RED)));
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"type": "prettypipes:module_clearing",
|
||||
"category": "misc"
|
||||
}
|
Loading…
Reference in a new issue