Made so sounds in sounds3 folder are still registered at all times but with a sounds3. prefix

master
Wynd 2024-08-07 22:41:08 +03:00
parent 7976cfabff
commit 32b1194eec
3 changed files with 5 additions and 19 deletions

View File

@ -57,7 +57,7 @@ public class LivingEntityMixin {
LivingEntity entity = (LivingEntity) (Object) this;
if (ModConfig.ADD_MORE_SOUNDS.get() && entity.isOnLadder() && entity.velocityY != 0 && entity.field_1645 % 20 == 0 && !entity.onGround) {
float pitch = WyHelper.clamp(0.85f + entity.level.rand.nextFloat() / 2, 0.0f, 1.0f);
entity.level.playSound(entity.x, entity.y, entity.z, "step.ladder", 0.3f, pitch);
entity.level.playSound(entity.x, entity.y, entity.z, "sound3.step.ladder", 0.3f, pitch);
}
}
}

View File

@ -58,7 +58,7 @@ public class MinecartMixin {
if (speed >= 0.01D && ModConfig.ADD_MORE_SOUNDS.get()) {
if (minecart.field_1645 % 39 == 1) {
minecart.level.playSound(x, y, z, "minecart.base", volume, pitch);
minecart.level.playSound(x, y, z, "sound3.minecart.base", volume, pitch);
}
}
}

View File

@ -17,9 +17,6 @@ import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(Minecraft.class)
public class MinecraftMixin {
private static final String[] ALLOWED_NEW_SOUNDS = {"minecart/", "step/ladder"};
@Redirect(method = "init()V", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;create()V"), remap = false)
public void createDisplay() throws LWJGLException {
// Why the fuck is this even a thing ? What was its intended purpose ? I NEED TO KNOW
@ -29,26 +26,15 @@ public class MinecraftMixin {
@Inject(method = "loadSoundFromDir", at = @At("HEAD"))
public void loadSoundFromDir(String string, File file, CallbackInfo ci) {
if(!ModConfig.ADD_MORE_SOUNDS.get()) {
if(ModConfig.ADD_MORE_SOUNDS.get()) {
Minecraft mc = (Minecraft) (Object) this;
int split = string.indexOf("/");
String type = string.substring(0, split);
String newSound = string.substring(split + 1);
// For now only allow the minecart sounds, allowing all of them causes weird effects with same name sounds when the game decides which one to use
// XXX Could always incorporate the sound3 part into the sound's name and have it accessible as sound3.random.bow for example, which would avoid the overlap with current sounds
if (type.equalsIgnoreCase("sound3")) {
boolean registerSound = false;
for (String test : ALLOWED_NEW_SOUNDS) {
if (newSound.startsWith(test)) {
registerSound = true;
break;
}
}
if (registerSound) {
MainMod.LOGGER.info("Registered a new sound " + newSound + " from " + file);
mc.soundHelper.method_2011(newSound, file);
}
MainMod.LOGGER.info("Registered a new sound sound3/" + newSound + " from " + file);
mc.soundHelper.method_2011("sound3/" + newSound, file);
}
}
}