forked from Jorbon/cool_elytra
-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
101 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
- Significant improvements to the banking physics | ||
- Hold W to go faster | ||
- Hopefully fixed the world disappearing sometimes |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
54 changes: 54 additions & 0 deletions
54
src/main/java/nl/enjarai/doabarrelroll/mixin/LivingEntityMixin.java
This file contains 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,54 @@ | ||
package nl.enjarai.doabarrelroll.mixin; | ||
|
||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.particle.ParticleTypes; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.World; | ||
import nl.enjarai.doabarrelroll.DoABarrelRollClient; | ||
import nl.enjarai.doabarrelroll.config.ModConfig; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
@Mixin(LivingEntity.class) | ||
public abstract class LivingEntityMixin extends Entity { | ||
|
||
public LivingEntityMixin(EntityType<?> type, World world) { | ||
super(type, world); | ||
} | ||
|
||
@ModifyArg( | ||
method = "travel(Lnet/minecraft/util/math/Vec3d;)V", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/entity/LivingEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V", | ||
ordinal = 6 | ||
) | ||
) | ||
private Vec3d doABarrelRoll$wrapElytraVelocity(Vec3d original) { | ||
if (!(((LivingEntity) (Object) this) instanceof ClientPlayerEntity) || !ModConfig.INSTANCE.enableThrust) return original; | ||
|
||
Vec3d rotation = getRotationVector(); | ||
Vec3d velocity = getVelocity(); | ||
|
||
int particleDensity = (int) MathHelper.clamp(DoABarrelRollClient.throttle * 10, 0, 10); | ||
if (DoABarrelRollClient.throttle > 0.1 && world.getTime() % (11 - particleDensity) == 0) { | ||
var pPos = getPos().add(velocity.multiply(0.5).negate()); | ||
world.addParticle( | ||
ParticleTypes.CAMPFIRE_SIGNAL_SMOKE, | ||
pPos.getX(), pPos.getY(), pPos.getZ(), | ||
random.nextGaussian() * 0.05, -velocity.y * 0.5, random.nextGaussian() * 0.05 | ||
); | ||
} | ||
|
||
return original.add( | ||
(rotation.x * 0.1 + (rotation.x * 1.5 - velocity.x) * 0.5) * DoABarrelRollClient.throttle, | ||
(rotation.y * 0.1 + (rotation.y * 1.5 - velocity.y) * 0.5) * DoABarrelRollClient.throttle, | ||
(rotation.z * 0.1 + (rotation.z * 1.5 - velocity.z) * 0.5) * DoABarrelRollClient.throttle | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -14,5 +14,6 @@ | |
"defaultRequire": 1 | ||
}, | ||
"mixins": [ | ||
"LivingEntityMixin" | ||
] | ||
} |