Skip to content

Commit

Permalink
Fix #127: Re-enable joints when placing attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Jan 1, 2025
1 parent 148746f commit 90ecc7c
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,7 @@ public void updateCachedShape(int pipeConnections, int inventoryConnections) {
cachedShape = PipeBoundingBoxes.getPipeShape(pipeConnections, inventoryConnections, attachments);
}

/**
* Update connection blacklist for a side, and schedule a node update, on the server side.
*/
protected void updateConnection(Direction side, boolean addConnection) {
private void updateConnectionBlacklist(Direction side, boolean addConnection) {
if (level.isClientSide()) {
throw new IllegalStateException("updateConnections() should not be called client-side.");
}
Expand All @@ -347,6 +344,13 @@ protected void updateConnection(Direction side, boolean addConnection) {
}
neighborPipe.setChanged();
}
}

/**
* Update connection blacklist for a side, and schedule a node update, on the server side.
*/
protected void updateConnection(Direction side, boolean addConnection) {
updateConnectionBlacklist(side, addConnection);

// Schedule inventory and network updates.
refreshHosts();
Expand Down Expand Up @@ -441,6 +445,11 @@ public ItemInteractionResult useItemOn(Player player, InteractionHand hand, Bloc
for (var host : getHosts()) {
if (host.acceptsAttachment(attachmentItem, stack)) {
if (!level.isClientSide) {
// Re-enable connection when an attachment is added to it if was previously disabled.
// (Attachments on disabled connections don't work as expected,
// yet there is no visual indication. So we just disallow that.)
updateConnectionBlacklist(hitSide, true);

host.setAttachment(hitSide, attachmentItem, new CompoundTag(), level.registryAccess());
host.getAttachment(hitSide).onPlaced(player);
level.blockUpdated(worldPosition, getBlockState().getBlock());
Expand Down

0 comments on commit 90ecc7c

Please sign in to comment.