| 1 | package net.minecraft.world.level.block;
|
| 2 |
|
| 3 | import net.minecraft.core.BlockPos;
|
| 4 | import net.minecraft.server.level.ServerLevel;
|
| 5 | import net.minecraft.util.RandomSource;
|
| 6 | import net.minecraft.world.item.ItemStack;
|
| 7 | import net.minecraft.world.level.Level;
|
| 8 | import net.minecraft.world.level.block.entity.BlockEntity;
|
| 9 | import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
| 10 | import net.minecraft.world.level.block.entity.BlockEntityType;
|
| 11 | import net.minecraft.world.level.block.entity.BlockEntityTypes;
|
| 12 | import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
| 13 | import net.minecraft.world.level.block.state.BlockBehaviour;
|
| 14 | import net.minecraft.world.level.block.state.BlockState;
|
| 15 | import org.jspecify.annotations.Nullable;
|
| 16 |
|
| 17 | /**
|
| 18 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 19 | */
|
| 20 | public class SpawnerBlock extends BaseEntityBlock {
|
| 21 | /**
|
| 22 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 23 | */
|
| 24 | public SpawnerBlock(final BlockBehaviour.Properties properties) {
|
| 25 | super(properties);
|
| 26 | }
|
| 27 |
|
| 28 | @Override
|
| 29 | public BlockEntity newBlockEntity(final BlockPos worldPosition, final BlockState blockState) {
|
| 30 | return new SpawnerBlockEntity(worldPosition, blockState);
|
| 31 | }
|
| 32 |
|
| 33 | @Override
|
| 34 | public <T extends BlockEntity> @Nullable BlockEntityTicker<T> getTicker(final Level level, final BlockState blockState, final BlockEntityType<T> type) {
|
| 35 | return createTickerHelper(type, BlockEntityTypes.MOB_SPAWNER, level.isClientSide() ? SpawnerBlockEntity::clientTick : SpawnerBlockEntity::serverTick);
|
| 36 | }
|
| 37 |
|
| 38 | @Override
|
| 39 | protected void spawnAfterBreak(final BlockState state, final ServerLevel level, final BlockPos pos, final ItemStack tool, final boolean dropExperience) {
|
| 40 | super.spawnAfterBreak(state, level, pos, tool, dropExperience);
|
| 41 | if (dropExperience) {
|
| 42 | RandomSource random = level.getRandom();
|
| 43 | int magicCount = 15 + random.nextInt(15) + random.nextInt(15);
|
| 44 | this.popExperience(level, pos, magicCount);
|
| 45 | }
|
| 46 | }
|
| 47 | }
|
| 48 |
|