Skip to content

Commit 021f63f

Browse files
New feature
1 parent df5b36e commit 021f63f

File tree

1 file changed

+32
-0
lines changed
  • src/main/java/nekiplay/meteorplus/features/modules/combat

1 file changed

+32
-0
lines changed

src/main/java/nekiplay/meteorplus/features/modules/combat/Hunt.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import meteordevelopment.meteorclient.events.world.TickEvent;
44
import meteordevelopment.meteorclient.pathing.PathManagers;
5+
import meteordevelopment.meteorclient.settings.BoolSetting;
56
import meteordevelopment.meteorclient.settings.EntityTypeListSetting;
67
import meteordevelopment.meteorclient.settings.Setting;
78
import meteordevelopment.meteorclient.settings.SettingGroup;
@@ -12,11 +13,16 @@
1213
import meteordevelopment.meteorclient.utils.entity.SortPriority;
1314
import meteordevelopment.meteorclient.utils.entity.TargetUtils;
1415
import meteordevelopment.orbit.EventHandler;
16+
import net.minecraft.block.Block;
17+
import net.minecraft.block.Blocks;
1518
import net.minecraft.entity.Entity;
1619
import net.minecraft.entity.EntityType;
1720
import net.minecraft.entity.LivingEntity;
1821
import net.minecraft.entity.Tameable;
1922
import net.minecraft.entity.player.PlayerEntity;
23+
import net.minecraft.util.math.BlockPos;
24+
import net.minecraft.util.math.Vec3d;
25+
import net.minecraft.world.World;
2026

2127
import java.util.ArrayList;
2228
import java.util.Set;
@@ -35,6 +41,20 @@ public Hunt() {
3541
.build()
3642
);
3743

44+
private final Setting<Boolean> onGround = sgGeneral.add(new BoolSetting.Builder()
45+
.name("On ground only")
46+
.description("Attack entities on ground only")
47+
.defaultValue(false)
48+
.build()
49+
);
50+
51+
private final Setting<Boolean> customCheck = sgGeneral.add(new BoolSetting.Builder()
52+
.name("Custom on ground check")
53+
.description("Use a custom on ground check instead of the usual entity.isOnGround. Useful on some servers")
54+
.defaultValue(false)
55+
.build()
56+
);
57+
3858
private boolean entityCheck(Entity entity) {
3959
if (entity.equals(mc.player) || entity.equals(mc.cameraEntity)) return false;
4060
if ((entity instanceof LivingEntity && ((LivingEntity) entity).isDead()) || !entity.isAlive()) return false;
@@ -54,7 +74,19 @@ private boolean entityCheck(Entity entity) {
5474
return false;
5575
}
5676
}
77+
if (onGround.get()) {
78+
if (customCheck.get()) {
79+
World world = entity.getWorld();
80+
81+
Vec3d entityPos = entity.getPos();
82+
BlockPos posBelow = new BlockPos((int) entityPos.x, (int) (entityPos.y - 1), (int) entityPos.z);
83+
84+
Block blockBelow = world.getBlockState(posBelow).getBlock();
5785

86+
return (blockBelow != Blocks.AIR && blockBelow != Blocks.WATER && blockBelow != Blocks.LAVA);
87+
}
88+
else return entity.isOnGround();
89+
}
5890
return true;
5991
}
6092
private final ArrayList<Entity> targets = new ArrayList<>();

0 commit comments

Comments
 (0)