Skip to content

Commit f4f99ec

Browse files
authoredDec 18, 2022
Expand Avoid with more features (renamed to Prevent) (#432)
* Expand Avoid with more features * Renamed Avoid to Prevent * Added an option for dragon eggs, and void * Added mixin cancelling particles from spawning when clicking the egg * Fix typo
1 parent 84a5f3b commit f4f99ec

File tree

5 files changed

+66
-19
lines changed

5 files changed

+66
-19
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.lambda.mixin.world;
2+
3+
import com.lambda.client.module.modules.movement.Prevent;
4+
import net.minecraft.block.BlockDragonEgg;
5+
import net.minecraft.util.math.BlockPos;
6+
import net.minecraft.world.World;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
12+
@Mixin(BlockDragonEgg.class)
13+
public class MixinBlockDragonEgg {
14+
@Inject(method = "teleport", at = @At("HEAD"), cancellable = true)
15+
public void onTeleport(World worldIn, BlockPos pos, CallbackInfo ci) {
16+
// if prevent is enabled, and the dragon egg setting is toggled, cancel the "teleport" function, so no particles spawn
17+
if (Prevent.INSTANCE.isEnabled() && Prevent.INSTANCE.getDragonEgg()) {
18+
ci.cancel();
19+
}
20+
}
21+
}

Diff for: ‎src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.lambda.mixin.world;
22

3-
import com.lambda.client.module.modules.movement.Avoid;
3+
import com.lambda.client.module.modules.movement.Prevent;
44
import net.minecraft.block.Block;
55
import net.minecraft.block.BlockAir;
66
import net.minecraft.block.BlockCactus;
@@ -23,11 +23,12 @@ public class MixinGetCollisionBB {
2323

2424
@Inject(method = "getCollisionBoundingBox", at = @At("HEAD"), cancellable = true)
2525
private void getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos, CallbackInfoReturnable<AxisAlignedBB> cir) {
26-
if (mc.world != null && Avoid.INSTANCE.isEnabled()) {
26+
if (mc.world != null && Prevent.INSTANCE.isEnabled()) {
2727
Block checkBlock = getBlock(pos);
28-
if ((checkBlock.equals(Blocks.FIRE) && Avoid.INSTANCE.getFire()) ||
29-
(checkBlock.equals(Blocks.CACTUS) && Avoid.INSTANCE.getCactus()) ||
30-
((!mc.world.isBlockLoaded(pos, false) || pos.getY() < 0) && Avoid.INSTANCE.getUnloaded())) {
28+
if ((checkBlock.equals(Blocks.FIRE) && Prevent.INSTANCE.getFire()) ||
29+
(checkBlock.equals(Blocks.CACTUS) && Prevent.INSTANCE.getCactus()) ||
30+
(!mc.world.isBlockLoaded(pos, false) && Prevent.INSTANCE.getUnloaded()) ||
31+
(pos.getY() < 0 && Prevent.INSTANCE.getVoid())) {
3132
cir.cancel();
3233
cir.setReturnValue(Block.FULL_BLOCK_AABB);
3334
}

Diff for: ‎src/main/kotlin/com/lambda/client/module/modules/movement/Avoid.kt

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.lambda.client.module.modules.movement
2+
3+
import com.lambda.client.event.events.PacketEvent
4+
import com.lambda.client.module.Category
5+
import com.lambda.client.module.Module
6+
import com.lambda.client.util.threads.safeListener
7+
import net.minecraft.init.Blocks
8+
import net.minecraft.network.play.client.CPacketPlayerDigging
9+
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock
10+
11+
object Prevent : Module(
12+
name = "Prevent",
13+
description = "Prevents contact with certain objects",
14+
category = Category.MOVEMENT
15+
) {
16+
val fire by setting("Fire", true, description = "Prevents you from touching fire by making the hitbox solid")
17+
val cactus by setting("Cactus", true, description = "Prevents you from taking cactus damage by slightly expanding its hitbox")
18+
val unloaded by setting("Unloaded Chunks", true, description = "Prevents you from entering unloaded chunks")
19+
val void by setting("Void", true, description = "Prevents you from entering Y levels below zero")
20+
val dragonEgg by setting("Dragon Egg", true, description = "Prevents you from teleporting dragon eggs")
21+
22+
init {
23+
safeListener<PacketEvent.Send> {
24+
if (dragonEgg) {
25+
when (it.packet) {
26+
is CPacketPlayerTryUseItemOnBlock -> {
27+
if (world.getBlockState(it.packet.pos).block == Blocks.DRAGON_EGG) it.cancel()
28+
}
29+
30+
is CPacketPlayerDigging -> {
31+
if (world.getBlockState(it.packet.position).block == Blocks.DRAGON_EGG) it.cancel()
32+
}
33+
}
34+
}
35+
36+
}
37+
}
38+
}

Diff for: ‎src/main/resources/mixins.lambda.json

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"render.MixinViewFrustum",
7676
"render.MixinVisGraph",
7777
"world.MixinBlock",
78+
"world.MixinBlockDragonEgg",
7879
"world.MixinBlockFluidRenderer",
7980
"world.MixinBlockLiquid",
8081
"world.MixinBlockModelRenderer",

0 commit comments

Comments
 (0)
Please sign in to comment.