| 1 | /*
|
| 2 | * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
|
| 3 | * Copyright (c) Meteor Development.
|
| 4 | */
|
| 5 |
|
| 6 | package meteordevelopment.meteorclient.mixin;
|
| 7 |
|
| 8 | import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
| 9 | import meteordevelopment.meteorclient.systems.modules.Modules;
|
| 10 | import meteordevelopment.meteorclient.systems.modules.movement.NoSlow;
|
| 11 | import meteordevelopment.meteorclient.systems.modules.movement.Slippy;
|
| 12 | import meteordevelopment.meteorclient.systems.modules.render.Xray;
|
| 13 | import meteordevelopment.meteorclient.utils.misc.ListMode;
|
| 14 | import net.minecraft.core.Direction;
|
| 15 | import net.minecraft.world.level.ItemLike;
|
| 16 | import net.minecraft.world.level.block.Block;
|
| 17 | import net.minecraft.world.level.block.Blocks;
|
| 18 | import net.minecraft.world.level.block.state.BlockBehaviour;
|
| 19 | import net.minecraft.world.level.block.state.BlockState;
|
| 20 | import org.spongepowered.asm.mixin.Mixin;
|
| 21 | import org.spongepowered.asm.mixin.injection.At;
|
| 22 | import org.spongepowered.asm.mixin.injection.Inject;
|
| 23 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
| 24 |
|
| 25 | @Mixin(Block.class)
|
| 26 | public abstract class BlockMixin extends BlockBehaviour implements ItemLike {
|
| 27 | public BlockMixin(Properties properties) {
|
| 28 | super(properties);
|
| 29 | }
|
| 30 |
|
| 31 | @ModifyReturnValue(method = "getFriction", at = @At("RETURN"))
|
| 32 | public float getFriction(float original) {
|
| 33 | // For some retarded reason Tweakeroo calls this method before meteor is initialized
|
| 34 | if (Modules.get() == null) return original;
|
| 35 |
|
| 36 | Slippy slippy = Modules.get().get(Slippy.class);
|
| 37 | Block block = (Block) (Object) this;
|
| 38 |
|
| 39 | boolean blockInList = (slippy.listMode.get() == ListMode.Whitelist ? slippy.allowedBlocks.get() : slippy.ignoredBlocks.get()).contains(block);
|
| 40 | if (slippy.isActive() && slippy.listMode.get().allows(blockInList)) {
|
| 41 | return slippy.friction.get().floatValue();
|
| 42 | }
|
| 43 |
|
| 44 | if (block == Blocks.SLIME_BLOCK && Modules.get().get(NoSlow.class).slimeBlock()) return 0.6F;
|
| 45 | else return original;
|
| 46 | }
|
| 47 |
|
| 48 | // For More Culling compatibility - runs before More Culling's inject to force-render whitelisted Xray blocks
|
| 49 | @Inject(method = "shouldRenderFace", at = @At("HEAD"), cancellable = true)
|
| 50 | private static void meteor$forceXrayFace(BlockState state, BlockState neighborState, Direction direction, CallbackInfoReturnable<Boolean> cir) {
|
| 51 | Modules modules = Modules.get();
|
| 52 | if (modules == null) return;
|
| 53 |
|
| 54 | Xray xray = modules.get(Xray.class);
|
| 55 | if (xray.isActive() && !xray.isBlocked(state.getBlock(), null)) {
|
| 56 | cir.setReturnValue(true);
|
| 57 | }
|
| 58 | }
|
| 59 | }
|
| 60 |
|