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

67 lines
2.3 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.jspecify.annotations.Nullable
*/
package net.minecraft.world.item;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.DispensibleContainerItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.BlockHitResult;
import org.jspecify.annotations.Nullable;
public class SolidBucketItem
extends BlockItem
implements DispensibleContainerItem {
private final SoundEvent placeSound;
public SolidBucketItem(Block content, SoundEvent placeSound, Item.Properties properties) {
super(content, properties);
this.placeSound = placeSound;
}
@Override
public InteractionResult useOn(UseOnContext context) {
InteractionResult placeResult = super.useOn(context);
Player player = context.getPlayer();
if (placeResult.consumesAction() && player != null) {
player.setItemInHand(context.getHand(), BucketItem.getEmptySuccessItem(context.getItemInHand(), player));
}
return placeResult;
}
@Override
protected SoundEvent getPlaceSound(BlockState blockState) {
return this.placeSound;
}
@Override
public boolean emptyContents(@Nullable LivingEntity user, Level level, BlockPos pos, @Nullable BlockHitResult hitResult) {
if (level.isInWorldBounds(pos) && level.isEmptyBlock(pos)) {
if (!level.isClientSide()) {
level.setBlock(pos, this.getBlock().defaultBlockState(), 3);
}
level.gameEvent((Entity)user, GameEvent.FLUID_PLACE, pos);
level.playSound((Entity)user, pos, this.placeSound, SoundSource.BLOCKS, 1.0f, 1.0f);
return true;
}
return false;
}
}