-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
85 additions
and
31 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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package gdavid.sixdoftest; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.util.math.RotationAxis; | ||
import net.minecraft.util.math.Vec3d; | ||
import org.joml.Quaternionf; | ||
|
||
public class RollManager { | ||
|
||
public static float getRoll(Entity entity) { | ||
return (float) entity.getVelocity().dotProduct(entity.getRotationVecClient().crossProduct(new Vec3d(0, 1, 0))); | ||
} | ||
|
||
@Environment(EnvType.CLIENT) | ||
public static void rollTransform(MatrixStack ms, Entity entity) { | ||
rollTransform(ms, getRoll(entity)); | ||
} | ||
|
||
@Environment(EnvType.CLIENT) | ||
public static void rollTransform(MatrixStack ms, float roll) { | ||
Quaternionf q = RotationAxis.POSITIVE_Z.rotation(roll); | ||
var mats = ms.peek(); | ||
mats.getPositionMatrix().rotateLocal(q); | ||
mats.getNormalMatrix().rotateLocal(q); | ||
} | ||
|
||
} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/gdavid/sixdoftest/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,25 @@ | ||
package gdavid.sixdoftest.mixin; | ||
|
||
import gdavid.sixdoftest.SpaceManager; | ||
import net.minecraft.entity.LivingEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(LivingEntity.class) | ||
public class LivingEntityMixin { | ||
|
||
@Unique | ||
private LivingEntity self() { | ||
return (LivingEntity) (Object) this; | ||
} | ||
|
||
@Inject(method = "computeFallDamage", at = @At("HEAD"), cancellable = true) | ||
private void noFallDamageIn6DOFSpace(float fallDistance, float damageMultiplier, CallbackInfoReturnable<Integer> callback) { | ||
if (!SpaceManager.isIn6dof(self())) return; | ||
callback.setReturnValue(0); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "gdavid.sixdoftest.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"EntityMixin" | ||
], | ||
"client": [ | ||
"PlayerEntityRendererMixin" | ||
], | ||
"injectors": { "defaultRequire": 1 } | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "gdavid.sixdoftest.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"EntityMixin", | ||
"LivingEntityMixin" | ||
], | ||
"client": [ | ||
"PlayerEntityRendererMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 } | ||
} |