xxWhatsherfacex Posted September 17, 2019 Share Posted September 17, 2019 (edited) I'm trying to make it so when a player stands in an ocean or beach biome and tries to fill a bucket with water, it instead gives a different item (SaltwaterBucket). I think I have to do this in an event handler class and the FullBucketEvent? Or would I accomplish this in my Item class? I'm a little stumped on what to do specifically though. Any pointers would be really appreciated! public class BucketFillHandler { @SubscribeEvent public void onBucketFill(FillBucketEvent event) { //Check for Ocean Biome and give player either saltwaterbucket or regular bucket. } } Edited September 18, 2019 by xxWhatsherfacex Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted September 17, 2019 Share Posted September 17, 2019 1 hour ago, xxWhatsherfacex said: FillBucketEvent event Does this event have a World and a BlockPos field you can access? If so just use World#getBiome(BlockPos). I believe that is the name of the method. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
xxWhatsherfacex Posted September 18, 2019 Author Share Posted September 18, 2019 Alright! Thanks so much! I managed to successfully check the biome and detect if the player is trying to collect water with their bucket. public class BucketFillHandler { @SubscribeEvent public void onBucketFill(FillBucketEvent event) { EntityPlayer player = Minecraft.getMinecraft().player; BlockPos pos = new BlockPos(player.getPositionVector()); if (event.getWorld().getBiome(pos) == Biomes.BEACH || event.getWorld().getBiome(pos) == Biomes.OCEAN || event.getWorld().getBiome(pos) == Biomes.DEEP_OCEAN || event.getWorld().getBiome(pos) == Biomes.COLD_BEACH || event.getWorld().getBiome(pos) == Biomes.FROZEN_OCEAN || event.getWorld().getBiome(pos) == Biomes.STONE_BEACH) { if(event.getEntityPlayer() != null && !event.getWorld().isRemote) { RayTraceResult target = event.getTarget(); if(target != null && target.typeOfHit == RayTraceResult.Type.BLOCK) { if(target.getBlockPos() != null) { IBlockState state = event.getWorld().getBlockState(target.getBlockPos()); Material material = state.getMaterial(); if(material == Material.WATER && ((Integer)state.getValue(BlockLiquid.LEVEL)).intValue() == 0) { //Give the player ModItems.SALTWATER_BUCKET } } } } } } I'm a little stumped on how to give the player the bucket now. I tried using event.setFilledBucket(new ItemStack(ModItems.SALTWATER_BUCKET, 1)); where the comment is but it isn't doing anything but giving the regular bucket of water. Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted September 18, 2019 Share Posted September 18, 2019 27 minutes ago, xxWhatsherfacex said: but it isn't doing anything but giving the regular bucket of water. Set the result to Result.ALLOW using Event#setResult Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
xxWhatsherfacex Posted September 18, 2019 Author Share Posted September 18, 2019 Oops! That was it! Thanks so much! ❤️ Quote Link to comment Share on other sites More sharing options...
MFMods Posted September 20, 2019 Share Posted September 20, 2019 On 9/18/2019 at 3:50 AM, xxWhatsherfacex said: I managed to successfully check the biome and detect if the player is trying to collect water with their bucket. do not use "Minecraft.getMinecraft ().player". it will crash the game in multiplayer. get the player from the event parameter. you almost never want to use equality to check for biomes (except if you want single exact biome, and none of its variations). normally you would use biome types. Quote Link to comment Share on other sites More sharing options...
xxWhatsherfacex Posted September 21, 2019 Author Share Posted September 21, 2019 Oh thanks! I'll go ahead and make those changes. ❤ Quote Link to comment Share on other sites More sharing options...
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.