aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/mixin/LeverBlockMixin.java
blob: 97c0a7c0b20c1bd3a8a2f893ab12c50c52e7e846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package de.hysky.skyblocker.mixin;

import de.hysky.skyblocker.skyblock.dungeon.OldLever;
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.block.BlockState;
import net.minecraft.block.LeverBlock;
import net.minecraft.block.WallMountedBlock;
import net.minecraft.util.shape.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import dev.cbyrne.betterinject.annotations.Arg;
import dev.cbyrne.betterinject.annotations.Inject;

@Mixin(LeverBlock.class)
public abstract class LeverBlockMixin extends WallMountedBlock {
    protected LeverBlockMixin(Settings settings) {
        super(settings);
    }

    @Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
    public void skyblocker$onGetOutlineShape(@Arg BlockState state, CallbackInfoReturnable<VoxelShape> cir) {
        if (Utils.isOnSkyblock()) {
            VoxelShape shape = OldLever.getShape(state.get(FACE), state.get(FACING));
            if (shape != null) cir.setReturnValue(shape);
        }
    }
}