airpodjoch_ Posted February 21, 2022 Posted February 21, 2022 (edited) 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 February 21, 2022 by airpodjoch_ Quote
airpodjoch_ Posted February 21, 2022 Author Posted February 21, 2022 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()) {} Quote
airpodjoch_ Posted February 22, 2022 Author Posted February 22, 2022 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. Quote
Recommended Posts
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.