-
Notifications
You must be signed in to change notification settings - Fork 43
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
5 changed files
with
43 additions
and
5 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
37 changes: 37 additions & 0 deletions
37
src/main/java/net/id/paradiselost/mixin/client/sound/MinecartInsideSoundInstanceMixin.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,37 @@ | ||
package net.id.paradiselost.mixin.client.sound; | ||
|
||
import net.id.paradiselost.component.ParadiseLostComponents; | ||
import net.minecraft.client.sound.MinecartInsideSoundInstance; | ||
import net.minecraft.client.sound.MovingSoundInstance; | ||
import net.minecraft.entity.vehicle.AbstractMinecartEntity; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvent; | ||
import net.minecraft.util.math.random.Random; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(MinecartInsideSoundInstance.class) | ||
public abstract class MinecartInsideSoundInstanceMixin extends MovingSoundInstance { | ||
|
||
@Shadow | ||
@Final | ||
private AbstractMinecartEntity minecart; | ||
|
||
protected MinecartInsideSoundInstanceMixin(SoundEvent soundEvent, SoundCategory soundCategory, Random random) { | ||
super(soundEvent, soundCategory, random); | ||
} | ||
|
||
@Inject(method = "tick", at = @At("TAIL")) | ||
public void tick(CallbackInfo ci) { | ||
if (!this.minecart.isRemoved()) { | ||
var floatingComponent = ParadiseLostComponents.FLOATING_KEY.get(this.minecart); | ||
if (floatingComponent.getFloating() && !floatingComponent.isCartOnRail(this.minecart)) { | ||
this.volume = 0.0F; | ||
} | ||
} | ||
} | ||
} |
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