Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello everyone, I am trying to check wether a player is at an ocean/beach, and then gives the player a Salty Water Bucket instead of a normal Water Bucket. I got it kinda working, up until the point it's not giving me the Salty Water Bucket.

This is what I have now:

public class BucketFillHandler {

    @SubscribeEvent
    public static void onBucketFill(@NotNull FillBucketEvent event) {
        Player player = event.getPlayer();
        BlockPos pos = new BlockPos(player.getX(), player.getY(), player.getZ());

        if (event.getWorld().isClientSide()) {
            if (event.getWorld().getBiomeManager().getBiome(pos).getRegistryName().toString().equals("minecraft:beach")) {
                if (event.getPlayer() != null) {
                    HitResult target = event.getTarget();
                    if (target != null && target.getType() == HitResult.Type.BLOCK) {
                        BlockState state = event.getWorld().getBlockState(new BlockPos(target.getLocation()));
                        Material material = state.getMaterial();

                        if (material == Material.WATER && (Integer) state.getValue(LiquidBlock.LEVEL) == 0) {
                            event.setResult(Event.Result.ALLOW);
                            System.out.println("YES"); // This is just for testing purposes.
                            event.setFilledBucket(new ItemStack(ModItems.SALTY_WATER_BUCKET.get(), 1)); // This is what doesn't work
                        }
                    }
                }
            }
        }
    }
}

 

Edited by airpodjoch_

  • Author

Wow. It was that simple. I actually scrapped that off my list if possible fixes, when my game crashed last time I used the if statement with that condition. However, before I made this forum post I changed the script around a little, not checking if this would actually work. I got to say that, it's kinda weird isClientSide() basically means "are you a server".

Anyway, I got it fixed by making it:

if (!event.getWorld().isClientSide()) {}

 

  • Author

Ah ok. So the goal is to give the player the bucket from the server side, and not the client side? I thought it was the other way around.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.