Package com.simibubi.create.api.event
Class BlockEntityBehaviourEvent
java.lang.Object
net.neoforged.bus.api.Event
com.simibubi.create.api.event.BlockEntityBehaviourEvent
public class BlockEntityBehaviourEvent
extends net.neoforged.bus.api.Event
Event that is fired just before a SmartBlockEntity is being deserialized
Also if a new one is placed
Use it to attach a new
Actual setup of the behaviours internal workings and data should be done in BlockEntityBehaviour#read() and BlockEntityBehaviour#initialize() respectively.
Because of the earliness of this event, the added behaviours will have access to the initial NBT read (unless the BE was placed, not loaded), thereby allowing block entities to store and retrieve data for injected behaviours.
Example:
Also if a new one is placed
Use it to attach a new
BlockEntityBehaviour or replace existing ones
(with caution)Actual setup of the behaviours internal workings and data should be done in BlockEntityBehaviour#read() and BlockEntityBehaviour#initialize() respectively.
Because of the earliness of this event, the added behaviours will have access to the initial NBT read (unless the BE was placed, not loaded), thereby allowing block entities to store and retrieve data for injected behaviours.
Example:
neoForgeEventBus.addListener((BlockEntityBehaviourEvent event) -> {
event.forType(AllBlockEntityTypes.FUNNEL.get(), be -> {
event.attach(new FunFunnelBehaviour(be));
});
});
-
Constructor Summary
ConstructorsConstructorDescriptionBlockEntityBehaviourEvent(SmartBlockEntity blockEntity, Map<BehaviourType<?>, BlockEntityBehaviour> behaviours) -
Method Summary
Modifier and TypeMethodDescriptionvoidattach(BlockEntityBehaviour behaviour) <T extends SmartBlockEntity>
voidremove(BehaviourType<?> type)
-
Constructor Details
-
BlockEntityBehaviourEvent
public BlockEntityBehaviourEvent(SmartBlockEntity blockEntity, Map<BehaviourType<?>, BlockEntityBehaviour> behaviours)
-
-
Method Details
-
forType
public <T extends SmartBlockEntity> void forType(net.minecraft.world.level.block.entity.BlockEntityType<T> type, Consumer<T> action) -
attach
-
remove
-