56 lines
2.1 KiB
Java
56 lines
2.1 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.server.level.ServerLevel;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.BaseEntityBlock;
|
|
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.SpawnerBlockEntity;
|
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import org.jspecify.annotations.Nullable;
|
|
|
|
public class SpawnerBlock
|
|
extends BaseEntityBlock {
|
|
public static final MapCodec<SpawnerBlock> CODEC = SpawnerBlock.simpleCodec(SpawnerBlock::new);
|
|
|
|
public MapCodec<SpawnerBlock> codec() {
|
|
return CODEC;
|
|
}
|
|
|
|
protected SpawnerBlock(BlockBehaviour.Properties properties) {
|
|
super(properties);
|
|
}
|
|
|
|
@Override
|
|
public BlockEntity newBlockEntity(BlockPos worldPosition, BlockState blockState) {
|
|
return new SpawnerBlockEntity(worldPosition, blockState);
|
|
}
|
|
|
|
@Override
|
|
public <T extends BlockEntity> @Nullable BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> type) {
|
|
return SpawnerBlock.createTickerHelper(type, BlockEntityType.MOB_SPAWNER, level.isClientSide() ? SpawnerBlockEntity::clientTick : SpawnerBlockEntity::serverTick);
|
|
}
|
|
|
|
@Override
|
|
protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack tool, boolean dropExperience) {
|
|
super.spawnAfterBreak(state, level, pos, tool, dropExperience);
|
|
if (dropExperience) {
|
|
int magicCount = 15 + level.random.nextInt(15) + level.random.nextInt(15);
|
|
this.popExperience(level, pos, magicCount);
|
|
}
|
|
}
|
|
}
|
|
|