@@ -230,14 +230,14 @@ public static void populate() {
230230 // Some item on Bedrock Edition have a different stack size, so we're changing that through the component.
231231 // This resolve https://github.com/GeyserMC/Geyser/issues/5612 and https://github.com/GeyserMC/Geyser/issues/4905
232232 if (definition .getIdentifier ().equals ("minecraft:cake" )) {
233- definition = new SimpleItemDefinition (entry .getName ().intern (), id , ItemVersion .from (entry .getVersion ()), true , fromItemDefinitionToDataDriven (definition , 1 , null , null ));
233+ definition = new SimpleItemDefinition (entry .getName ().intern (), id , ItemVersion .from (entry .getVersion ()), true , fromItemDefinitionToDataDriven (definition , 1 , null , null , false ));
234234 } else if (definition .getIdentifier ().equals ("minecraft:armor_stand" )) {
235235 // You have to change the item version to data driven for armor stand else this won't work.
236- definition = new SimpleItemDefinition (entry .getName ().intern (), id , ItemVersion .DATA_DRIVEN , true , fromItemDefinitionToDataDriven (definition , 16 , "armor_stand" , "item.armor_stand.name" ));
236+ definition = new SimpleItemDefinition (entry .getName ().intern (), id , ItemVersion .DATA_DRIVEN , true , fromItemDefinitionToDataDriven (definition , 16 , "armor_stand" , "item.armor_stand.name" , false ));
237237 } else if (definition .getIdentifier ().equals ("minecraft:firework_rocket" )) {
238238 // For fireworks rocket, we purposely make this item data driven so now bedrock won't do client-sided boosting
239239 // and now we can control fireworks boost ourselves! This resolve https://github.com/GeyserMC/Geyser/issues/5409
240- definition = new SimpleItemDefinition (entry .getName ().intern (), id , ItemVersion .DATA_DRIVEN , true , fromItemDefinitionToDataDriven (definition , 64 , "fireworks" , "item.fireworks.name" ));
240+ definition = new SimpleItemDefinition (entry .getName ().intern (), id , ItemVersion .DATA_DRIVEN , true , fromItemDefinitionToDataDriven (definition , 64 , "fireworks" , "item.fireworks.name" , true ));
241241 }
242242
243243 definitions .put (entry .getName (), definition );
@@ -828,7 +828,7 @@ private static NbtMap registerFurnaceMinecart(int nextFreeBedrockId) {
828828 return builder .build ();
829829 }
830830
831- private static NbtMap fromItemDefinitionToDataDriven (ItemDefinition definition , int maxStackSize , String texture , String displayName ) {
831+ private static NbtMap fromItemDefinitionToDataDriven (ItemDefinition definition , int maxStackSize , String texture , String displayName , boolean swing ) {
832832 NbtMapBuilder builder = NbtMap .builder ();
833833 builder .putString ("name" , definition .getIdentifier ()).putInt ("id" , definition .getRuntimeId ());
834834
@@ -853,6 +853,12 @@ private static NbtMap fromItemDefinitionToDataDriven(ItemDefinition definition,
853853 itemProperties .putInt ("max_stack_size" , maxStackSize );
854854
855855 componentBuilder .putCompound ("item_properties" , itemProperties .build ());
856+
857+ if (swing ) {
858+ componentBuilder .putCompound ("minecraft:throwable" , NbtMap .builder ().putBoolean ("do_swing_animation" , true ).build ());
859+ componentBuilder .putCompound ("minecraft:projectile" , NbtMap .builder ().putString ("projectile_entity" , "minecraft:snowball" ).build ());
860+ }
861+
856862 builder .putCompound ("components" , componentBuilder .build ());
857863 return builder .build ();
858864 }
0 commit comments