80 lines
3.1 KiB
Java
80 lines
3.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.util.RandomSource;
|
|
import net.minecraft.util.valueproviders.ConstantInt;
|
|
import net.minecraft.util.valueproviders.IntProvider;
|
|
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.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.SculkCatalystBlockEntity;
|
|
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 org.jspecify.annotations.Nullable;
|
|
|
|
public class SculkCatalystBlock
|
|
extends BaseEntityBlock {
|
|
public static final MapCodec<SculkCatalystBlock> CODEC = SculkCatalystBlock.simpleCodec(SculkCatalystBlock::new);
|
|
public static final BooleanProperty PULSE = BlockStateProperties.BLOOM;
|
|
private final IntProvider xpRange = ConstantInt.of(5);
|
|
|
|
public MapCodec<SculkCatalystBlock> codec() {
|
|
return CODEC;
|
|
}
|
|
|
|
public SculkCatalystBlock(BlockBehaviour.Properties properties) {
|
|
super(properties);
|
|
this.registerDefaultState((BlockState)((BlockState)this.stateDefinition.any()).setValue(PULSE, false));
|
|
}
|
|
|
|
@Override
|
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
|
builder.add(PULSE);
|
|
}
|
|
|
|
@Override
|
|
protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
|
|
if (state.getValue(PULSE).booleanValue()) {
|
|
level.setBlock(pos, (BlockState)state.setValue(PULSE, false), 3);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public @Nullable BlockEntity newBlockEntity(BlockPos worldPosition, BlockState blockState) {
|
|
return new SculkCatalystBlockEntity(worldPosition, blockState);
|
|
}
|
|
|
|
@Override
|
|
public <T extends BlockEntity> @Nullable BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> type) {
|
|
if (level.isClientSide()) {
|
|
return null;
|
|
}
|
|
return SculkCatalystBlock.createTickerHelper(type, BlockEntityType.SCULK_CATALYST, SculkCatalystBlockEntity::serverTick);
|
|
}
|
|
|
|
@Override
|
|
protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack tool, boolean dropExperience) {
|
|
super.spawnAfterBreak(state, level, pos, tool, dropExperience);
|
|
if (dropExperience) {
|
|
this.tryDropExperience(level, pos, tool, this.xpRange);
|
|
}
|
|
}
|
|
}
|
|
|