2025-11-24 22:52:51 +03:00

53 lines
1.9 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.mojang.serialization.MapCodec
* org.jspecify.annotations.Nullable
*/
package net.minecraft.world.level.block;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import org.jspecify.annotations.Nullable;
public abstract class BaseEntityBlock
extends Block
implements EntityBlock {
protected BaseEntityBlock(BlockBehaviour.Properties properties) {
super(properties);
}
protected abstract MapCodec<? extends BaseEntityBlock> codec();
@Override
protected boolean triggerEvent(BlockState state, Level level, BlockPos pos, int b0, int b1) {
super.triggerEvent(state, level, pos, b0, b1);
BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity == null) {
return false;
}
return blockEntity.triggerEvent(b0, b1);
}
@Override
protected @Nullable MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) {
BlockEntity blockEntity = level.getBlockEntity(pos);
return blockEntity instanceof MenuProvider ? (MenuProvider)((Object)blockEntity) : null;
}
protected static <E extends BlockEntity, A extends BlockEntity> @Nullable BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> actual, BlockEntityType<E> expected, BlockEntityTicker<? super E> ticker) {
return expected == actual ? ticker : null;
}
}