修复getTicker类型问题

This commit is contained in:
Light_Quanta 2025-05-30 20:38:20 +08:00
parent e69cd6a265
commit a725a914be
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -70,12 +70,18 @@ public class FuMO25Block extends Block implements EntityBlock {
@Override
public @Nullable <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level pLevel, @NotNull BlockState pState, @NotNull BlockEntityType<T> pBlockEntityType) {
if (!pLevel.isClientSide && pBlockEntityType == ModBlockEntities.FUMO_25.get()) {
return FuMO25BlockEntity::serverTick;
if (!pLevel.isClientSide) {
return createTickerHelper(pBlockEntityType, ModBlockEntities.FUMO_25.get(), FuMO25BlockEntity::serverTick);
}
return null;
}
@Nullable
@SuppressWarnings("unchecked")
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> pServerType, BlockEntityType<E> pClientType, BlockEntityTicker<? super E> pTicker) {
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
}
@Override
@ParametersAreNonnullByDefault
public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pMovedByPiston) {