-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MarioTravelData and common-side travelHook implemented.
- Loading branch information
1 parent
fc127c1
commit 1931797
Showing
49 changed files
with
941 additions
and
685 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
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
127 changes: 127 additions & 0 deletions
127
src/main/java/com/floralquafloral/mariodata/MarioClientSideData.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,127 @@ | ||
package com.floralquafloral.mariodata; | ||
|
||
import com.floralquafloral.MarioQuaMario; | ||
import com.floralquafloral.registries.RegistryManager; | ||
import com.floralquafloral.registries.states.character.ParsedCharacter; | ||
import com.floralquafloral.util.JumpSoundPlayer; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.sound.PositionedSoundInstance; | ||
import net.minecraft.client.sound.SoundManager; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.registry.Registries; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvent; | ||
import net.minecraft.sound.SoundEvents; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.random.Random; | ||
|
||
import java.util.HashMap; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
@SuppressWarnings("UnusedReturnValue") | ||
public interface MarioClientSideData extends MarioData { | ||
SoundManager SOUND_MANAGER = MinecraftClient.getInstance().getSoundManager(); | ||
|
||
default PositionedSoundInstance playSoundEvent( | ||
SoundEvent event, SoundCategory category, | ||
double x, double y, double z, | ||
float pitch, float volume, long seed | ||
) { | ||
PositionedSoundInstance sound = new PositionedSoundInstance( | ||
event, category, | ||
volume, pitch, | ||
Random.create(seed), | ||
x, y, z | ||
); | ||
SOUND_MANAGER.play(sound); | ||
return sound; | ||
} | ||
|
||
default PositionedSoundInstance playSoundEvent(SoundEvent event, long seed) { | ||
PlayerEntity mario = this.getMario(); | ||
return playSoundEvent( | ||
event, SoundCategory.PLAYERS, | ||
mario.getX(), mario.getY(), mario.getZ(), | ||
1.0F, 1.0F, seed | ||
); | ||
} | ||
|
||
default PositionedSoundInstance playSoundEvent(SoundEvent event, float pitch, float volume, long seed) { | ||
PlayerEntity mario = this.getMario(); | ||
return playSoundEvent( | ||
event, SoundCategory.PLAYERS, | ||
mario.getX(), mario.getY(), mario.getZ(), | ||
pitch, volume, seed | ||
); | ||
} | ||
|
||
default PositionedSoundInstance playSoundEvent(SoundEvent event, Entity entity, SoundCategory category, long seed) { | ||
return playSoundEvent( | ||
event, category, | ||
entity.getX(), entity.getY(), entity.getZ(), | ||
1.0F, 1.0F, seed | ||
); | ||
} | ||
|
||
default PositionedSoundInstance voice(VoiceLine line, long seed) { | ||
PlayerEntity mario = this.getMario(); | ||
|
||
SOUND_MANAGER.stop(VoiceLine.MARIO_VOICE_LINES.get(this)); | ||
|
||
PositionedSoundInstance newSoundInstance = this.playSoundEvent( | ||
line.SOUND_EVENTS.get(this.getCharacter()), SoundCategory.VOICE, | ||
mario.getX(), mario.getY(), mario.getZ(), | ||
1.0F, this.getPowerUp().VOICE_PITCH, | ||
seed | ||
); | ||
VoiceLine.MARIO_VOICE_LINES.put(this, newSoundInstance); | ||
|
||
return newSoundInstance; | ||
} | ||
|
||
default void playJumpSound(long seed) { | ||
JumpSoundPlayer.playJumpSfx(this, seed); | ||
} | ||
|
||
enum VoiceLine { | ||
SELECT, | ||
DUCK, | ||
|
||
DOUBLE_JUMP, | ||
TRIPLE_JUMP, | ||
GYMNAST_SALUTE, | ||
|
||
DUCK_JUMP, | ||
LONG_JUMP, | ||
BACKFLIP, | ||
SIDEFLIP, | ||
WALL_JUMP, | ||
|
||
REVERT, | ||
BURNT, | ||
|
||
FIREBALL, | ||
GET_STAR; | ||
|
||
private static final Map<MarioClientSideData, PositionedSoundInstance> MARIO_VOICE_LINES = new HashMap<>(); | ||
public static void staticInitialize() { | ||
|
||
} | ||
|
||
private final Map<ParsedCharacter, SoundEvent> SOUND_EVENTS; | ||
VoiceLine() { | ||
SOUND_EVENTS = new HashMap<>(); | ||
|
||
for(ParsedCharacter character : RegistryManager.CHARACTERS) { | ||
Identifier id = Identifier.of(character.ID.getNamespace(), "voice." + character.ID.getPath() + "." + this.name().toLowerCase(Locale.ROOT)); | ||
MarioQuaMario.LOGGER.info("Automatically registering VoiceLine sound event {}...", id); | ||
SoundEvent event = SoundEvent.of(id); | ||
Registry.register(Registries.SOUND_EVENT, id, event); | ||
SOUND_EVENTS.put(character, event); | ||
} | ||
} | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/floralquafloral/mariodata/MarioOtherClientData.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,16 @@ | ||
package com.floralquafloral.mariodata; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
|
||
public class MarioOtherClientData extends MarioPlayerData implements MarioClientSideData { | ||
public MarioOtherClientData(PlayerEntity mario) { | ||
super(mario); | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
this.getAction().clientTick(this, false); | ||
this.getPowerUp().clientTick(this, false); | ||
this.getCharacter().clientTick(this, false); | ||
} | ||
} |
Oops, something went wrong.