-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
134 additions
and
101 deletions.
There are no files selected for viewing
48 changes: 0 additions & 48 deletions
48
...n/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
...main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.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,64 @@ | ||
package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; | ||
|
||
import dan200.computercraft.client.sound.SpeakerSound; | ||
import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; | ||
import net.minecraft.client.resources.sounds.AbstractSoundInstance; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.joml.Vector3d; | ||
import org.joml.Vector3dc; | ||
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.CallbackInfo; | ||
import org.valkyrienskies.core.api.ships.Ship; | ||
import org.valkyrienskies.mod.client.audio.VelocityTickableSoundInstance; | ||
import org.valkyrienskies.mod.common.VSGameUtilsKt; | ||
|
||
@Mixin(SpeakerSound.class) | ||
public abstract class MixinSpeakerSound extends AbstractSoundInstance implements VelocityTickableSoundInstance { | ||
@Unique private SpeakerPosition speakerPosition; | ||
@Unique private Ship ship; | ||
|
||
protected MixinSpeakerSound(ResourceLocation arg, SoundSource arg2) { | ||
super(arg, arg2); | ||
} | ||
|
||
@Inject( | ||
method = "setPosition", | ||
at = @At("RETURN"), | ||
remap = false | ||
) | ||
private void isOnShip(SpeakerPosition position, CallbackInfo ci) { | ||
this.speakerPosition = position; | ||
this.ship = VSGameUtilsKt.getShipManagingPos(position.level(), position.position()); | ||
if (this.ship != null) { | ||
Vec3 worldPos = VSGameUtilsKt.toWorldCoordinates(speakerPosition.level(), speakerPosition.position()); | ||
x = worldPos.x; | ||
y = worldPos.y; | ||
z = worldPos.z; | ||
} | ||
} | ||
|
||
@Inject( | ||
method = "tick", | ||
at = @At("HEAD") | ||
) | ||
private void updateWorldPos(CallbackInfo ci) { | ||
if (this.ship != null) { | ||
Vec3 worldPos = VSGameUtilsKt.toWorldCoordinates(speakerPosition.level(), speakerPosition.position()); | ||
x = worldPos.x; | ||
y = worldPos.y; | ||
z = worldPos.z; | ||
} | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Vector3dc getVelocity() { | ||
return ship != null ? ship.getVelocity() : new Vector3d(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...rc/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/README.MD
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
47 changes: 0 additions & 47 deletions
47
.../main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
...src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerSound.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,64 @@ | ||
package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; | ||
|
||
import dan200.computercraft.client.sound.SpeakerSound; | ||
import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; | ||
import net.minecraft.client.resources.sounds.AbstractSoundInstance; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.joml.Vector3d; | ||
import org.joml.Vector3dc; | ||
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.CallbackInfo; | ||
import org.valkyrienskies.core.api.ships.Ship; | ||
import org.valkyrienskies.mod.client.audio.VelocityTickableSoundInstance; | ||
import org.valkyrienskies.mod.common.VSGameUtilsKt; | ||
|
||
@Mixin(SpeakerSound.class) | ||
public abstract class MixinSpeakerSound extends AbstractSoundInstance implements VelocityTickableSoundInstance { | ||
@Unique private SpeakerPosition speakerPosition; | ||
@Unique private Ship ship; | ||
|
||
protected MixinSpeakerSound(ResourceLocation arg, SoundSource arg2) { | ||
super(arg, arg2); | ||
} | ||
|
||
@Inject( | ||
method = "setPosition", | ||
at = @At("RETURN"), | ||
remap = false | ||
) | ||
private void isOnShip(SpeakerPosition position, CallbackInfo ci) { | ||
this.speakerPosition = position; | ||
this.ship = VSGameUtilsKt.getShipManagingPos(position.level(), position.position()); | ||
if (this.ship != null) { | ||
Vec3 worldPos = VSGameUtilsKt.toWorldCoordinates(speakerPosition.level(), speakerPosition.position()); | ||
x = worldPos.x; | ||
y = worldPos.y; | ||
z = worldPos.z; | ||
} | ||
} | ||
|
||
@Inject( | ||
method = "tick", | ||
at = @At("HEAD") | ||
) | ||
private void updateWorldPos(CallbackInfo ci) { | ||
if (this.ship != null) { | ||
Vec3 worldPos = VSGameUtilsKt.toWorldCoordinates(speakerPosition.level(), speakerPosition.position()); | ||
x = worldPos.x; | ||
y = worldPos.y; | ||
z = worldPos.z; | ||
} | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Vector3dc getVelocity() { | ||
return ship != null ? ship.getVelocity() : new Vector3d(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/README.MD
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