/* * 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.server.level.ServerLevel; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.Block; 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.entity.TrialSpawnerBlockEntity; import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerState; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.block.state.properties.EnumProperty; import org.jspecify.annotations.Nullable; public class TrialSpawnerBlock extends BaseEntityBlock { public static final MapCodec CODEC = TrialSpawnerBlock.simpleCodec(TrialSpawnerBlock::new); public static final EnumProperty STATE = BlockStateProperties.TRIAL_SPAWNER_STATE; public static final BooleanProperty OMINOUS = BlockStateProperties.OMINOUS; public MapCodec codec() { return CODEC; } public TrialSpawnerBlock(BlockBehaviour.Properties properties) { super(properties); this.registerDefaultState((BlockState)((BlockState)((BlockState)this.stateDefinition.any()).setValue(STATE, TrialSpawnerState.INACTIVE)).setValue(OMINOUS, false)); } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(STATE, OMINOUS); } @Override public @Nullable BlockEntity newBlockEntity(BlockPos worldPosition, BlockState blockState) { return new TrialSpawnerBlockEntity(worldPosition, blockState); } @Override public @Nullable BlockEntityTicker getTicker(Level level, BlockState blockState, BlockEntityType type) { BlockEntityTicker blockEntityTicker; if (level instanceof ServerLevel) { ServerLevel serverLevel = (ServerLevel)level; blockEntityTicker = TrialSpawnerBlock.createTickerHelper(type, BlockEntityType.TRIAL_SPAWNER, (innerLevel, pos, state, entity) -> entity.getTrialSpawner().tickServer(serverLevel, pos, state.getOptionalValue(BlockStateProperties.OMINOUS).orElse(false))); } else { blockEntityTicker = TrialSpawnerBlock.createTickerHelper(type, BlockEntityType.TRIAL_SPAWNER, (innerLevel, pos, state, entity) -> entity.getTrialSpawner().tickClient(innerLevel, pos, state.getOptionalValue(BlockStateProperties.OMINOUS).orElse(false))); } return blockEntityTicker; } }