diff --git a/src/main/java/com/lambda/mixin/world/MixinBlockDragonEgg.java b/src/main/java/com/lambda/mixin/world/MixinBlockDragonEgg.java new file mode 100644 index 000000000..57eb5319d --- /dev/null +++ b/src/main/java/com/lambda/mixin/world/MixinBlockDragonEgg.java @@ -0,0 +1,21 @@ +package com.lambda.mixin.world; + +import com.lambda.client.module.modules.movement.Prevent; +import net.minecraft.block.BlockDragonEgg; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(BlockDragonEgg.class) +public class MixinBlockDragonEgg { + @Inject(method = "teleport", at = @At("HEAD"), cancellable = true) + public void onTeleport(World worldIn, BlockPos pos, CallbackInfo ci) { + // if prevent is enabled, and the dragon egg setting is toggled, cancel the "teleport" function, so no particles spawn + if (Prevent.INSTANCE.isEnabled() && Prevent.INSTANCE.getDragonEgg()) { + ci.cancel(); + } + } +} diff --git a/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java b/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java index 2a9498ab5..e6eaabf8b 100644 --- a/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java +++ b/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java @@ -1,6 +1,6 @@ package com.lambda.mixin.world; -import com.lambda.client.module.modules.movement.Avoid; +import com.lambda.client.module.modules.movement.Prevent; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockCactus; @@ -23,11 +23,12 @@ public class MixinGetCollisionBB { @Inject(method = "getCollisionBoundingBox", at = @At("HEAD"), cancellable = true) private void getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos, CallbackInfoReturnable cir) { - if (mc.world != null && Avoid.INSTANCE.isEnabled()) { + if (mc.world != null && Prevent.INSTANCE.isEnabled()) { Block checkBlock = getBlock(pos); - if ((checkBlock.equals(Blocks.FIRE) && Avoid.INSTANCE.getFire()) || - (checkBlock.equals(Blocks.CACTUS) && Avoid.INSTANCE.getCactus()) || - ((!mc.world.isBlockLoaded(pos, false) || pos.getY() < 0) && Avoid.INSTANCE.getUnloaded())) { + if ((checkBlock.equals(Blocks.FIRE) && Prevent.INSTANCE.getFire()) || + (checkBlock.equals(Blocks.CACTUS) && Prevent.INSTANCE.getCactus()) || + (!mc.world.isBlockLoaded(pos, false) && Prevent.INSTANCE.getUnloaded()) || + (pos.getY() < 0 && Prevent.INSTANCE.getVoid())) { cir.cancel(); cir.setReturnValue(Block.FULL_BLOCK_AABB); } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Avoid.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Avoid.kt deleted file mode 100644 index 21a3ed55e..000000000 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Avoid.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.lambda.client.module.modules.movement - -import com.lambda.client.module.Category -import com.lambda.client.module.Module - -object Avoid : Module( - name = "Avoid", - description = "Prevents contact with certain objects", - category = Category.MOVEMENT -) { - val fire by setting("Fire", true) - val cactus by setting("Cactus", true) - val unloaded by setting("Unloaded Chunks", true) -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Prevent.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Prevent.kt new file mode 100644 index 000000000..c2218c7d8 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Prevent.kt @@ -0,0 +1,38 @@ +package com.lambda.client.module.modules.movement + +import com.lambda.client.event.events.PacketEvent +import com.lambda.client.module.Category +import com.lambda.client.module.Module +import com.lambda.client.util.threads.safeListener +import net.minecraft.init.Blocks +import net.minecraft.network.play.client.CPacketPlayerDigging +import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock + +object Prevent : Module( + name = "Prevent", + description = "Prevents contact with certain objects", + category = Category.MOVEMENT +) { + val fire by setting("Fire", true, description = "Prevents you from touching fire by making the hitbox solid") + val cactus by setting("Cactus", true, description = "Prevents you from taking cactus damage by slightly expanding its hitbox") + val unloaded by setting("Unloaded Chunks", true, description = "Prevents you from entering unloaded chunks") + val void by setting("Void", true, description = "Prevents you from entering Y levels below zero") + val dragonEgg by setting("Dragon Egg", true, description = "Prevents you from teleporting dragon eggs") + + init { + safeListener { + if (dragonEgg) { + when (it.packet) { + is CPacketPlayerTryUseItemOnBlock -> { + if (world.getBlockState(it.packet.pos).block == Blocks.DRAGON_EGG) it.cancel() + } + + is CPacketPlayerDigging -> { + if (world.getBlockState(it.packet.position).block == Blocks.DRAGON_EGG) it.cancel() + } + } + } + + } + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.lambda.json b/src/main/resources/mixins.lambda.json index 08b385b45..a5b0880b3 100644 --- a/src/main/resources/mixins.lambda.json +++ b/src/main/resources/mixins.lambda.json @@ -75,6 +75,7 @@ "render.MixinViewFrustum", "render.MixinVisGraph", "world.MixinBlock", + "world.MixinBlockDragonEgg", "world.MixinBlockFluidRenderer", "world.MixinBlockLiquid", "world.MixinBlockModelRenderer",