|
| 1 | +package io.github.razordevs.deep_aether.mixin.block; |
| 2 | + |
| 3 | +import com.aetherteam.aether.block.AetherBlocks; |
| 4 | +import com.llamalad7.mixinextras.sugar.Local; |
| 5 | +import io.github.razordevs.deep_aether.init.DABlocks; |
| 6 | +import net.minecraft.core.BlockPos; |
| 7 | +import net.minecraft.server.level.ServerLevel; |
| 8 | +import net.minecraft.world.level.Level; |
| 9 | +import net.minecraft.world.level.block.Block; |
| 10 | +import net.minecraft.world.level.block.PointedDripstoneBlock; |
| 11 | +import net.minecraft.world.level.block.state.BlockState; |
| 12 | +import net.minecraft.world.level.gameevent.GameEvent; |
| 13 | +import net.minecraft.world.level.material.Fluid; |
| 14 | +import net.minecraft.world.level.material.Fluids; |
| 15 | +import org.spongepowered.asm.mixin.Mixin; |
| 16 | +import org.spongepowered.asm.mixin.injection.At; |
| 17 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 18 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 19 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 20 | + |
| 21 | +import java.util.Optional; |
| 22 | + |
| 23 | +@Mixin(PointedDripstoneBlock.class) |
| 24 | +public abstract class PointedDripstoneBlockMixin { |
| 25 | + |
| 26 | + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;is(Lnet/minecraft/world/level/block/Block;)Z"), method = "maybeTransferFluid") |
| 27 | + private static void maybeTransferFluid(BlockState state, ServerLevel level, BlockPos pos, float p_221863_, CallbackInfo ci, @Local Optional<PointedDripstoneBlock.FluidInfo> optional, @Local Fluid fluid, @Local(ordinal = 1) BlockPos blockpos) { |
| 28 | + if (optional.get().sourceState().is(DABlocks.AETHER_MUD.get()) && fluid == Fluids.WATER) { |
| 29 | + BlockState blockstate1 = AetherBlocks.QUICKSOIL.get().defaultBlockState(); |
| 30 | + level.setBlockAndUpdate(optional.get().pos(), blockstate1); |
| 31 | + Block.pushEntitiesUp(optional.get().sourceState(), blockstate1, level, optional.get().pos()); |
| 32 | + level.gameEvent(GameEvent.BLOCK_CHANGE, optional.get().pos(), GameEvent.Context.of(blockstate1)); |
| 33 | + level.levelEvent(1504, blockpos, 0); |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + @Inject(at = @At("RETURN"), method = "getFluidAboveStalactite", cancellable = true) |
| 38 | + private static void getFluidAboveStalactite(Level p_154182_, BlockPos p_154183_, BlockState p_154184_, CallbackInfoReturnable<Optional<PointedDripstoneBlock.FluidInfo>> cir) { |
| 39 | + Optional<PointedDripstoneBlock.FluidInfo> info = cir.getReturnValue(); |
| 40 | + |
| 41 | + if(info.isPresent()) { |
| 42 | + if(info.get().sourceState().is(DABlocks.AETHER_MUD)) { |
| 43 | + cir.setReturnValue(Optional.of(new PointedDripstoneBlock.FluidInfo(info.get().pos(), Fluids.WATER, info.get().sourceState()))); |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | +} |
0 commit comments