Skip to content

Commit aa9b7e1

Browse files
authored
Fix #127: Re-enable joints when placing attachments (#134)
1 parent 148746f commit aa9b7e1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/java/dev/technici4n/moderndynamics/pipe/PipeBlockEntity.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,7 @@ public void updateCachedShape(int pipeConnections, int inventoryConnections) {
321321
cachedShape = PipeBoundingBoxes.getPipeShape(pipeConnections, inventoryConnections, attachments);
322322
}
323323

324-
/**
325-
* Update connection blacklist for a side, and schedule a node update, on the server side.
326-
*/
327-
protected void updateConnection(Direction side, boolean addConnection) {
324+
private void updateConnectionBlacklist(Direction side, boolean addConnection) {
328325
if (level.isClientSide()) {
329326
throw new IllegalStateException("updateConnections() should not be called client-side.");
330327
}
@@ -347,6 +344,13 @@ protected void updateConnection(Direction side, boolean addConnection) {
347344
}
348345
neighborPipe.setChanged();
349346
}
347+
}
348+
349+
/**
350+
* Update connection blacklist for a side, and schedule a node update, on the server side.
351+
*/
352+
protected void updateConnection(Direction side, boolean addConnection) {
353+
updateConnectionBlacklist(side, addConnection);
350354

351355
// Schedule inventory and network updates.
352356
refreshHosts();
@@ -441,6 +445,11 @@ public ItemInteractionResult useItemOn(Player player, InteractionHand hand, Bloc
441445
for (var host : getHosts()) {
442446
if (host.acceptsAttachment(attachmentItem, stack)) {
443447
if (!level.isClientSide) {
448+
// Re-enable connection when an attachment is added to it if was previously disabled.
449+
// (Attachments on disabled connections don't work as expected,
450+
// yet there is no visual indication. So we just disallow that.)
451+
updateConnectionBlacklist(hitSide, true);
452+
444453
host.setAttachment(hitSide, attachmentItem, new CompoundTag(), level.registryAccess());
445454
host.getAttachment(hitSide).onPlaced(player);
446455
level.blockUpdated(worldPosition, getBlockState().getBlock());

0 commit comments

Comments
 (0)