Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #127: Re-enable joints when placing attachments #134

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading