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

47 lines
1.7 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.mojang.datafixers.kinds.App
* com.mojang.datafixers.kinds.Applicative
* com.mojang.serialization.MapCodec
* com.mojang.serialization.codecs.RecordCodecBuilder
*/
package net.minecraft.world.level.block;
import com.mojang.datafixers.kinds.App;
import com.mojang.datafixers.kinds.Applicative;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.valueproviders.IntProvider;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
public class DropExperienceBlock
extends Block {
public static final MapCodec<DropExperienceBlock> CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)IntProvider.codec(0, 10).fieldOf("experience").forGetter(b -> b.xpRange), DropExperienceBlock.propertiesCodec()).apply((Applicative)i, DropExperienceBlock::new));
private final IntProvider xpRange;
public MapCodec<? extends DropExperienceBlock> codec() {
return CODEC;
}
public DropExperienceBlock(IntProvider xpRange, BlockBehaviour.Properties properties) {
super(properties);
this.xpRange = xpRange;
}
@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);
}
}
}