Skip to content

API for blocks to declare whether they're relocatable from a given area#3129

Open
Commoble wants to merge 12 commits into
neoforged:26.1.xfrom
Commoble:26.1.x-relocation-api
Open

API for blocks to declare whether they're relocatable from a given area#3129
Commoble wants to merge 12 commits into
neoforged:26.1.xfrom
Commoble:26.1.x-relocation-api

Conversation

@Commoble
Copy link
Copy Markdown
Contributor

@Commoble Commoble commented Apr 25, 2026

The purpose of this is for multiblocks which can be relocated if and only if the whole multiblock is being relocated, to be able declare this behavior.

For example, half a door block shouldn't be relocated, but a whole door is perfectly fine to relocate.

This PR adds an overridable method IBlockExtension#getRelocability for declaring this behavior (and corresponding IBlockStateExtension API), and also patches doors, beds, double plants, and extended pistons to support it.

A mod which intends to relocate some region of blocks (meaning, to cut/copy a region of blocks and paste them somewhere else, including translation, rotation, and/or mirror) would call IBlockStateExtension#getRelocability on each blockstate in the area they are relocating blocks from, testing the returned BlockRelocability object for the region of blocks the relocator is attempting to move.

The default behavior of the extension is to just check the block tag c:relocation_not_supported, and blocks which are not relocatable under any circumstances may continue to add themselves to that tag instead of overriding this method.

Additionally, a relocation system which wants to know how big a multiblock is so they can expand the area being relocated to cover the multiblock, may switch over the BlockRelocability, which is a sealed interface; the Multiblock subclass declares a set of positions indicating the extent of the multiblock.

@neoforged-automation neoforged-automation Bot added the 26.1 Targeted at Minecraft 26.1 label Apr 25, 2026
@neoforged-pr-publishing
Copy link
Copy Markdown

  • Publish PR to GitHub Packages

@ChiefArug
Copy link
Copy Markdown
Member

It is possible, though rare, to obtain half blocks like beds without their corresponding halves (usually through update suppression shenanigins or wacky worldgen).

This doesn't seem to consider that, is it something worth considering?

@Commoble
Copy link
Copy Markdown
Contributor Author

It is possible, though rare, to obtain half blocks like beds without their corresponding halves (usually through update suppression shenanigins or wacky worldgen).

This doesn't seem to consider that, is it something worth considering?

That's a fair point, I can update the vanilla overrides so that they only deny relocations if the other half is a properly-connected other half

Comment thread src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java Outdated
@sciwhiz12 sciwhiz12 added the enhancement New (or improvement to existing) feature or request label May 4, 2026
Comment thread src/main/java/net/neoforged/neoforge/common/extensions/IBlockExtension.java Outdated
Comment thread src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java Outdated
Comment thread src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java Outdated
Comment thread src/main/java/net/neoforged/neoforge/common/extensions/IBlockStateExtension.java Outdated
Comment thread src/main/java/net/neoforged/neoforge/common/util/BlockRelocability.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

26.1 Targeted at Minecraft 26.1 enhancement New (or improvement to existing) feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants