|
| 1 | +/* |
| 2 | + * This program is free software; you can redistribute it and/or |
| 3 | + * modify it under the terms of the GNU Lesser General Public |
| 4 | + * License as published by the Free Software Foundation; either |
| 5 | + * version 3 of the License, or (at your option) any later version. |
| 6 | + * |
| 7 | + * This program is distributed in the hope that it will be useful, |
| 8 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 10 | + * Lesser General Public License for more details. |
| 11 | + * |
| 12 | + * You should have received a copy of the GNU Lesser General Public License |
| 13 | + * along with this program; if not, write to the Free Software Foundation, |
| 14 | + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 15 | + * |
| 16 | + * For more information, see the LICENSE file. |
| 17 | + */ |
| 18 | + |
| 19 | +package io.github.axolotlclient.oldanimations.mixin.blocks; |
| 20 | + |
| 21 | +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
| 22 | +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
| 23 | +import com.llamalad7.mixinextras.sugar.Local; |
| 24 | +import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig; |
| 25 | +import io.github.axolotlclient.oldanimations.util.PlayerUtil; |
| 26 | +import net.minecraft.block.RedstoneWireBlock; |
| 27 | +import net.minecraft.block.state.BlockState; |
| 28 | +import net.minecraft.util.math.BlockPos; |
| 29 | +import net.minecraft.util.math.Direction; |
| 30 | +import net.minecraft.world.WorldView; |
| 31 | +import org.spongepowered.asm.mixin.Mixin; |
| 32 | +import org.spongepowered.asm.mixin.injection.At; |
| 33 | + |
| 34 | +@Mixin(RedstoneWireBlock.class) |
| 35 | +public abstract class RedstoneWireBlockMixin { |
| 36 | + |
| 37 | + @WrapOperation(method = "getConnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;Lnet/minecraft/util/math/Direction;)Z")) |
| 38 | + private boolean axolotlclient$disconnectBlock(BlockState blockState, Direction direction, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) { |
| 39 | + if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() && |
| 40 | + PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) { |
| 41 | + return false; |
| 42 | + } |
| 43 | + return original.call(blockState, direction); |
| 44 | + } |
| 45 | + |
| 46 | + @WrapOperation(method = "getConnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;)Z")) |
| 47 | + private boolean axolotlclient$disconnectBlock2(BlockState blockState, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) { |
| 48 | + if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() && |
| 49 | + PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) { |
| 50 | + return false; |
| 51 | + } |
| 52 | + return original.call(blockState); |
| 53 | + } |
| 54 | + |
| 55 | + @WrapOperation(method = "connectsTo", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;Lnet/minecraft/util/math/Direction;)Z")) |
| 56 | + private boolean axolotlclient$disconnectBlock3(BlockState blockState, Direction direction, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) { |
| 57 | + if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() && |
| 58 | + PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) { |
| 59 | + return false; |
| 60 | + } |
| 61 | + return original.call(blockState, direction); |
| 62 | + } |
| 63 | + |
| 64 | + @WrapOperation(method = "connectsTo", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/world/WorldView;Lnet/minecraft/util/math/BlockPos;)Z")) |
| 65 | + private boolean axolotlclient$disconnectBlock4(WorldView worldView, BlockPos blockPos, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) { |
| 66 | + if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() && |
| 67 | + PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) { |
| 68 | + return false; |
| 69 | + } |
| 70 | + return original.call(worldView, blockPos); |
| 71 | + } |
| 72 | + |
| 73 | + @WrapOperation(method = "getConnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;Lnet/minecraft/util/math/Direction;)Z")) |
| 74 | + private boolean axolotlclient$disconnectBlock5(BlockState blockState, Direction direction, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) { |
| 75 | + if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() && |
| 76 | + PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) { |
| 77 | + return false; |
| 78 | + } |
| 79 | + return original.call(blockState, direction); |
| 80 | + } |
| 81 | + |
| 82 | + @WrapOperation(method = "getConnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/RedstoneWireBlock;shouldConnectTo(Lnet/minecraft/block/state/BlockState;)Z")) |
| 83 | + private boolean axolotlclient$disconnectBlock6(BlockState blockState, Operation<Boolean> original, @Local(index = 4, ordinal = 1) BlockPos blockPos2) { |
| 84 | + if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.useAndMineDestroyVisual.get() && |
| 85 | + PlayerUtil.INSTANCE.isFakeMinedBlock(blockPos2)) { |
| 86 | + return false; |
| 87 | + } |
| 88 | + return original.call(blockState); |
| 89 | + } |
| 90 | +} |
0 commit comments