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 water bottle filling not working in the end dimension #4327

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 @@ -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 @@ -34,6 +34,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