Skip to content

Commit

Permalink
fixed: Water logged blocks were replaced when right-clicked with a cu…
Browse files Browse the repository at this point in the history
…stom water bucket (Fabric/Quilt) #41
  • Loading branch information
cech12 committed Jun 22, 2024
1 parent 5dd0657 commit 11554cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Forge Recommended Versioning](https://mcforge.readthedocs.io/en/latest/conventions/versioning/).

## [1.21-4.0.0.2] - 2024-06-22
### Fixed
- Water logged blocks were replaced when right-clicked with a custom water bucket (Fabric/Quilt) (thanks to Janbsh for the report) #41

## [1.21-4.0.0.1] - 2024-06-20
### Fixed
- damage bars of buckets were broken (Neoforge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.FluidTags;
Expand Down Expand Up @@ -159,7 +160,8 @@ public Tuple<Boolean, ItemStack> tryPickUpFluid(ItemStack stack, @Nullable Playe
ItemStack fullVanillaBucket = bucketPickup.pickupBlock(player, level, pos, state);
if (!fullVanillaBucket.isEmpty() && fullVanillaBucket.getItem() instanceof BucketItem bucketItem) {
Fluid fluid = Services.BUCKET.getFluidOfBucketItem(bucketItem);
level.playSound(player, pos, FluidVariantAttributes.getFillSound(FluidVariant.of(fluid)), SoundSource.BLOCKS, 1.0F, 1.0F);
SoundEvent sound = bucketPickup.getPickupSound().orElse(FluidVariantAttributes.getFillSound(FluidVariant.of(fluid)));
level.playSound(player, pos, sound, SoundSource.BLOCKS, 1.0F, 1.0F);
ItemStack usedStack = stack.copy();
usedStack.setCount(1);
usedStack = BucketLibUtil.addFluid(usedStack, fluid);
Expand Down Expand Up @@ -193,13 +195,12 @@ public Tuple<Boolean, ItemStack> tryPlaceFluid(ItemStack stack, @Nullable Player
BlockState state = level.getBlockState(pos);
Block block = state.getBlock();
if (block instanceof LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(player, level, pos, state, fluid)) {
if (liquidBlockContainer.placeLiquid(level, pos, state, fluid.defaultFluidState())) {
level.playSound(player, pos, FluidVariantAttributes.getEmptySound(FluidVariant.of(fluid)), SoundSource.BLOCKS, 1.0F, 1.0F);
return new Tuple<>(true, BucketLibUtil.removeFluid(stack, serverLevel, player));
}
liquidBlockContainer.placeLiquid(level, pos, state, fluid.defaultFluidState());
level.playSound(player, pos, FluidVariantAttributes.getEmptySound(FluidVariant.of(fluid)), SoundSource.BLOCKS, 1.0F, 1.0F);
return new Tuple<>(true, BucketLibUtil.removeFluid(stack, serverLevel, player));
}
//air / replaceable block interaction
if (state.isAir() || state.canBeReplaced(fluid) || !state.getFluidState().isEmpty()) {
if (state.isAir() || state.canBeReplaced(fluid) || (!state.getFluidState().isEmpty() && !(block instanceof LiquidBlockContainer))) {
if (level.setBlock(pos, fluid.defaultFluidState().createLegacyBlock(), 11) || state.getFluidState().isSource()) {
level.playSound(player, pos, FluidVariantAttributes.getEmptySound(FluidVariant.of(fluid)), SoundSource.BLOCKS, 1.0F, 1.0F);
return new Tuple<>(true, BucketLibUtil.removeFluid(stack, serverLevel, player));
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Project
group=de.cech12.bucketlib
mod_version=4.0.0.1
mod_version=4.0.0.2
mod_id=bucketlib
mod_name=BucketLib
mod_author=Cech12
Expand Down

0 comments on commit 11554cd

Please sign in to comment.