Skip to content

Commit 53d977c

Browse files
fixed pipe connections to tile entities
1 parent 598b32c commit 53d977c

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/dev/core/pipe/item/travelingItem/TravelingItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class TravelingItem {
122122
return;
123123
}
124124
const storage = StorageInterface.getStorage(this.blockSource, x, y, z);
125-
if (this.itemMover.isValidStorage(storage)) {
125+
if (this.itemMover.isValidStorage(storage, World.getInverseBlockSide(this.itemMover.MoveVectorIndex))) {
126126
const pushedCount = storage.addItem(this.item, World.getInverseBlockSide(this.itemMover.MoveVectorIndex));
127127

128128
if (pushedCount > 0) {

src/dev/core/pipe/item/travelingItem/TravelingItemMover.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ class TravelingItemMover {
9898
}
9999

100100
public findNewMoveVector(region: BlockSource): boolean {
101-
const nextPipes = this.filterPaths(this.getRelativePaths(region), region);
101+
var relativePaths = this.getRelativePaths(region);
102+
const nextPipes = this.filterPaths(relativePaths, region);
102103
const keys = Object.keys(nextPipes);
103104

104105
if (keys.length > 0) {
@@ -170,16 +171,16 @@ class TravelingItemMover {
170171
}
171172

172173
const storage = StorageInterface.getStorage(region, x, y, z);
173-
if (this.isValidStorage(storage) && !currentConnector?.hasBlacklistBlockID(pipeBlockID, pipeBlockData)) {
174+
if (this.isValidStorage(storage, World.getInverseBlockSide(i)) && !currentConnector?.hasBlacklistBlockID(pipeBlockID, pipeBlockData)) {
174175
targets[i] = storage;
175176
}
176177
}
177178
}
178179
return targets;
179180
}
180181

181-
public isValidStorage(storage: Storage): boolean {
182-
const slots = storage?.getInputSlots();
182+
public isValidStorage(storage: Storage, side: number): boolean {
183+
const slots = storage?.getInputSlots(side);
183184
if (!slots) return false;
184185

185186
let trueSlotsLength = slots.length;

src/dev/core/pipe/item/wooden/WoodenPipeTileEntity.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@ class WoodenPipeTileEntity implements TileEntity.TileEntityPrototype {
134134

135135
public canConnectTo(x: number, y: number, z: number, region: BlockSource, side: number): boolean {
136136
const storage = StorageInterface.getStorage(region, x, y, z);
137-
return storage ? storage.getOutputSlots().length > 0 : false;
137+
const slots = storage?.getOutputSlots(side);
138+
if (!slots) return false;
139+
140+
let trueSlotsLength = slots.length;
141+
if (trueSlotsLength > 0 && slots[0] == "_json_saver_id") {
142+
// ! tileEntity container has jsonSaverId in slots[0]
143+
trueSlotsLength -= 1;
144+
}
145+
return trueSlotsLength > 0;
138146
}
139147

140148
private maxExtractable(): number {

0 commit comments

Comments
 (0)