-
Notifications
You must be signed in to change notification settings - Fork 7
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
6 changed files
with
94 additions
and
74 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
2 changes: 1 addition & 1 deletion
2
.../transportation/LivingEntityAccessor.java → ...rtation/riptide/LivingEntityAccessor.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
82 changes: 82 additions & 0 deletions
82
src/main/java/dev/symphony/harmony/mixin/transportation/riptide/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,82 @@ | ||
package dev.symphony.harmony.mixin.transportation.riptide; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import dev.symphony.harmony.config.HarmonyConfig; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
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.CallbackInfo; | ||
|
||
@Mixin(LivingEntity.class) | ||
public abstract class LivingEntityMixin extends Entity { | ||
/** | ||
* FEATURE: Using riptide trident enchant underwater makes the player gain acceleration during its effect. | ||
* @author Kiku | ||
* @author Flatkat | ||
*/ | ||
@SuppressWarnings("JavadocDeclaration") | ||
@Unique | ||
private static final float MODIFIER = HarmonyConfig.riptideAccelerationOnWater; | ||
@Unique | ||
private static final float DEG = (float) (Math.PI / 180F); | ||
|
||
@Shadow | ||
protected int riptideTicks; | ||
|
||
@Shadow public abstract void setSprinting(boolean sprinting); | ||
|
||
public LivingEntityMixin(EntityType<?> type, World world) { | ||
super(type, world); | ||
} | ||
|
||
//Applies constant acceleration when using riptide and touching water. | ||
@Inject( | ||
method = "tickMovement", at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/entity/LivingEntity;tickRiptide(Lnet/minecraft/util/math/Box;Lnet/minecraft/util/math/Box;)V" | ||
) | ||
) | ||
private void accelerateWhenRiptide(CallbackInfo ci) { | ||
if(HarmonyConfig.riptideAccelerationOnWater != 0){ | ||
if (!this.isTouchingWater()) return; | ||
float f = getYaw(); | ||
float g = getPitch(); | ||
float h = -MathHelper.sin(f * DEG) * MathHelper.cos(g * DEG); | ||
float k = -MathHelper.sin(g * DEG); | ||
float l = MathHelper.cos(f * DEG) * MathHelper.cos(g * DEG); | ||
float m = MathHelper.sqrt(h * h + k * k + l * l); | ||
h *= MODIFIER / m; | ||
k *= MODIFIER / m; | ||
l *= MODIFIER / m; | ||
addVelocity(h, k, l); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* FEATURE: Reduced water drag when using riptide | ||
* @author Kiku | ||
* @author Flatkat | ||
**/ | ||
@ModifyExpressionValue( | ||
method = "travelInFluid", at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/entity/LivingEntity;hasStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Z" | ||
) | ||
) | ||
private boolean boostWhenRiptide(boolean original) { | ||
if(HarmonyConfig.reduceRiptideWaterDrag){ | ||
return original || this.riptideTicks>0; | ||
} | ||
return original; | ||
} | ||
|
||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...ixin/transportation/TridentItemMixin.java → ...nsportation/riptide/TridentItemMixin.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
4 changes: 4 additions & 0 deletions
4
src/main/java/dev/symphony/harmony/mixin/transportation/riptide/package-info.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,4 @@ | ||
/** | ||
* Contains multiple features related to Trident's Riptide enchantment | ||
*/ | ||
package dev.symphony.harmony.mixin.transportation.riptide; |
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