Skip to content

Commit

Permalink
Preparing to start on Sound Helper script
Browse files Browse the repository at this point in the history
  • Loading branch information
floral-qua-floral committed Dec 20, 2024
1 parent 9cf1571 commit d0890b5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.fqf.mario_qua_mario.mariodata;

import com.fqf.mario_qua_mario.registries.actions.AbstractParsedAction;
import com.fqf.mario_qua_mario.registries.power_granting.ParsedPowerUp;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.sound.SoundInstance;
import net.minecraft.entity.Entity;
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.Vec3d;
import net.minecraft.util.math.random.Random;
Expand Down Expand Up @@ -64,6 +67,17 @@ default void fadeJumpSound() {

Map<IMarioClientDataImpl, SoundInstance> MARIO_VOICE_LINES = new HashMap<>();

default void handlePowerTransitionSound(boolean isReversion, ParsedPowerUp newPower, long seed) {
if(isReversion) this.playSound(SoundEvents.ENTITY_SPLASH_POTION_BREAK, seed);
else {
this.playSound(newPower.ACQUISITION_SOUND, seed);
}
}

default void handleSlidingSound(AbstractParsedAction newAction) {

}

@Override
default SoundInstanceWrapperImpl voice(VoiceLine line, long seed) {
MinecraftClient.getInstance().getSoundManager().stop(MARIO_VOICE_LINES.get(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fqf.mario_qua_mario.definitions.states.PowerUpDefinition;
import com.fqf.mario_qua_mario.registries.ParsedMarioThing;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;

public class ParsedPowerUp extends ParsedPowerGrantingState {
Expand All @@ -20,7 +21,8 @@ public ParsedPowerUp(PowerUpDefinition definition) {
this.REVERSION_TARGET_ID = definition.getReversionTarget();
this.VALUE = definition.getValue();

this.ACQUISITION_SOUND = definition.getAcquisitionSound();
SoundEvent definedAcquisitionSound = definition.getAcquisitionSound();
this.ACQUISITION_SOUND = definedAcquisitionSound == null ? SoundEvents.BLOCK_SHROOMLIGHT_PLACE : definedAcquisitionSound;
this.VOICE_PITCH = definition.getVoicePitch();

this.HEART = definition.getPowerHeart(new PowerHeartHelperImpl(this.ID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.server.network.ServerPlayerEntity;

public class MarioEventListeners {
public static void register() {
Expand All @@ -20,7 +21,15 @@ public static void register() {
});

ServerLivingEntityEvents.ALLOW_DAMAGE.register((livingEntity, damageSource, amount) -> {
return true;
if(!(livingEntity instanceof ServerPlayerEntity mario)) return true;

MarioServerPlayerData data = mario.mqm$getMarioData();
if(!data.isEnabled()) return true;

if(data.getPowerUp().REVERSION_TARGET_ID == null) return true;

data.revertTo(data.getPowerUp().REVERSION_TARGET_ID);
return false;
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.fqf.mario_qua_mario.util;

public class MarioModSFX {

}

0 comments on commit d0890b5

Please sign in to comment.