Skip to content

Commit 81e9f30

Browse files
committed
Increase cohesion for ElytraFix
1 parent 24746e4 commit 81e9f30

File tree

4 files changed

+21
-40
lines changed

4 files changed

+21
-40
lines changed

src/main/java/com/lambda/EntityLivingBaseFireworkHelper.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/main/java/com/lambda/mixin/entity/MixinEntityLivingBase.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.lambda.mixin.entity;
22

3-
import com.lambda.EntityLivingBaseFireworkHelper;
3+
import com.lambda.client.module.modules.misc.ElytraFix;
44
import com.lambda.client.module.modules.movement.ElytraFlight;
55
import net.minecraft.entity.Entity;
66
import net.minecraft.entity.EntityLivingBase;
@@ -31,7 +31,7 @@ public MixinEntityLivingBase(World worldIn) {
3131
at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/entity/EntityLivingBase;getLookVec()Lnet/minecraft/util/math/Vec3d;", ordinal = 0)
3232
)
3333
private Vec3d vec3d(Vec3d original) {
34-
if (EntityLivingBaseFireworkHelper.shouldWork(EntityLivingBase.class.cast(this))) {
34+
if (ElytraFix.INSTANCE.shouldWork(EntityLivingBase.class.cast(this))) {
3535
float negPacketPitch = -ElytraFlight.INSTANCE.getPacketPitch();
3636
float f0 = MathHelper.cos((float) (-this.rotationYaw * 0.017453292f - Math.PI));
3737
float f1 = MathHelper.sin((float) (-this.rotationYaw * 0.017453292f - Math.PI));
@@ -49,7 +49,7 @@ private Vec3d vec3d(Vec3d original) {
4949
ordinal = 3
5050
)
5151
private float f(float original) {
52-
if (EntityLivingBaseFireworkHelper.shouldWork(EntityLivingBase.class.cast(this))) {
52+
if (ElytraFix.INSTANCE.shouldWork(EntityLivingBase.class.cast(this))) {
5353
return ElytraFlight.INSTANCE.getPacketPitch() * 0.017453292f;
5454
}
5555
return original;
@@ -76,7 +76,7 @@ private void getVec(
7676
at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/EntityLivingBase;motionX:D", ordinal = 7)
7777
)
7878
public double motionX(EntityLivingBase it) {
79-
if (EntityLivingBaseFireworkHelper.shouldModify(EntityLivingBase.class.cast(this))) {
79+
if (ElytraFix.INSTANCE.shouldModify(EntityLivingBase.class.cast(this))) {
8080
it.motionX += modifiedVec.x * 0.1 + (modifiedVec.x * 1.5 - this.motionX) * 0.5;
8181
}
8282
return it.motionX;
@@ -87,7 +87,7 @@ public double motionX(EntityLivingBase it) {
8787
at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/EntityLivingBase;motionY:D", ordinal = 7)
8888
)
8989
public double motionY(EntityLivingBase it) {
90-
if (EntityLivingBaseFireworkHelper.shouldModify(EntityLivingBase.class.cast(this))) {
90+
if (ElytraFix.INSTANCE.shouldModify(EntityLivingBase.class.cast(this))) {
9191
it.motionY += modifiedVec.y * 0.1 + (modifiedVec.y * 1.5 - this.motionY) * 0.5;
9292
}
9393
return it.motionY;
@@ -98,7 +98,7 @@ public double motionY(EntityLivingBase it) {
9898
at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/entity/EntityLivingBase;motionZ:D", ordinal = 7)
9999
)
100100
public double motionZ(EntityLivingBase it) {
101-
if (EntityLivingBaseFireworkHelper.shouldModify(EntityLivingBase.class.cast(this))) {
101+
if (ElytraFix.INSTANCE.shouldModify(EntityLivingBase.class.cast(this))) {
102102
it.motionZ += modifiedVec.z * 0.1 + (modifiedVec.z * 1.5 - this.motionZ) * 0.5;
103103
}
104104
return it.motionZ;

src/main/java/com/lambda/mixin/render/MixinViewFrustum.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.spongepowered.asm.mixin.injection.Inject;
1313
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1414

15-
// TODO: Find a working fix of this for optifine
1615
@Mixin(ViewFrustum.class)
1716
public abstract class MixinViewFrustum {
1817
@Shadow public RenderChunk[] renderChunks;

src/main/kotlin/com/lambda/client/module/modules/misc/ElytraFix.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import com.lambda.client.event.events.PacketEvent
44
import com.lambda.client.mixin.extension.boostedEntity
55
import com.lambda.client.module.Category
66
import com.lambda.client.module.Module
7+
import com.lambda.client.module.modules.movement.ElytraFlight
78
import com.lambda.client.util.threads.safeListener
9+
import com.lambda.mixin.accessor.AccessorEntityFireworkRocket
10+
import net.minecraft.client.entity.EntityPlayerSP
11+
import net.minecraft.entity.EntityLivingBase
812
import net.minecraft.entity.item.EntityFireworkRocket
913
import net.minecraft.network.play.server.SPacketPlayerPosLook
1014

@@ -22,4 +26,15 @@ object ElytraFix : Module(
2226
}
2327
}
2428
}
29+
30+
fun shouldWork(entity: EntityLivingBase) = EntityPlayerSP::class.java.isAssignableFrom(entity.javaClass)
31+
&& ElytraFlight.isEnabled
32+
&& ElytraFlight.mode.value == ElytraFlight.ElytraFlightMode.VANILLA
33+
34+
fun shouldModify(entity: EntityLivingBase) = shouldWork(entity)
35+
&& entity.world.loadedEntityList
36+
.filterIsInstance<AccessorEntityFireworkRocket>()
37+
.any {
38+
it.boostedEntity.equals(entity)
39+
}
2540
}

0 commit comments

Comments
 (0)