#Generic.scale custom walking sound

9 messages · Page 1 of 1 (latest)

little pawn
#

Thru the name can some make me a custom mod for fabric for 1.20.5 or 1.20.6 that lets you if u grow with the attribute generic.scale command to size 5 till 16 it will use a custom sound if you walk like a giant footsteps sounds then Minecraft walking sounds but the custom sounds is on the resource pack so the mod and resource pack works together

#

I used this code but it doesn't work it was generated from chatgpt

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;

public class GiantWalkingSoundMod implements ModInitializer {
@Override
public void onInitialize() {
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
server.getPlayerManager().getPlayerList().forEach(player -> {
player.getAttributeInstance(EntityAttributes.GENERIC_SCALE).setOnAttributeModifiedCallback((attribute, value) -> {
double size = player.getAttributeInstance(EntityAttributes.GENERIC_SCALE).getValue();
// Check if the player's size is within the specified range
if (size >= 5.0 && size <= 16.0) {
// Check if the player is moving
if (player.horizontalSpeed > 0) {
// Play custom sound
playCustomSound(player, CustomSoundEvents.GIANT_WALKING);
}
}
return value;
});
});
});
}

private void playCustomSound(ServerPlayerEntity player, SoundEvent soundEvent) {
    player.playSound(soundEvent, 1.0f, 1.0f);
}

// Define custom sound event
public static class CustomSoundEvents {
    // Ensure these identifiers match the sounds in your resource pack
    public static final SoundEvent GIANT_WALKING = register("yourmodid:giant_walking");

    private static SoundEvent register(String name) {
        return new SoundEvent(new Identifier(name));
    }
}

}

ocean pike
#

In general LLM = bad for writing code

#

Also, what is the resource pack for

little pawn
#

For my server

toxic fiber
#

surprisingly the only issue i think i see with gpt's code is that it uses the wrong event

#

it should probably use ServerTickEvents.END_WORLD_TICK or ServerTickEvents.START_WORLD_TICK