diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument1_20_5.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument1_20_5.java index a3675baf2..0d62f7789 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument1_20_5.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument1_20_5.java @@ -36,7 +36,7 @@ public record Instrument1_20_5(Holder soundEvent, int useDuration, f public Instrument1_20_5 readDirect(final ByteBuf buffer) { final Holder soundEvent = Types.SOUND_EVENT.read(buffer); final int useDuration = Types.VAR_INT.readPrimitive(buffer); - final float range = buffer.readFloat(); + final float range = Types.FLOAT.readPrimitive(buffer); return new Instrument1_20_5(soundEvent, useDuration, range); } @@ -44,7 +44,7 @@ public record Instrument1_20_5(Holder soundEvent, int useDuration, f public void writeDirect(final ByteBuf buffer, final Instrument1_20_5 value) { Types.SOUND_EVENT.write(buffer, value.soundEvent()); Types.VAR_INT.writePrimitive(buffer, value.useDuration()); - buffer.writeFloat(value.range()); + Types.FLOAT.writePrimitive(buffer, value.range()); } }; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument1_21_2.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument1_21_2.java index 4cca205f5..e6abac244 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument1_21_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/Instrument1_21_2.java @@ -37,7 +37,7 @@ public record Instrument1_21_2(Holder soundEvent, float useDuration, public Instrument1_21_2 readDirect(final ByteBuf buffer) { final Holder soundEvent = Types.SOUND_EVENT.read(buffer); final float useDuration = Types.FLOAT.readPrimitive(buffer); - final float range = buffer.readFloat(); + final float range = Types.FLOAT.readPrimitive(buffer); final Tag description = Types.TAG.read(buffer); return new Instrument1_21_2(soundEvent, useDuration, range, description); } @@ -46,7 +46,7 @@ public record Instrument1_21_2(Holder soundEvent, float useDuration, public void writeDirect(final ByteBuf buffer, final Instrument1_21_2 value) { Types.SOUND_EVENT.write(buffer, value.soundEvent()); Types.FLOAT.writePrimitive(buffer, value.useDuration()); - buffer.writeFloat(value.range()); + Types.FLOAT.writePrimitive(buffer, value.range()); Types.TAG.write(buffer, value.description()); } }; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java index 0a004ffd5..90acc67c7 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java @@ -272,7 +272,7 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter< return Holder.of(instrument.id()); } final Instrument1_20_5 value = instrument.value(); - return Holder.of(new Instrument1_21_2(value.soundEvent(), value.useDuration(), value.range(), new StringTag(""))); + return Holder.of(new Instrument1_21_2(value.soundEvent(), value.useDuration() / 20F, value.range(), new StringTag(""))); }); dataContainer.replace(StructuredDataKey.FOOD1_21, StructuredDataKey.FOOD1_21_2, food -> { // Just assume the item type default for CONSUMABLE; add USE_REMAINDER from old food properties @@ -295,7 +295,7 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter< return Holder.of(instrument.id()); } final Instrument1_21_2 value = instrument.value(); - return Holder.of(new Instrument1_20_5(value.soundEvent(), (int) value.useDuration(), value.range())); + return Holder.of(new Instrument1_20_5(value.soundEvent(), (int) (value.useDuration() * 20), value.range())); }); dataContainer.replace(StructuredDataKey.FOOD1_21_2, StructuredDataKey.FOOD1_21, food -> { final StructuredData consumableData = dataContainer.getNonEmpty(StructuredDataKey.CONSUMABLE1_21_2); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/EntityPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/EntityPacketRewriter1_21_2.java index 0a9db63c2..b69129990 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/EntityPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/EntityPacketRewriter1_21_2.java @@ -42,6 +42,16 @@ import java.util.Arrays; public final class EntityPacketRewriter1_21_2 extends EntityRewriter { + private static final String[] GOAT_HORN_INSTRUMENTS = { + "ponder_goat_horn", + "sing_goat_horn", + "seek_goat_horn", + "feel_goat_horn", + "admire_goat_horn", + "call_goat_horn", + "yearn_goat_horn", + "dream_goat_horn" + }; private static final float IMPULSE = 0.98F; public EntityPacketRewriter1_21_2(final Protocol1_21To1_21_2 protocol) { @@ -54,6 +64,22 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter { + final PacketWrapper instrumentsPacket = wrapper.create(ClientboundConfigurationPackets1_21.REGISTRY_DATA); + instrumentsPacket.write(Types.STRING, "minecraft:instrument"); + final RegistryEntry[] entries = new RegistryEntry[GOAT_HORN_INSTRUMENTS.length]; + for (int i = 0; i < GOAT_HORN_INSTRUMENTS.length; i++) { + final CompoundTag tag = new CompoundTag(); + tag.putString("sound_event", "item.goat_horn.sound." + i); + tag.putFloat("use_duration", 7); + tag.putInt("range", 256); + tag.putString("description", ""); + entries[i] = new RegistryEntry(GOAT_HORN_INSTRUMENTS[i], tag); + } + instrumentsPacket.write(Types.REGISTRY_ENTRY_ARRAY, entries); + instrumentsPacket.send(Protocol1_21To1_21_2.class); + }); + protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, wrapper -> { final String registryKey = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING)); RegistryEntry[] entries = wrapper.read(Types.REGISTRY_ENTRY_ARRAY);