Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FluidStorageUtil#moveWithSound Play Sound #3431

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private static boolean moveWithSound(Storage<FluidVariant> from, Storage<FluidVa
if (!fill && handItem == Items.POTION) sound = SoundEvents.ITEM_BOTTLE_EMPTY;
}

player.playSound(sound, SoundCategory.BLOCKS, 1, 1);
player.getWorld().playSound(player, player.getX(), player.getEyeY(), player.getZ(), sound, SoundCategory.PLAYERS, 1, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this been tested, I believe you need to pass null as the first param otherwise this is going to play for everyone BUT the player.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should be called both on client and server. ClientWorld.playSound will play sound to the except, while ServerWorld.playSound will play sound to all players but the except. This usage is according to vanilla usage, such as FenceGateBlock#onUse.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm, I tested with the chute block in the FAPI test mods, they only call this on the server. I wonder if its worth wrappning this is a !world.isClient? Maybe @Technici4n would have some input on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it depends on which side modders are expected to call it. It's probably worth documenting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you were right, it makes sense to call this on both sides. I have gone ahead and updated the testmod, this now works as expected. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we indicate it needs to be called on both sides in the doc?

modmuss50 marked this conversation as resolved.
Show resolved Hide resolved

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,18 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient() && world.getBlockEntity(pos) instanceof FluidChuteBlockEntity chute) {
if (world.getBlockEntity(pos) instanceof FluidChuteBlockEntity chute) {
if (!FluidStorageUtil.interactWithFluidStorage(chute.storage, player, hand)) {
player.sendMessage(
Text.literal("Fluid: ")
.append(FluidVariantAttributes.getName(chute.storage.variant))
.append(", amount: " + chute.storage.amount),
false
);
if (!world.isClient()) {
player.sendMessage(
Text.literal("Fluid: ")
.append(FluidVariantAttributes.getName(chute.storage.variant))
.append(", amount: " + chute.storage.amount),
false
);
}

return ActionResult.CONSUME;
}
}

Expand Down
Loading