Skip to content

Conversation

@Jishuna
Copy link

@Jishuna Jishuna commented Dec 5, 2025

Description

Allows customizing what happens to an entity when they are inside a custom block.
This allows for the creation of things like poison ivy or toxic liquids.

Example Script

// Kills any entity that steps into the block.
StartupEvents.registry('block', event => {
     event.create('test')
     .noCollision()
     .entityInside(callback => {
        callback.entity.setHealth(0);
     });
});

Other details

Copy link
Contributor

@ChiefArug ChiefArug left a comment

Choose a reason for hiding this comment

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

Good idea for another callback!

import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;

public class EntityInsideBlockCallback extends EntitySteppedOnBlockCallback {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this inheritance tree. It makes no sense conceptually, and if Mojang add a new parameter to stepped on then it will need reworking. Maybe instead rename EntitySteppedOnBlockCallback to a more generic 'EntityBlockCallback' and use that directly in both places?

Copy link
Contributor

Choose a reason for hiding this comment

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

This class doesn't need to exist if all it doesn't do anything its superclass does.

@Info("""
Set what happens when an entity is inside the block
This is called every tick for every entity inside the block, so be careful what you do here.
This will never be called if the block is a solid full cube.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this hold even when an entity is suffocating in the block?

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.

2 participants