Skip to content

Commit

Permalink
Don't hardcode record IDs and fix records for 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Jun 16, 2021
1 parent aba279f commit 2c9cd7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,15 @@ public static void init() {
javaEffect = SoundEffect.valueOf(entry.getKey());
String name = node.get("name").asText();
float volume = node.has("volume") ? node.get("volume").floatValue() : 1.0f;
boolean pitchSub = node.has("pitch_sub") ? node.get("pitch_sub").booleanValue() : false;
boolean pitchSub = node.has("pitch_sub") && node.get("pitch_sub").booleanValue();
float pitchMul = node.has("pitch_mul") ? node.get("pitch_mul").floatValue() : 1.0f;
float pitchAdd = node.has("pitch_add") ? node.get("pitch_add").floatValue() : 0.0f;
boolean relative = node.has("relative") ? node.get("relative").booleanValue() : true;
boolean relative = node.has("relative") && node.get("relative").booleanValue();
effect = new PlaySoundEffect(name, volume, pitchSub, pitchMul, pitchAdd, relative);
break;
}
case "record": {
JsonNode records = entry.getValue().get("records");
Iterator<Map.Entry<String, JsonNode>> recordsIterator = records.fields();
while (recordsIterator.hasNext()) {
Map.Entry<String, JsonNode> recordEntry = recordsIterator.next();
RECORDS.put(Integer.parseInt(recordEntry.getKey()), SoundEvent.valueOf(recordEntry.getValue().asText()));
}
// Special case handled in ItemRegistry
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.nukkitx.nbt.NbtMapBuilder;
import com.nukkitx.nbt.NbtType;
import com.nukkitx.nbt.NbtUtils;
import com.nukkitx.protocol.bedrock.data.SoundEvent;
import com.nukkitx.protocol.bedrock.data.inventory.ComponentItemData;
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
Expand All @@ -44,10 +45,10 @@
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.translators.effect.EffectRegistry;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.world.block.BlockTranslator1_17_0;
import org.geysermc.connector.utils.FileUtils;
import org.geysermc.connector.utils.LanguageUtils;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -466,6 +467,10 @@ public static void init() {
.damage(itemEntry.getBedrockData())
.count(1)
.blockRuntimeId(itemEntry.getBedrockBlockId()).build());
} else if (entry.getKey().startsWith("minecraft:music_disc_")) {
// The Java record level event uses the item ID as the "key" to play the record
EffectRegistry.RECORDS.put(itemIndex, SoundEvent.valueOf("RECORD_" +
entry.getKey().replace("minecraft:music_disc_", "").toUpperCase(Locale.ENGLISH)));
}

itemNames.add(entry.getKey());
Expand Down
2 changes: 1 addition & 1 deletion connector/src/main/resources/mappings
Submodule mappings updated 1 files
+1 −17 effects.json

0 comments on commit 2c9cd7e

Please sign in to comment.