-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
46 additions
and
67 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
43 changes: 43 additions & 0 deletions
43
projects/pswg/src/main/java/com/parzivail/pswg/client/sound/EnvironmentSoundManager.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,43 @@ | ||
package com.parzivail.pswg.client.sound; | ||
|
||
import com.parzivail.pswg.entity.BlasterBoltEntity; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvents; | ||
import net.minecraft.util.math.Box; | ||
|
||
public class EnvironmentSoundManager | ||
{ | ||
public static void tick(MinecraftClient mc) | ||
{ | ||
if (mc.player == null || mc.world == null) | ||
return; | ||
|
||
var pos = mc.player.getEyePos(); | ||
|
||
var box = Box.of(mc.player.getPos(), 16, 16, 16); | ||
for (var entity : mc.world.getEntitiesByClass(BlasterBoltEntity.class, box, e -> true)) | ||
{ | ||
var entityDirection = entity.getVelocity(); | ||
|
||
var newEntityPos = entity.getLerpedPos(1); | ||
|
||
var oldPlayerDelta = entity.getLerpedPos(0).subtract(pos); | ||
var newPlayerDelta = newEntityPos.subtract(pos); | ||
|
||
var oldPlayerDot = entityDirection.dotProduct(oldPlayerDelta); | ||
var newPlayerDot = entityDirection.dotProduct(newPlayerDelta); | ||
|
||
if (oldPlayerDot >= 0 && newPlayerDot < 0) | ||
{ | ||
// Entity transitioned from moving towards the | ||
// player (i.e. pos-player vector and direction | ||
// vector face the same direction) to away from | ||
// the player (i.e. vectors point opposite | ||
// directions) | ||
|
||
mc.world.playSound(newEntityPos.x, newEntityPos.y, newEntityPos.z, SoundEvents.ENTITY_GHAST_SCREAM, SoundCategory.PLAYERS, 1, 1, true); | ||
} | ||
} | ||
} | ||
} |
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
50 changes: 0 additions & 50 deletions
50
...c/main/java/com/parzivail/pswg/features/blasters/client/BlasterBoltHissSoundInstance.java
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
projects/pswg/src/main/java/com/parzivail/util/math/Vec3fUtil.java
This file was deleted.
Oops, something went wrong.