mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-23 04:08:34 +01:00
Compare commits
No commits in common. "dfb73e9917b1b7a58207b288ded6cd3fd562a7a5" and "2597923ec8db735ddd53de99bafedab7fa793d20" have entirely different histories.
dfb73e9917
...
2597923ec8
12 changed files with 57 additions and 122 deletions
|
@ -34,7 +34,7 @@ mod_name=PrettyPipes
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.17.1
|
mod_version=1.17.0
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|
|
@ -167,18 +167,6 @@ public final class Utility {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void copyInto(ItemStackHandler handler, ItemStackHandler dest) {
|
|
||||||
dest.setSize(handler.getSlots());
|
|
||||||
for (var i = 0; i < handler.getSlots(); i++)
|
|
||||||
dest.setStackInSlot(i, handler.getStackInSlot(i).copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStackHandler copy(ItemStackHandler handler) {
|
|
||||||
var ret = new ItemStackHandler();
|
|
||||||
copyInto(handler, ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IMergeItemStack {
|
public interface IMergeItemStack {
|
||||||
|
|
||||||
boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection);
|
boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection);
|
||||||
|
|
|
@ -138,7 +138,9 @@ public class ItemFilter {
|
||||||
public void load() {
|
public void load() {
|
||||||
var content = this.stack.get(Data.TYPE);
|
var content = this.stack.get(Data.TYPE);
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
Utility.copyInto(content.items, this.content);
|
this.content.setSize(content.items.getSlots());
|
||||||
|
for (var i = 0; i < this.content.getSlots(); i++)
|
||||||
|
this.content.setStackInSlot(i, content.items.getStackInSlot(i));
|
||||||
this.isWhitelist = content.whitelist;
|
this.isWhitelist = content.whitelist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
||||||
while (craftingPipes.hasNext()) {
|
while (craftingPipes.hasNext()) {
|
||||||
var pipe = craftingPipes.next();
|
var pipe = craftingPipes.next();
|
||||||
for (var request : pipe.craftResultRequests) {
|
for (var request : pipe.craftResultRequests) {
|
||||||
var dest = request.getMiddle();
|
var dest = request.getLeft();
|
||||||
var stack = request.getRight();
|
var stack = request.getRight();
|
||||||
// add up all the items that should go to the same location
|
// add up all the items that should go to the same location
|
||||||
var existing = items.stream()
|
var existing = items.stream()
|
||||||
|
|
|
@ -80,10 +80,6 @@ public record PacketButton(BlockPos pos, int result, List<Integer> data) impleme
|
||||||
return ((IModule) stack.getItem()).getContainer(stack, tile, windowId, inv, player, data.getFirst());
|
return ((IModule) stack.getItem()).getContainer(stack, tile, windowId, inv, player, data.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldTriggerClientSideContainerClosingOnOpen() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}, buf -> {
|
}, buf -> {
|
||||||
buf.writeBlockPos(pos);
|
buf.writeBlockPos(pos);
|
||||||
buf.writeInt(data.getFirst());
|
buf.writeInt(data.getFirst());
|
||||||
|
|
|
@ -271,7 +271,7 @@ public class PipeBlock extends BaseEntityBlock implements SimpleWaterloggedBlock
|
||||||
if (worldIn.getBlockEntity(pos) instanceof PipeBlockEntity pipe) {
|
if (worldIn.getBlockEntity(pos) instanceof PipeBlockEntity pipe) {
|
||||||
pipe.getItems().clear();
|
pipe.getItems().clear();
|
||||||
for (var lock : pipe.craftIngredientRequests)
|
for (var lock : pipe.craftIngredientRequests)
|
||||||
network.resolveNetworkLock(lock.getRight());
|
network.resolveNetworkLock(lock);
|
||||||
}
|
}
|
||||||
super.onRemove(state, worldIn, pos, newState, isMoving);
|
super.onRemove(state, worldIn, pos, newState, isMoving);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.Registry;
|
import de.ellpeck.prettypipes.Registry;
|
||||||
import de.ellpeck.prettypipes.Utility;
|
import de.ellpeck.prettypipes.Utility;
|
||||||
import de.ellpeck.prettypipes.items.IModule;
|
import de.ellpeck.prettypipes.items.IModule;
|
||||||
import de.ellpeck.prettypipes.misc.EquatableItemStack;
|
|
||||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||||
import de.ellpeck.prettypipes.network.NetworkLock;
|
import de.ellpeck.prettypipes.network.NetworkLock;
|
||||||
import de.ellpeck.prettypipes.network.PipeNetwork;
|
import de.ellpeck.prettypipes.network.PipeNetwork;
|
||||||
|
@ -41,7 +40,6 @@ import net.neoforged.neoforge.common.util.Lazy;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
import net.neoforged.neoforge.items.ItemStackHandler;
|
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -71,10 +69,8 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
PipeBlockEntity.this.setChanged();
|
PipeBlockEntity.this.setChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// crafting module slot, ingredient request network lock
|
public final Queue<NetworkLock> craftIngredientRequests = new LinkedList<>();
|
||||||
public final Queue<Pair<Integer, NetworkLock>> craftIngredientRequests = new LinkedList<>();
|
public final List<Pair<BlockPos, ItemStack>> craftResultRequests = new ArrayList<>();
|
||||||
// crafting module slot, destination pipe for the result, result item
|
|
||||||
public final List<Triple<Integer, BlockPos, ItemStack>> craftResultRequests = new ArrayList<>();
|
|
||||||
public PressurizerBlockEntity pressurizer;
|
public PressurizerBlockEntity pressurizer;
|
||||||
public BlockState cover;
|
public BlockState cover;
|
||||||
public int moduleDropCheck;
|
public int moduleDropCheck;
|
||||||
|
@ -101,21 +97,13 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
super.saveAdditional(compound, provider);
|
super.saveAdditional(compound, provider);
|
||||||
compound.put("modules", this.modules.serializeNBT(provider));
|
compound.put("modules", this.modules.serializeNBT(provider));
|
||||||
compound.putInt("module_drop_check", this.moduleDropCheck);
|
compound.putInt("module_drop_check", this.moduleDropCheck);
|
||||||
var requests = new ListTag();
|
compound.put("requests", Utility.serializeAll(provider, this.craftIngredientRequests));
|
||||||
for (var tuple : this.craftIngredientRequests) {
|
|
||||||
var nbt = new CompoundTag();
|
|
||||||
nbt.putInt("module_slot", tuple.getLeft());
|
|
||||||
nbt.put("lock", tuple.getRight().serializeNBT(provider));
|
|
||||||
requests.add(nbt);
|
|
||||||
}
|
|
||||||
compound.put("craft_requests", requests);
|
|
||||||
if (this.cover != null)
|
if (this.cover != null)
|
||||||
compound.put("cover", NbtUtils.writeBlockState(this.cover));
|
compound.put("cover", NbtUtils.writeBlockState(this.cover));
|
||||||
var results = new ListTag();
|
var results = new ListTag();
|
||||||
for (var triple : this.craftResultRequests) {
|
for (var triple : this.craftResultRequests) {
|
||||||
var nbt = new CompoundTag();
|
var nbt = new CompoundTag();
|
||||||
nbt.putInt("module_slot", triple.getLeft());
|
nbt.putLong("dest_pipe", triple.getLeft().asLong());
|
||||||
nbt.putLong("dest_pipe", triple.getMiddle().asLong());
|
|
||||||
nbt.put("item", triple.getRight().save(provider));
|
nbt.put("item", triple.getRight().save(provider));
|
||||||
results.add(nbt);
|
results.add(nbt);
|
||||||
}
|
}
|
||||||
|
@ -128,19 +116,12 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
this.moduleDropCheck = compound.getInt("module_drop_check");
|
this.moduleDropCheck = compound.getInt("module_drop_check");
|
||||||
this.cover = compound.contains("cover") ? NbtUtils.readBlockState(this.level != null ? this.level.holderLookup(Registries.BLOCK) : BuiltInRegistries.BLOCK.asLookup(), compound.getCompound("cover")) : null;
|
this.cover = compound.contains("cover") ? NbtUtils.readBlockState(this.level != null ? this.level.holderLookup(Registries.BLOCK) : BuiltInRegistries.BLOCK.asLookup(), compound.getCompound("cover")) : null;
|
||||||
this.craftIngredientRequests.clear();
|
this.craftIngredientRequests.clear();
|
||||||
var requests = compound.getList("craft_requests", Tag.TAG_COMPOUND);
|
this.craftIngredientRequests.addAll(Utility.deserializeAll(compound.getList("requests", Tag.TAG_COMPOUND), l -> new NetworkLock(provider, l)));
|
||||||
for (var i = 0; i < requests.size(); i++) {
|
|
||||||
var nbt = requests.getCompound(i);
|
|
||||||
this.craftIngredientRequests.add(Pair.of(
|
|
||||||
nbt.getInt("module_slot"),
|
|
||||||
new NetworkLock(provider, nbt.getCompound("lock"))));
|
|
||||||
}
|
|
||||||
this.craftResultRequests.clear();
|
this.craftResultRequests.clear();
|
||||||
var results = compound.getList("craft_results", Tag.TAG_COMPOUND);
|
var results = compound.getList("craft_results", Tag.TAG_COMPOUND);
|
||||||
for (var i = 0; i < results.size(); i++) {
|
for (var i = 0; i < results.size(); i++) {
|
||||||
var nbt = results.getCompound(i);
|
var nbt = results.getCompound(i);
|
||||||
this.craftResultRequests.add(Triple.of(
|
this.craftResultRequests.add(Pair.of(
|
||||||
nbt.getInt("module_slot"),
|
|
||||||
BlockPos.of(nbt.getLong("dest_pipe")),
|
BlockPos.of(nbt.getLong("dest_pipe")),
|
||||||
ItemStack.parseOptional(provider, nbt.getCompound("item"))));
|
ItemStack.parseOptional(provider, nbt.getCompound("item"))));
|
||||||
}
|
}
|
||||||
|
@ -378,14 +359,6 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getModuleSlot(ItemStack module) {
|
|
||||||
for (var i = 0; i < this.modules.getSlots(); i++) {
|
|
||||||
if (this.modules.getStackInSlot(i) == module)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeCover(Player player, InteractionHand hand) {
|
public void removeCover(Player player, InteractionHand hand) {
|
||||||
if (this.level.isClientSide)
|
if (this.level.isClientSide)
|
||||||
return;
|
return;
|
||||||
|
@ -427,11 +400,6 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
||||||
return new MainPipeContainer(Registry.pipeContainer, window, player, PipeBlockEntity.this.worldPosition);
|
return new MainPipeContainer(Registry.pipeContainer, window, player, PipeBlockEntity.this.worldPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldTriggerClientSideContainerClosingOnOpen() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConnectionType getConnectionType(BlockPos pipePos, Direction direction) {
|
public ConnectionType getConnectionType(BlockPos pipePos, Direction direction) {
|
||||||
var state = this.level.getBlockState(pipePos.relative(direction));
|
var state = this.level.getBlockState(pipePos.relative(direction));
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package de.ellpeck.prettypipes.pipe.modules.craft;
|
package de.ellpeck.prettypipes.pipe.modules.craft;
|
||||||
|
|
||||||
import de.ellpeck.prettypipes.Utility;
|
|
||||||
import de.ellpeck.prettypipes.misc.FilterSlot;
|
import de.ellpeck.prettypipes.misc.FilterSlot;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeContainer;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -21,7 +20,7 @@ public class CraftingModuleContainer extends AbstractPipeContainer<CraftingModul
|
||||||
@Override
|
@Override
|
||||||
protected void addSlots() {
|
protected void addSlots() {
|
||||||
var contents = this.moduleStack.get(CraftingModuleItem.Contents.TYPE);
|
var contents = this.moduleStack.get(CraftingModuleItem.Contents.TYPE);
|
||||||
this.input = Utility.copy(contents.input());
|
this.input = contents.input();
|
||||||
for (var i = 0; i < this.input.getSlots(); i++) {
|
for (var i = 0; i < this.input.getSlots(); i++) {
|
||||||
this.addSlot(new FilterSlot(this.input, i, (176 - this.input.getSlots() * 18) / 2 + 1 + i % 9 * 18, 17 + 32 + i / 9 * 18, false) {
|
this.addSlot(new FilterSlot(this.input, i, (176 - this.input.getSlots() * 18) / 2 + 1 + i % 9 * 18, 17 + 32 + i / 9 * 18, false) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,7 +32,7 @@ public class CraftingModuleContainer extends AbstractPipeContainer<CraftingModul
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.output = Utility.copy(contents.output());
|
this.output = contents.output();
|
||||||
for (var i = 0; i < this.output.getSlots(); i++) {
|
for (var i = 0; i < this.output.getSlots(); i++) {
|
||||||
this.addSlot(new FilterSlot(this.output, i, (176 - this.output.getSlots() * 18) / 2 + 1 + i % 9 * 18, 85 + i / 9 * 18, false) {
|
this.addSlot(new FilterSlot(this.output, i, (176 - this.output.getSlots() * 18) / 2 + 1 + i % 9 * 18, 85 + i / 9 * 18, false) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,10 +47,8 @@ public class CraftingModuleContainer extends AbstractPipeContainer<CraftingModul
|
||||||
@Override
|
@Override
|
||||||
public void removed(Player playerIn) {
|
public void removed(Player playerIn) {
|
||||||
super.removed(playerIn);
|
super.removed(playerIn);
|
||||||
if (this.modified) {
|
if (this.modified)
|
||||||
this.moduleStack.set(CraftingModuleItem.Contents.TYPE, new CraftingModuleItem.Contents(this.input, this.output));
|
this.moduleStack.set(CraftingModuleItem.Contents.TYPE, new CraftingModuleItem.Contents(this.input, this.output));
|
||||||
this.tile.setChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
import net.neoforged.neoforge.items.ItemStackHandler;
|
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.apache.commons.lang3.tuple.Triple;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -70,31 +69,27 @@ public class CraftingModuleItem 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 slot = tile.getModuleSlot(module);
|
|
||||||
var network = PipeNetwork.get(tile.getLevel());
|
var network = PipeNetwork.get(tile.getLevel());
|
||||||
// process crafting ingredient requests
|
// process crafting ingredient requests
|
||||||
if (!tile.craftIngredientRequests.isEmpty()) {
|
if (!tile.craftIngredientRequests.isEmpty()) {
|
||||||
network.startProfile("crafting_ingredients");
|
network.startProfile("crafting_ingredients");
|
||||||
var request = tile.craftIngredientRequests.peek();
|
var request = tile.craftIngredientRequests.peek();
|
||||||
if (request.getLeft() == slot) {
|
|
||||||
var lock = request.getRight();
|
|
||||||
var equalityTypes = ItemFilter.getEqualityTypes(tile);
|
var equalityTypes = ItemFilter.getEqualityTypes(tile);
|
||||||
var dest = tile.getAvailableDestination(Direction.values(), lock.stack, true, true);
|
var dest = tile.getAvailableDestination(Direction.values(), request.stack, true, true);
|
||||||
if (dest != null) {
|
if (dest != null) {
|
||||||
var requestRemain = network.requestExistingItem(lock.location, tile.getBlockPos(), dest.getLeft(), lock, dest.getRight(), equalityTypes);
|
var requestRemain = network.requestExistingItem(request.location, tile.getBlockPos(), dest.getLeft(), request, dest.getRight(), equalityTypes);
|
||||||
network.resolveNetworkLock(lock);
|
network.resolveNetworkLock(request);
|
||||||
tile.craftIngredientRequests.remove();
|
tile.craftIngredientRequests.remove();
|
||||||
|
|
||||||
// if we couldn't fit all items into the destination, create another request for the rest
|
// if we couldn't fit all items into the destination, create another request for the rest
|
||||||
var remain = lock.stack.copy();
|
var remain = request.stack.copy();
|
||||||
remain.shrink(dest.getRight().getCount() - requestRemain.getCount());
|
remain.shrink(dest.getRight().getCount() - requestRemain.getCount());
|
||||||
if (!remain.isEmpty()) {
|
if (!remain.isEmpty()) {
|
||||||
var remainRequest = new NetworkLock(lock.location, remain);
|
var remainRequest = new NetworkLock(request.location, remain);
|
||||||
tile.craftIngredientRequests.add(Pair.of(slot, remainRequest));
|
tile.craftIngredientRequests.add(remainRequest);
|
||||||
network.createNetworkLock(remainRequest);
|
network.createNetworkLock(remainRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
network.endProfile();
|
network.endProfile();
|
||||||
}
|
}
|
||||||
// pull requested crafting results from the network once they are stored
|
// pull requested crafting results from the network once they are stored
|
||||||
|
@ -103,15 +98,14 @@ public class CraftingModuleItem extends ModuleItem {
|
||||||
var items = network.getOrderedNetworkItems(tile.getBlockPos());
|
var items = network.getOrderedNetworkItems(tile.getBlockPos());
|
||||||
var equalityTypes = ItemFilter.getEqualityTypes(tile);
|
var equalityTypes = ItemFilter.getEqualityTypes(tile);
|
||||||
for (var request : tile.craftResultRequests) {
|
for (var request : tile.craftResultRequests) {
|
||||||
if (request.getLeft() == slot) {
|
|
||||||
var remain = request.getRight().copy();
|
var remain = request.getRight().copy();
|
||||||
var destPipe = network.getPipe(request.getMiddle());
|
var destPipe = network.getPipe(request.getLeft());
|
||||||
if (destPipe != null) {
|
if (destPipe != null) {
|
||||||
var dest = destPipe.getAvailableDestinationOrConnectable(remain, true, true);
|
var dest = destPipe.getAvailableDestinationOrConnectable(remain, true, true);
|
||||||
if (dest == null)
|
if (dest == null)
|
||||||
continue;
|
continue;
|
||||||
for (var item : items) {
|
for (var item : items) {
|
||||||
var requestRemain = network.requestExistingItem(item, request.getMiddle(), dest.getLeft(), null, dest.getRight(), equalityTypes);
|
var requestRemain = network.requestExistingItem(item, request.getLeft(), dest.getLeft(), null, dest.getRight(), equalityTypes);
|
||||||
remain.shrink(dest.getRight().getCount() - requestRemain.getCount());
|
remain.shrink(dest.getRight().getCount() - requestRemain.getCount());
|
||||||
if (remain.isEmpty())
|
if (remain.isEmpty())
|
||||||
break;
|
break;
|
||||||
|
@ -120,13 +114,12 @@ public class CraftingModuleItem extends ModuleItem {
|
||||||
tile.craftResultRequests.remove(request);
|
tile.craftResultRequests.remove(request);
|
||||||
// if we couldn't pull everything, log a new request
|
// if we couldn't pull everything, log a new request
|
||||||
if (!remain.isEmpty())
|
if (!remain.isEmpty())
|
||||||
tile.craftResultRequests.add(Triple.of(slot, request.getMiddle(), remain));
|
tile.craftResultRequests.add(Pair.of(request.getLeft(), remain));
|
||||||
network.endProfile();
|
network.endProfile();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
network.endProfile();
|
network.endProfile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +162,6 @@ public class CraftingModuleItem extends ModuleItem {
|
||||||
var craftableAmount = this.getCraftableAmount(module, tile, unavailableConsumer, stack, dependencyChain);
|
var craftableAmount = this.getCraftableAmount(module, tile, unavailableConsumer, stack, dependencyChain);
|
||||||
if (craftableAmount <= 0)
|
if (craftableAmount <= 0)
|
||||||
return stack;
|
return stack;
|
||||||
var slot = tile.getModuleSlot(module);
|
|
||||||
|
|
||||||
var network = PipeNetwork.get(tile.getLevel());
|
var network = PipeNetwork.get(tile.getLevel());
|
||||||
var items = network.getOrderedNetworkItems(tile.getBlockPos());
|
var items = network.getOrderedNetworkItems(tile.getBlockPos());
|
||||||
|
@ -189,8 +181,7 @@ public class CraftingModuleItem extends ModuleItem {
|
||||||
var copy = in.copy();
|
var copy = in.copy();
|
||||||
copy.setCount(in.getCount() * toCraft);
|
copy.setCount(in.getCount() * toCraft);
|
||||||
var ret = ItemTerminalBlockEntity.requestItemLater(tile.getLevel(), tile.getBlockPos(), items, unavailableConsumer, copy, CraftingModuleItem.addDependency(dependencyChain, module), equalityTypes);
|
var ret = ItemTerminalBlockEntity.requestItemLater(tile.getLevel(), tile.getBlockPos(), items, unavailableConsumer, copy, CraftingModuleItem.addDependency(dependencyChain, module), equalityTypes);
|
||||||
for (var lock : ret.getLeft())
|
tile.craftIngredientRequests.addAll(ret.getLeft());
|
||||||
tile.craftIngredientRequests.add(Pair.of(slot, lock));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var remain = stack.copy();
|
var remain = stack.copy();
|
||||||
|
@ -198,7 +189,7 @@ public class CraftingModuleItem extends ModuleItem {
|
||||||
|
|
||||||
var result = stack.copy();
|
var result = stack.copy();
|
||||||
result.shrink(remain.getCount());
|
result.shrink(remain.getCount());
|
||||||
tile.craftResultRequests.add(Triple.of(slot, destPipe, result));
|
tile.craftResultRequests.add(Pair.of(destPipe, result));
|
||||||
|
|
||||||
return remain;
|
return remain;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
Supplier<StackSizeModuleItem.Data> data = () -> this.menu.moduleStack.getOrDefault(StackSizeModuleItem.Data.TYPE, StackSizeModuleItem.Data.DEFAULT);
|
var data = this.menu.moduleStack.getOrDefault(StackSizeModuleItem.Data.TYPE, StackSizeModuleItem.Data.DEFAULT);
|
||||||
textField.setValue(String.valueOf(data.get().maxStackSize()));
|
textField.setValue(String.valueOf(data.maxStackSize()));
|
||||||
textField.setMaxLength(4);
|
textField.setMaxLength(4);
|
||||||
textField.setResponder(s -> {
|
textField.setResponder(s -> {
|
||||||
if (s.isEmpty())
|
if (s.isEmpty())
|
||||||
|
@ -44,7 +44,7 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
|
||||||
var amount = Integer.parseInt(s);
|
var amount = Integer.parseInt(s);
|
||||||
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_AMOUNT, List.of(amount));
|
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_AMOUNT, List.of(amount));
|
||||||
});
|
});
|
||||||
Supplier<Component> buttonText = () -> Component.translatable("info." + PrettyPipes.ID + ".limit_to_max_" + (data.get().limitToMaxStackSize() ? "on" : "off"));
|
Supplier<Component> buttonText = () -> Component.translatable("info." + PrettyPipes.ID + ".limit_to_max_" + (data.limitToMaxStackSize() ? "on" : "off"));
|
||||||
this.addRenderableWidget(Button.builder(buttonText.get(), b -> {
|
this.addRenderableWidget(Button.builder(buttonText.get(), b -> {
|
||||||
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_MODULE_BUTTON, List.of());
|
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_MODULE_BUTTON, List.of());
|
||||||
b.setMessage(buttonText.get());
|
b.setMessage(buttonText.get());
|
||||||
|
|
|
@ -218,7 +218,7 @@ public class ItemTerminalBlockEntity extends BlockEntity implements IPipeConnect
|
||||||
var otherPipe = network.getPipe(craftable.getLeft());
|
var otherPipe = network.getPipe(craftable.getLeft());
|
||||||
if (otherPipe != null) {
|
if (otherPipe != null) {
|
||||||
for (var lock : otherPipe.craftIngredientRequests)
|
for (var lock : otherPipe.craftIngredientRequests)
|
||||||
network.resolveNetworkLock(lock.getRight());
|
network.resolveNetworkLock(lock);
|
||||||
otherPipe.craftIngredientRequests.clear();
|
otherPipe.craftIngredientRequests.clear();
|
||||||
otherPipe.craftResultRequests.clear();
|
otherPipe.craftResultRequests.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,17 +64,10 @@ public class CraftingTerminalContainer extends ItemTerminalContainer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
|
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
|
||||||
if (slotId > 0) {
|
if (slotId > 0 && clickTypeIn == ClickType.PICKUP) {
|
||||||
var ghostItems = this.getTile().ghostItems;
|
|
||||||
if (clickTypeIn == ClickType.PICKUP) {
|
|
||||||
var slot = this.slots.get(slotId);
|
var slot = this.slots.get(slotId);
|
||||||
if (slot.container == this.craftInventory && !slot.hasItem())
|
if (slot.container == this.craftInventory && !slot.hasItem())
|
||||||
ghostItems.setStackInSlot(slot.getSlotIndex(), ItemStack.EMPTY);
|
this.getTile().ghostItems.setStackInSlot(slot.getSlotIndex(), ItemStack.EMPTY);
|
||||||
} else if (clickTypeIn == ClickType.QUICK_MOVE) {
|
|
||||||
// clear the entire grid when holding shift
|
|
||||||
for (var i = 0; i < ghostItems.getSlots(); i++)
|
|
||||||
ghostItems.setStackInSlot(i, ItemStack.EMPTY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
super.clicked(slotId, dragType, clickTypeIn, player);
|
super.clicked(slotId, dragType, clickTypeIn, player);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue