Skip to content

Commit 37f67b1

Browse files
authored
Add Avoid (#177)
1 parent 10ca5fe commit 37f67b1

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.lambda.client.mixin.client.world;
2+
3+
import com.lambda.client.module.modules.movement.Avoid;
4+
import net.minecraft.block.Block;
5+
import net.minecraft.block.BlockAir;
6+
import net.minecraft.block.BlockCactus;
7+
import net.minecraft.block.BlockFire;
8+
import net.minecraft.block.state.IBlockState;
9+
import net.minecraft.client.Minecraft;
10+
import net.minecraft.init.Blocks;
11+
import net.minecraft.util.math.AxisAlignedBB;
12+
import net.minecraft.util.math.BlockPos;
13+
import net.minecraft.world.IBlockAccess;
14+
import org.spongepowered.asm.mixin.Mixin;
15+
import org.spongepowered.asm.mixin.injection.At;
16+
import org.spongepowered.asm.mixin.injection.Inject;
17+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
18+
19+
//dude idk this mixin is so dumb ~Aven
20+
@Mixin({Block.class, BlockAir.class, BlockFire.class, BlockCactus.class})
21+
public class MixinGetCollisionBB {
22+
23+
private final Minecraft mc = Minecraft.getMinecraft();
24+
25+
@Inject(method = "getCollisionBoundingBox", at = @At("HEAD"), cancellable = true)
26+
private void getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos, CallbackInfoReturnable<AxisAlignedBB> cir) {
27+
if (mc.world != null && Avoid.INSTANCE.isEnabled()) {
28+
Block checkBlock = getBlock(pos);
29+
if (checkBlock.equals(Blocks.FIRE) && Avoid.INSTANCE.getFire() ||
30+
checkBlock.equals(Blocks.CACTUS) && Avoid.INSTANCE.getCactus() ||
31+
(!mc.world.isBlockLoaded(pos, false) || pos.getY() < 0) && Avoid.INSTANCE.getUnloaded()) {
32+
cir.cancel();
33+
cir.setReturnValue(Block.FULL_BLOCK_AABB);
34+
}
35+
}
36+
}
37+
public Block getBlock(BlockPos var0) {return mc.world.getBlockState(var0).getBlock();}
38+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.lambda.client.module.modules.movement
2+
3+
import com.lambda.client.module.Category
4+
import com.lambda.client.module.Module
5+
6+
object Avoid : Module(
7+
name = "Avoid",
8+
category = Category.MOVEMENT,
9+
description = "Prevents contact with certain objects"
10+
) {
11+
val fire by setting("Fire", true)
12+
val cactus by setting("Cactus", true)
13+
val unloaded by setting("Unloaded Chunks", true)
14+
}

src/main/resources/mixins.lambda.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"world.MixinBlockModelRenderer",
8080
"world.MixinBlockSoulSand",
8181
"world.MixinBlockWeb",
82+
"world.MixinGetCollisionBB",
8283
"world.MixinWorld"
8384
]
8485
}

0 commit comments

Comments
 (0)