-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
EndermanLook -> MobLook #5372
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
Open
machiecodes
wants to merge
2
commits into
MeteorDevelopment:master
Choose a base branch
from
machiecodes:mob-look
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
EndermanLook -> MobLook #5372
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 0 additions & 85 deletions
85
src/main/java/meteordevelopment/meteorclient/systems/modules/world/EndermanLook.java
This file was deleted.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
src/main/java/meteordevelopment/meteorclient/systems/modules/world/MobLook.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). | ||
* Copyright (c) Meteor Development. | ||
*/ | ||
|
||
package meteordevelopment.meteorclient.systems.modules.world; | ||
|
||
import meteordevelopment.meteorclient.events.world.TickEvent; | ||
import meteordevelopment.meteorclient.settings.BoolSetting; | ||
import meteordevelopment.meteorclient.settings.EnumSetting; | ||
import meteordevelopment.meteorclient.settings.Setting; | ||
import meteordevelopment.meteorclient.settings.SettingGroup; | ||
import meteordevelopment.meteorclient.systems.modules.Categories; | ||
import meteordevelopment.meteorclient.systems.modules.Module; | ||
import meteordevelopment.meteorclient.utils.entity.Target; | ||
import meteordevelopment.meteorclient.utils.player.Rotations; | ||
import meteordevelopment.orbit.EventHandler; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.mob.CreakingEntity; | ||
import net.minecraft.entity.mob.EndermanEntity; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
public class MobLook extends Module { | ||
private final SettingGroup sgGeneral = settings.getDefaultGroup(); | ||
|
||
private final Setting<Mode> endermenMode = sgGeneral.add(new EnumSetting.Builder<Mode>() | ||
.name("endermen-mode") | ||
.description("Whether to look at/away from endermen") | ||
.defaultValue(Mode.Away) | ||
.build() | ||
); | ||
|
||
private final Setting<Boolean> stunHostiles = sgGeneral.add(new BoolSetting.Builder() | ||
.name("stun-hostiles") | ||
.description("Automatically stares at hostile endermen to stun them in place.") | ||
.defaultValue(true) | ||
.visible(() -> endermenMode.get() == Mode.Away) | ||
.build() | ||
); | ||
|
||
private final Setting<Boolean> stunCreaking = sgGeneral.add(new BoolSetting.Builder() | ||
.name("stun-creaking") | ||
.description("Automatically stares at hostile creaking to stun them in place.") | ||
.defaultValue(true) | ||
.build() | ||
); | ||
|
||
public MobLook() { | ||
super(Categories.World, "mob-look", "Look at/away from endermen and creaking to prevent them from moving."); | ||
} | ||
|
||
@EventHandler | ||
private void onTick(TickEvent.Pre event) { | ||
if (mc.player.getAbilities().creativeMode) return; | ||
|
||
for (Entity entity : mc.world.getEntities()) { | ||
if (stunCreaking.get() && entity instanceof CreakingEntity creaking && creaking.isAlive() && mc.player.canSee(creaking)) { | ||
Rotations.rotate(Rotations.getYaw(creaking), Rotations.getPitch(creaking), -75); | ||
} | ||
|
||
if (entity instanceof EndermanEntity enderman && enderman.isAlive() && mc.player.canSee(enderman)) { | ||
if (mc.player.getEquippedStack(EquipmentSlot.HEAD).isOf(Blocks.CARVED_PUMPKIN.asItem())) continue; | ||
|
||
switch (endermenMode.get()) { | ||
case Away -> { | ||
if (enderman.isAngry() && stunHostiles.get()) { | ||
Rotations.rotate(Rotations.getYaw(enderman), Rotations.getPitch(enderman, Target.Head), -75); | ||
} else if (playerIsLookingAt(enderman)) { | ||
Rotations.rotate(mc.player.getYaw(), 90, -75); | ||
} | ||
} | ||
case At -> { | ||
if (!enderman.isAngry()) { | ||
Rotations.rotate(Rotations.getYaw(enderman), Rotations.getPitch(enderman, Target.Head), -75); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @see LivingEntity#isEntityLookingAtMe(LivingEntity, double, boolean, boolean, double...) | ||
*/ | ||
private boolean playerIsLookingAt(EndermanEntity entity) { | ||
Vec3d vec3d = mc.player.getRotationVec(1.0F).normalize(); | ||
Vec3d vec3d2 = new Vec3d(entity.getX() - mc.player.getX(), entity.getEyeY() - mc.player.getEyeY(), entity.getZ() - mc.player.getZ()); | ||
|
||
double d = vec3d2.length(); | ||
vec3d2 = vec3d2.normalize(); | ||
double e = vec3d.dotProduct(vec3d2); | ||
|
||
return e > 1.0D - 0.025D / d; | ||
} | ||
|
||
public enum Mode { | ||
At, | ||
Away | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strange description