Skip to content

Commit

Permalink
fixed: buckets could not be stacked after holding fish or axolotl #46
Browse files Browse the repository at this point in the history
  • Loading branch information
cech12 committed Sep 7, 2024
1 parent 28850a7 commit e03a2dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 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.20.1-2.3.4.3] - 2024-09-07
### Fixed
- buckets could not be stacked after holding fish or axolotl (thanks to Sinhika & Blazified for the report) #46

## [1.20.1-2.3.4.2] - 2024-08-29
### Fixed
- workaround to avoid game crash caused by "noBucket()" fluids of Registrate mod (thanks to PhilTheGreatLOL for the report) #45
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mixin_version=0.8.5

## Mod Properties
mod_id=bucketlib
mod_version=2.3.4.2
mod_version=2.3.4.3
mod_group_id=cech12.bucketlib
mod_name=BucketLib
mod_authors=Cech12
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/cech12/bucketlib/api/item/UniversalBucketItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,13 @@ public InteractionResultHolder<ItemStack> use(@Nonnull Level level, @Nonnull Pla
//remove entity to be able to use tryPlaceFluid method
FluidActionResult fluidActionResult = FluidUtil.tryPlaceFluid(player, level, interactionHand, pos, BucketLibUtil.removeEntityType(itemstack, false), fluidStack);
if (fluidActionResult.isSuccess()) {
ItemStack result = fluidActionResult.getResult();
if (BucketLibUtil.containsEntityType(itemstack)) {
//place entity if exists
spawnEntityFromBucket(player, level, itemstack, pos, false);
result = spawnEntityFromBucket(player, level, itemstack, pos, false);
result = BucketLibUtil.removeFluid(result);
}
return InteractionResultHolder.sidedSuccess(BucketLibUtil.createEmptyResult(itemstack, player, fluidActionResult.getResult(), interactionHand), level.isClientSide());
return InteractionResultHolder.sidedSuccess(BucketLibUtil.createEmptyResult(itemstack, player, result, interactionHand), level.isClientSide());
}
}
} else if (BucketLibUtil.containsEntityType(itemstack)) {
Expand Down Expand Up @@ -318,6 +320,14 @@ public ItemStack spawnEntityFromBucket(@Nullable Player player, Level level, Ite
if (entity instanceof Bucketable bucketable) {
bucketable.loadFromBucketTag(itemStack.getOrCreateTag());
bucketable.setFromBucket(true);
//remove entity data
ItemStack tempStack = new ItemStack(itemStack.getItem(), 1);
bucketable.saveToBucketTag(tempStack);
if (tempStack.getTag() != null && itemStack.getTag() != null) {
CompoundTag nbt = itemStack.getTag();
tempStack.getTag().getAllKeys().forEach(nbt::remove);
itemStack.setTag(nbt);
}
}
if (player != null) {
serverLevel.gameEvent(player, GameEvent.ENTITY_PLACE, pos);
Expand Down

0 comments on commit e03a2dd

Please sign in to comment.