Skip to content

Conversation

ner24
Copy link

@ner24 ner24 commented Aug 9, 2025

added additional methods to try and fix compile errors in create fabric. Were put here as it could be useful outside of create too:

  • EntityExtensions#getEyeInFluidType()
  • new LivingEntityExtensions class which is applied to LivingEntity
  • LivingEntityExtensions#canDrownInFluidType(FluidType type)
  • onNeighborChange and getWeakChanges added to BlockExtensions and BlockStateExtensions

Comment on lines 146 to 148
default void onNeighborChange(BlockState state, LevelReader level, BlockPos pos, BlockPos neighbor) {
//do nothing by default
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method exists in NeighborChangeListeningBlock

Copy link
Author

@ner24 ner24 Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh i missed that.
Also, it doesnt seem like NeighborChangeListeningBlock is implemented anywhere in the main class hierarchy for blocks (i.e. Block.class). This differs to forge where these 2 methods are effectively applied to every block via IForgeBlock and IForgeBlockState. Wouldn't this mean that Forge mods being ported to Fabric will have a common bug where a block class defines onNeighborChange but does not implement the NeighborChangeListeningBlock interface leading to blocks not updating when they should be on Fabric?
I realise that Override annotation could force a compile error but Java doesnt force that annotation so there will be cases where it isnt used and so the bug will be undetected until someone spots it in game.
How can this be avoided (or how is this avoided)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I did move to NeighborChangeListeningBlock but I think my point still stands (unless im misunderstanding something, still new to this). Already had to fix it for the vanilla comparator

…eakChanges to it), updated Comparator block to fix bug where it wont update via the vault
@ner24
Copy link
Author

ner24 commented Aug 10, 2025

I've moved to using NeighbourListeningBlock. It also fixes the vanilla comparator not updating when the vault inventory updates by having the comparator also implement the NeighborListeningBlock (done this way to mimic how forge does it).

@skippyall
Copy link

skippyall commented Aug 10, 2025

I forgot to mention that I already did a PR on the Create Fabric repo Fabricators-of-Create/Create#1794 basically fixes the same errors. However, your approach might be slightly better

@skippyall
Copy link

Also I don't know if

I've moved to using NeighbourListeningBlock. It also fixes the vanilla comparator not updating when the vault inventory updates by having the comparator also implement the NeighborListeningBlock (done this way to mimic how forge does it).

Having the comparator implement NeighborListeningBlock will probably make it update twice for normal updates using Level#updateNeighborForOutputSignal

@ner24
Copy link
Author

ner24 commented Aug 10, 2025

I forgot to mention that I already did a PR on the Create Fabric repo Fabricators-of-Create/Create#1794 basically fixes the same errors. However, your approach might be slightly better

Yes I did see that. I feel like it makes more sense to put it in the Porting lib. Most of the errors are due to differences between forge and fabric which is sort of the point of this library.

@ner24
Copy link
Author

ner24 commented Aug 10, 2025

Also I don't know if

I've moved to using NeighbourListeningBlock. It also fixes the vanilla comparator not updating when the vault inventory updates by having the comparator also implement the NeighborListeningBlock (done this way to mimic how forge does it).

Having the comparator implement NeighborListeningBlock will probably make it update twice for normal updates using Level#updateNeighborForOutputSignal

Possibly. Atm I am just aiming to just keep it similar to what Forge does. Before that patch the comparator would not update when the vault inventory updated.

ner24 added 2 commits August 10, 2025 23:14
…eted duplicate implementation of updateFluidOnEyes
…parators which now implement NeighborChangeListeningBlock
@ner24
Copy link
Author

ner24 commented Aug 11, 2025

Also I don't know if

I've moved to using NeighbourListeningBlock. It also fixes the vanilla comparator not updating when the vault inventory updates by having the comparator also implement the NeighborListeningBlock (done this way to mimic how forge does it).

Having the comparator implement NeighborListeningBlock will probably make it update twice for normal updates using Level#updateNeighborForOutputSignal

Ive updated that method in 0f1b608 to try and avoid that now

Copy link
Member

@AlphaMode AlphaMode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if these changes will be accepted since this isn't really how porting lib is suppose to handle things but I will invest further into this later

@Mixin(ComparatorBlock.class)
public class ComparatorBlockMixin implements ComparatorBlockExtension {
@Override
public void onNeighborChange(BlockState state, LevelReader world, BlockPos pos, BlockPos neighbor) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Porting Lib isn't meant to override vanilla like this. All extensions are meant to be added to modded blocks that want the behavior

Copy link
Author

@ner24 ner24 Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. The main issue is that forge adds this method to IForgeBlock interface which the comparator then implements in forge. I wanted to try and mimic this behaviour as the otherwise inconsistent implementation of onNeighbourChange in forge and fabric lead to the comparator missing updates from block entities which only call onNeighbourChange.

Otherwise, forge to fabric ports have to manually account for the fact that not all blocks implement NeighborChangeListeningBlock and then send those updates manually (albeit i think this will only really be an issue with updates to vanilla blocks since modded blocks should already have implemented this method if they are listening to neighbour changes).

As an example, this was an issue with the create mod vault not updating comparators.

Ig the other way would be to have a neighbour notify interface which when implemented can include calls to neighbour change listeners + an additional line for notifying neighbouring blocks of type comparator.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With that, the comparator mixin can be removed. If thats preferrable i can do that

* and {@link LevelMixin#port_lib$updateNeighbourForOutputSignal2(BlockPos, Block, CallbackInfo, BlockPos, BlockState)}
* which call {@link NeighborChangeListeningBlock#onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos)}
*/
@Redirect(method = "updateNeighbourForOutputSignal",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirecting vanilla code for this isn't what Porting Lib is for

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove this as well in relation to the suggested change in #179 (comment)

throw new RuntimeException("this should be overridden via mixin. what?");
}

default FluidType getEyeInFluidType() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methods that don't have a unique method signature like this means that it will conflict with other mods and need to be prefixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants