Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Avoid with more features #432

Merged
merged 2 commits into from
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/java/com/lambda/mixin/world/MixinBlockDragonEgg.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
11 changes: 6 additions & 5 deletions src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<AxisAlignedBB> 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);
}
Expand Down
14 changes: 0 additions & 14 deletions src/main/kotlin/com/lambda/client/module/modules/movement/Avoid.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<PacketEvent.Send> {
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()
}
}
}

}
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.lambda.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"render.MixinViewFrustum",
"render.MixinVisGraph",
"world.MixinBlock",
"world.MixinBlockDragonEgg",
"world.MixinBlockFluidRenderer",
"world.MixinBlockLiquid",
"world.MixinBlockModelRenderer",
Expand Down