From 1ed2a78d85da0db3e167b1732bfef20574b676c9 Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Tue, 9 Apr 2024 11:44:03 +0100 Subject: [PATCH] Well --- .../content/building/block/RopeBlock.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/violetmoon/quark/content/building/block/RopeBlock.java b/src/main/java/org/violetmoon/quark/content/building/block/RopeBlock.java index a3332bda75..dd5ad6a796 100755 --- a/src/main/java/org/violetmoon/quark/content/building/block/RopeBlock.java +++ b/src/main/java/org/violetmoon/quark/content/building/block/RopeBlock.java @@ -1,5 +1,15 @@ package org.violetmoon.quark.content.building.block; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.violetmoon.quark.content.automation.module.PistonsMoveTileEntitiesModule; +import org.violetmoon.quark.content.building.module.RopeModule; +import org.violetmoon.zeta.block.ZetaBlock; +import org.violetmoon.zeta.item.ZetaBlockItem; +import org.violetmoon.zeta.module.ZetaModule; +import org.violetmoon.zeta.registry.IZetaBlockItemProvider; +import org.violetmoon.zeta.registry.RenderLayerRegistry; + import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.sounds.SoundEvents; @@ -40,19 +50,9 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.fluids.FluidActionResult; import net.minecraftforge.fluids.FluidUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import org.violetmoon.quark.content.automation.module.PistonsMoveTileEntitiesModule; -import org.violetmoon.quark.content.building.module.RopeModule; -import org.violetmoon.zeta.block.ZetaBlock; -import org.violetmoon.zeta.item.ZetaBlockItem; -import org.violetmoon.zeta.module.ZetaModule; -import org.violetmoon.zeta.registry.IZetaBlockItemProvider; -import org.violetmoon.zeta.registry.RenderLayerRegistry; - public class RopeBlock extends ZetaBlock implements IZetaBlockItemProvider, SimpleWaterloggedBlock { private static final VoxelShape SHAPE = box(6, 0, 6, 10, 16, 10); @@ -131,7 +131,14 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn, return InteractionResult.sidedSuccess(worldIn.isClientSide); } } else if(stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).isPresent()) { //TODO: Forge extension - return FluidUtil.interactWithFluidHandler(player, hand, worldIn, getBottomPos(worldIn, pos), Direction.UP) ? InteractionResult.sidedSuccess(worldIn.isClientSide) : InteractionResult.PASS; + FluidActionResult interact = FluidUtil.tryPickUpFluid(stack, player, worldIn, getBottomPos(worldIn, pos), Direction.UP); + if(interact.success) { + stack.shrink(1); + if(!player.addItem(interact.result)) + player.drop(interact.result, false); + } + + return interact.success ? InteractionResult.sidedSuccess(worldIn.isClientSide) : InteractionResult.PASS; } else if(stack.getItem() == Items.GLASS_BOTTLE) { BlockPos bottomPos = getBottomPos(worldIn, pos); BlockState stateAt = worldIn.getBlockState(bottomPos); @@ -144,7 +151,7 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn, if(stack.isEmpty()) player.setItemInHand(hand, bottleStack); - else if(!player.getInventory().add(bottleStack)) + else if(!player.addItem(bottleStack)) player.drop(bottleStack, false); return InteractionResult.sidedSuccess(worldIn.isClientSide);