-
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.
most of the minecart levitation sounds
- Loading branch information
Showing
14 changed files
with
167 additions
and
5 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/net/id/paradiselost/client/sound/LevitaMovingMinecartSoundInstance.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,56 @@ | ||
package net.id.paradiselost.client.sound; | ||
|
||
import net.id.paradiselost.component.ParadiseLostComponents; | ||
import net.id.paradiselost.util.ParadiseLostSoundEvents; | ||
import net.minecraft.client.sound.MovingSoundInstance; | ||
import net.minecraft.client.sound.SoundInstance; | ||
import net.minecraft.entity.vehicle.AbstractMinecartEntity; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.util.math.MathHelper; | ||
|
||
public class LevitaMovingMinecartSoundInstance extends MovingSoundInstance { | ||
private final AbstractMinecartEntity minecart; | ||
private float distance = 0.0F; | ||
|
||
public LevitaMovingMinecartSoundInstance(AbstractMinecartEntity minecart) { | ||
super(ParadiseLostSoundEvents.ENTITY_MINECART_ROLLING_LEVITATING, SoundCategory.NEUTRAL, SoundInstance.createRandom()); | ||
this.minecart = minecart; | ||
this.repeat = true; | ||
this.repeatDelay = 0; | ||
this.volume = 0.0F; | ||
this.x = ((float)minecart.getX()); | ||
this.y = ((float)minecart.getY()); | ||
this.z = ((float)minecart.getZ()); | ||
} | ||
|
||
@Override | ||
public boolean canPlay() { | ||
return !this.minecart.isSilent(); | ||
} | ||
|
||
@Override | ||
public boolean shouldAlwaysPlay() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
if (this.minecart.isRemoved()) { | ||
this.setDone(); | ||
} else { | ||
this.x = this.minecart.getX(); | ||
this.y = this.minecart.getY(); | ||
this.z = this.minecart.getZ(); | ||
float f = (float) this.minecart.getVelocity().horizontalLength(); | ||
var floatingComponent = ParadiseLostComponents.FLOATING_KEY.get(minecart); | ||
if (f >= 0.01F && this.minecart.getWorld().getTickManager().shouldTick() && floatingComponent.getFloating()) { | ||
this.distance = MathHelper.clamp(this.distance + 0.0025F, 0.0F, 1.0F); | ||
this.volume = MathHelper.lerp(MathHelper.clamp(f, 0.0F, 0.5F), 0.0F, 0.7F); | ||
} else { | ||
this.distance = 0.0F; | ||
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
29 changes: 29 additions & 0 deletions
29
src/main/java/net/id/paradiselost/mixin/client/network/ClientPlayNetworkHandlerMixin.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,29 @@ | ||
package net.id.paradiselost.mixin.client.network; | ||
|
||
import net.id.paradiselost.client.sound.LevitaMovingMinecartSoundInstance; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.ClientCommonNetworkHandler; | ||
import net.minecraft.client.network.ClientConnectionState; | ||
import net.minecraft.client.network.ClientPlayNetworkHandler; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.vehicle.AbstractMinecartEntity; | ||
import net.minecraft.network.ClientConnection; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ClientPlayNetworkHandler.class) | ||
public abstract class ClientPlayNetworkHandlerMixin extends ClientCommonNetworkHandler { | ||
|
||
public ClientPlayNetworkHandlerMixin(MinecraftClient client, ClientConnection connection, ClientConnectionState connectionState) { | ||
super(client, connection, connectionState); | ||
} | ||
|
||
@Inject(method = "playSpawnSound", at = @At("HEAD")) | ||
private void playSpawnSound(Entity entity, CallbackInfo ci) { | ||
if (entity instanceof AbstractMinecartEntity abstractMinecartEntity) { | ||
this.client.getSoundManager().play(new LevitaMovingMinecartSoundInstance(abstractMinecartEntity)); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/net/id/paradiselost/mixin/client/sound/MovingMinecartSoundInstanceMixin.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,40 @@ | ||
package net.id.paradiselost.mixin.client.sound; | ||
|
||
import net.id.paradiselost.component.ParadiseLostComponents; | ||
import net.minecraft.block.AbstractRailBlock; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.sound.MovingMinecartSoundInstance; | ||
import net.minecraft.client.sound.MovingSoundInstance; | ||
import net.minecraft.entity.vehicle.AbstractMinecartEntity; | ||
import net.minecraft.entity.vehicle.VehicleEntity; | ||
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(MovingMinecartSoundInstance.class) | ||
public abstract class MovingMinecartSoundInstanceMixin extends MovingSoundInstance { | ||
|
||
@Shadow | ||
@Final | ||
private AbstractMinecartEntity minecart; | ||
|
||
protected MovingMinecartSoundInstanceMixin(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()) { | ||
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
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
Binary file added
BIN
+310 KB
src/main/resources/assets/paradise_lost/sounds/entity/minecart/inside_levitating.ogg
Binary file not shown.
Binary file added
BIN
+310 KB
...main/resources/assets/paradise_lost/sounds/entity/minecart/minecart_inside_levitating.ogg
Binary file not shown.
Binary file added
BIN
+216 KB
...ain/resources/assets/paradise_lost/sounds/entity/minecart/minecart_rolling_levitating.ogg
Binary file not shown.
Binary file added
BIN
+216 KB
src/main/resources/assets/paradise_lost/sounds/entity/minecart/rolling_levitating.ogg
Binary file not shown.
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