Skip to content

Commit

Permalink
Fix water bottle filling not working in the end dimension
Browse files Browse the repository at this point in the history
While in the End, don't attempt to pick up ender air while looking at fluids. This more generic approach will disallow ender air bottling while looking at lava, even if attempting to use a bottle this way wouldn't do anything by default, but it's less likely to cause issues with other mods that attempt to bottle fluids from the world.
  • Loading branch information
TheRealWormbo authored and williewillus committed May 29, 2023
1 parent 39fc60a commit 92f78d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
package vazkii.botania.common.item.material;

import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
Expand All @@ -19,8 +20,12 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;

import org.jetbrains.annotations.NotNull;

Expand All @@ -43,22 +48,32 @@ public static InteractionResultHolder<ItemStack> onPlayerInteract(Player player,
return InteractionResultHolder.pass(stack);
}

if ((world.dimension() == Level.END && isClearFromDragonBreath(world, player.getBoundingBox().inflate(3.5)))
if ((world.dimension() == Level.END && isClearFromDragonBreath(world, player.getBoundingBox().inflate(3.5)) && notAimingAtFluid(world, player))
|| pickupFromEntity(world, player.getBoundingBox().inflate(1.0))) {

if (!world.isClientSide) {
ItemStack enderAir = new ItemStack(BotaniaItems.enderAirBottle);
player.getInventory().placeItemBackInInventory(enderAir);
stack.shrink(1);
world.playSound(null, player.blockPosition(), SoundEvents.ITEM_PICKUP, SoundSource.NEUTRAL, 0.5F, 1F);
world.gameEvent(player, GameEvent.FLUID_PICKUP, player.position());
}

return InteractionResultHolder.success(stack);
return InteractionResultHolder.sidedSuccess(stack, world.isClientSide());
}

return InteractionResultHolder.pass(stack);
}

private static boolean notAimingAtFluid(Level world, Player player) {
BlockHitResult hitResult = getPlayerPOVHitResult(world, player, ClipContext.Fluid.ANY);
if (hitResult.getType() == HitResult.Type.BLOCK) {
BlockPos pos = hitResult.getBlockPos();
return world.mayInteract(player, pos) && world.getFluidState(pos).isEmpty();
}
return true;
}

public static boolean isClearFromDragonBreath(Level world, AABB aabb) {
List<AreaEffectCloud> list = world.getEntitiesOfClass(AreaEffectCloud.class,
aabb, entity -> entity != null && entity.isAlive()
Expand Down
1 change: 1 addition & 0 deletions web/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ and start a new "Upcoming" section.
* Fix: Made Teru Teru Bozu truely happy during clear weather again (Wormbo)
* Fix: Leaves placed by Worldshaper's Astrolabe no longer decay
* Fix: Some items being missing from Forge equipment tags and Fabric bow tag
* Fix: Using an empty bottle in the end will not attempt to pick up Ender Air if the player is aiming at a liquid (Wormbo)
* Fix: Horn of the Canopy breaking persistent leaves
* Fix: Thermalily not updating comparators properly
* Fix: Kindle Lens not creating Soul Fire when it should
Expand Down

0 comments on commit 92f78d7

Please sign in to comment.