From 28ce2a53e08dcd2b20f8bcde7f018e847291e0de Mon Sep 17 00:00:00 2001 From: ScarPC Date: Sun, 13 Sep 2026 10:33:20 +0300 Subject: [PATCH] Replace weapon pose jitter with native swings and timed slash trails --- README.md | 4 +- build.gradle.kts | 2 +- docs/animation-0.1.1.md | 18 +++++ .../verification/client/WeaponsCapture.java | 27 ++++---- .../weapons/behavior/GauntletCombat.java | 2 +- .../weapons/mixin/GauntletInventoryMixin.java | 5 ++ .../weapons/mixin/TwinbladeSwingMixin.java | 7 +- .../weapons/resource/SlashDisplay.java | 16 +++-- .../weapons/resource/WeaponPresentation.java | 63 +++++++++++------ .../assets/astraweapons/items/v2/guard.json | 24 +++++++ .../assets/astraweapons/items/v2/hook.json | 24 +++++++ .../assets/astraweapons/items/v2/jab.json | 24 +++++++ .../assets/astraweapons/items/v2/lunge.json | 24 +++++++ .../assets/astraweapons/items/v2/slash_0.json | 6 ++ .../assets/astraweapons/items/v2/slash_1.json | 6 ++ .../assets/astraweapons/items/v2/slash_2.json | 6 ++ .../assets/astraweapons/items/v2/slash_3.json | 6 ++ .../astraweapons/items/v2/slash_fire_0.json | 6 ++ .../astraweapons/items/v2/slash_fire_1.json | 6 ++ .../astraweapons/items/v2/slash_fire_2.json | 6 ++ .../astraweapons/items/v2/slash_fire_3.json | 6 ++ .../astraweapons/items/v2/twinblade.json | 24 +++++++ .../astraweapons/items/v2/uppercut.json | 24 +++++++ .../assets/astraweapons/models/v2/guard.json | 39 +++++++++++ .../assets/astraweapons/models/v2/hook.json | 39 +++++++++++ .../assets/astraweapons/models/v2/jab.json | 39 +++++++++++ .../assets/astraweapons/models/v2/lunge.json | 39 +++++++++++ .../astraweapons/models/v2/slash_0.json | 43 ++++++++++++ .../astraweapons/models/v2/slash_1.json | 43 ++++++++++++ .../astraweapons/models/v2/slash_2.json | 43 ++++++++++++ .../astraweapons/models/v2/slash_3.json | 43 ++++++++++++ .../astraweapons/models/v2/slash_fire_0.json | 43 ++++++++++++ .../astraweapons/models/v2/slash_fire_1.json | 43 ++++++++++++ .../astraweapons/models/v2/slash_fire_2.json | 43 ++++++++++++ .../astraweapons/models/v2/slash_fire_3.json | 43 ++++++++++++ .../astraweapons/models/v2/twinblade.json | 39 +++++++++++ .../astraweapons/models/v2/uppercut.json | 39 +++++++++++ .../astraweapons/textures/item/v2/slash_0.png | Bin 0 -> 524 bytes .../astraweapons/textures/item/v2/slash_1.png | Bin 0 -> 718 bytes .../astraweapons/textures/item/v2/slash_2.png | Bin 0 -> 567 bytes .../astraweapons/textures/item/v2/slash_3.png | Bin 0 -> 678 bytes .../textures/item/v2/slash_fire_0.png | Bin 0 -> 527 bytes .../textures/item/v2/slash_fire_1.png | Bin 0 -> 720 bytes .../textures/item/v2/slash_fire_2.png | Bin 0 -> 575 bytes .../textures/item/v2/slash_fire_3.png | Bin 0 -> 685 bytes src/main/resources/weapons-index.txt | 36 ++++++++++ .../weapons/WeaponsResourcesTest.java | 7 ++ .../weapons/verification/CaptureFixture.java | 12 +--- .../verification/GauntletVerification.java | 6 ++ tools/build_visuals.py | 2 +- tools/build_visuals_v2.py | 64 ++++++++++++++++++ tools/capture-client.ps1 | 2 +- tools/encode-review.ps1 | 14 ++++ tools/install-mods.ps1 | 6 +- tools/verify-server.ps1 | 2 +- 55 files changed, 1003 insertions(+), 62 deletions(-) create mode 100644 docs/animation-0.1.1.md create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/guard.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/hook.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/jab.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/lunge.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_0.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_1.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_2.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_3.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_0.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_1.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_2.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_3.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/twinblade.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/items/v2/uppercut.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/guard.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/hook.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/jab.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/lunge.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_0.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_1.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_2.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_3.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_0.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_1.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_2.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_3.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/twinblade.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/models/v2/uppercut.json create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_0.png create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_1.png create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_2.png create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_3.png create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_0.png create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_1.png create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_2.png create mode 100644 src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_3.png create mode 100644 tools/build_visuals_v2.py create mode 100644 tools/encode-review.ps1 diff --git a/README.md b/README.md index d8752fb..25c7aa5 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ «Размах» расширяет радиус до 4/5 блоков. Отмена атаки, стены, союзники, PvP, броня, щиты, криты и обычные чары учитываются. Смена оружия/слота, выход, смерть и смена измерения отменяют незавершённый замах. Вместо частиц используется временная vanilla item-display с анимированной текстурой дуги, в том числе огненный вариант при «Заговоре огня». -Положение оружия в руке проходит через шесть модельных кадров; геометрия попадания остаётся серверной. +С версии 0.1.1 положение оружия не скачет между шестью моделями: используется штатный плавный взмах Minecraft со стабильным хватом. След удара — короткая сужающаяся дуга из четырёх кадров, синхронизированных с конкретным ударом. Боевые перчатки: базовый урон 3, скорость 4 атаки/с, откат 5 тиков (0,25 с), небольшая область ±28° до 2,2 блока. Серия: левый → правый → левый → правый → левый хук → правый апперкот → правый выпад. @@ -34,7 +34,7 @@ Недостающие ресурсы и определения устанавливаются в общие каталоги AstraPlus до загрузки чар/сборки пака. Существующие пользовательские файлы сохраняются. После установки JAR нужен перезапуск сервера и принятие обновлённого ресурспака. При отключённой автоматической сборке выполните `/astraplus build`. -Модели рук анимируются средствами ресурспака и сетевых пакетов; базовые движения рук самого ванильного персонажа сохраняются. +Ванильный клиент использует `swing_animation`: STAB для прямых ударов/апперкота/выпада, WHACK для хука и твинблейда. Перчатки закреплены на кистях в третьем лице; смещение моделей отдельно от рук удалено. Произвольная скелетная анимация не используется. Изменения поз умеренные; точного воспроизведения анимаций Dungeons на ванильном скелете нет. Авторы заимствованных моделей и звуков указаны в [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md), в JAR, ресурспаке и описании перчаток. Сборка: сначала `AstraPlus/gradlew build`, затем `gradlew build verificationJar` в AstraWeapons. diff --git a/build.gradle.kts b/build.gradle.kts index aa8e8df..5cb6787 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { id("net.neoforged.moddev") version "2.0.146" } group = "online.astradev" -version = "0.1.0" +version = "0.1.1" repositories { mavenCentral() } dependencies { compileOnly(files(providers.gradleProperty("astraPlusJar").orElse("../AstraPlus/build/libs/AstraPlus-0.5.67.jar"))) diff --git a/docs/animation-0.1.1.md b/docs/animation-0.1.1.md new file mode 100644 index 0000000..614b88f --- /dev/null +++ b/docs/animation-0.1.1.md @@ -0,0 +1,18 @@ +# Исправление анимаций 0.1.1 + +Исходная проблема подтверждена двумя пользовательскими записями: позы предметов менялись скачками поверх обычного взмаха, перчатки смещались отдельно от кистей, след твинблейда выглядел как широкий обруч. + +Ванильный клиент сохранён. Покадровая подмена модели во время взмаха удалена. Используются штатные `swing_animation` Minecraft 26.2: прямые удары — STAB, хук и твинблейд — WHACK. Клиент интерполирует движение руки сам. Неактивная перчатка имеет однокадровый NONE; сервер отправляет взмах принятой руки после завершения локального клика, чтобы основной взмах не подавлял левый. + +Все третьеличные преобразования наследуются от исходных моделей: оружие остаётся прикреплённым к кисти. Хват твинблейда в первом лице уменьшен и наклонён. След удара стал узким, с яркой кромкой, и проходит четыре кадра по возрасту конкретного удара. Новые ресурсы находятся в `v2`, поэтому обновляются без перезаписи пользовательских файлов. + +Проверки: + +- JUnit проверяет установку новых ресурсов, сохранение пользовательских правок, отсутствие отрыва моделей от рук через третьеличные смещения. +- Изолированный сервер проверяет серию, точный урон, откат, щиты, область твинблейда, тип и длительность штатного взмаха и восстановление реальных компонентов при перемещении в творческом инвентаре. +- Клиент без игровых модов AstraPlus/AstraWeapons отправляет реальные пакеты взмаха; записываются 360 последовательных кадров с частотой 20 кадров/с, от первого и третьего лица. Дополнительно проверяется исчезновение визуальной перчатки при переключении на твинблейд. +- `tools/encode-review.ps1` собирает четыре ракурса в один MP4: сверху перчатки, снизу твинблейд; слева первое лицо, справа третье. + +Это доступные ванильному клиенту движения. Они не воспроизводят произвольную скелетную анимацию Minecraft Dungeons. + +Результат выпуска 13.09.2026: 7 JUnit-тестов без ошибок; серверная проверка `build/verify-20260913-102920-88497e` — PASS. Клиент `build/weapons-capture-20260913-102945-3d1653` проверил 49 моделей, 23 звуковых файла и 360 последовательных кадров. Запись: `build/animation-review-0.1.1.mp4`. diff --git a/src/clientVerification/java/online/astradev/weapons/verification/client/WeaponsCapture.java b/src/clientVerification/java/online/astradev/weapons/verification/client/WeaponsCapture.java index e91909c..9a99918 100644 --- a/src/clientVerification/java/online/astradev/weapons/verification/client/WeaponsCapture.java +++ b/src/clientVerification/java/online/astradev/weapons/verification/client/WeaponsCapture.java @@ -49,28 +49,25 @@ public final class WeaponsCapture { if(mc.gui.screen() instanceof DisconnectedScreen)throw new IllegalStateException("Disconnected during capture"); if(mc.player==null || mc.level==null || mc.gui.overlay()!=null)return; mc.gui.toastManager().clear(); - if(stage>6) { + if(stage>3) { if(!audio.isDone())return; long count; try(var files=Files.list(mc.gameDirectory.toPath().resolve("screenshots"))) {count=files.filter(f->f.getFileName().toString().startsWith("weapons-")).count();} - if(count<21)return; - finish("PASS: "+models+" client item codecs/baked models, "+audio.join()+" original audio samples, 21 hand/area screenshots");return; + if(count<360)return; + finish("PASS: "+models+" client item codecs/baked models, "+audio.join()+" original audio samples, 360 consecutive frames of real swing packets, first/third-person");return; } if(!Files.exists(server.resolve("capture-stage-"+stage+".txt")))return; ++age; - if(age==35||age==55||age==75) { - if(stage==6 && age>40) { - var displays=new com.google.gson.JsonArray(); - for(var e:mc.level.entitiesForRendering()) if(e instanceof net.minecraft.world.entity.Display.ItemDisplay d) { - var state=d.itemRenderState(); - if(state!=null) {var row=new com.google.gson.JsonObject();row.addProperty("model",String.valueOf(state.itemStack().get(net.minecraft.core.component.DataComponents.ITEM_MODEL)));row.addProperty("position",d.position().toString());row.addProperty("age",d.tickCount);displays.add(row);} - } - Files.writeString(mc.gameDirectory.toPath().resolve("slash-displays-"+age+".json"),displays.toString()); - if(displays.isEmpty())throw new IllegalStateException("No textured slash received by client"); - } - net.minecraft.client.Screenshot.grab(mc.gameDirectory,"weapons-"+stage+"-"+age+".png",mc.gameRenderer.mainRenderTarget(),1,ignored->{}); + mc.options.setCameraType(stage%2==0 ? net.minecraft.client.CameraType.FIRST_PERSON : net.minecraft.client.CameraType.THIRD_PERSON_FRONT); + if(stage==2 && age==20 && !mc.player.getOffhandItem().isEmpty()) throw new IllegalStateException("Ghost glove remains after switching to twinblade"); + if(age>=25 && age<=110 && (age-25)%(stage<2 ? 6 : 16)==0) { + // Same swing call as vanilla left-click-air: local prediction + ServerboundSwingPacket. + mc.player.swing(net.minecraft.world.InteractionHand.MAIN_HAND); } - if(age>=90) { Files.writeString(server.resolve("capture-ack-"+stage+".txt"),"done");stage++;age=0; } + if(age>=20 && age<110) { + net.minecraft.client.Screenshot.grab(mc.gameDirectory,String.format("weapons-%d-%03d.png",stage,age-20),mc.gameRenderer.mainRenderTarget(),1,ignored->{}); + } + if(age>=125) { Files.writeString(server.resolve("capture-ack-"+stage+".txt"),"done");stage++;age=0; } } catch(Throwable error) { error.printStackTrace();finish("FAIL: "+error); } } private void finish(String result) { diff --git a/src/main/java/online/astradev/weapons/behavior/GauntletCombat.java b/src/main/java/online/astradev/weapons/behavior/GauntletCombat.java index ce36b94..8077dfa 100644 --- a/src/main/java/online/astradev/weapons/behavior/GauntletCombat.java +++ b/src/main/java/online/astradev/weapons/behavior/GauntletCombat.java @@ -102,7 +102,7 @@ public final class GauntletCombat { WeaponPresentation.animate(p,Combo.pose(step),Combo.left(step),config.gauntletCooldownTicks); sound(p,step == 6 ? "swing_kick" : step == 5 ? "swing_medium" : "swing_short",.7f); if (batch.hit) sound(p,step == 6 ? "hit_kick" : step == 5 ? "hit_medium" : "hit_light",.8f); - p.swing(Combo.left(step) ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND,true); + // WeaponPresentation sends the accepted hand after the local one-tick input swing. } public static boolean attackAllowed(Player p,Entity t) { return BATCHES.get(p.getUUID()).accepted.contains(t.getId()); } public static boolean hurt(Player p,Entity t,DamageSource source,float damage) { diff --git a/src/main/java/online/astradev/weapons/mixin/GauntletInventoryMixin.java b/src/main/java/online/astradev/weapons/mixin/GauntletInventoryMixin.java index e4e3222..fb74de5 100644 --- a/src/main/java/online/astradev/weapons/mixin/GauntletInventoryMixin.java +++ b/src/main/java/online/astradev/weapons/mixin/GauntletInventoryMixin.java @@ -13,6 +13,11 @@ import online.astradev.weapons.resource.WeaponPresentation; @Mixin(ServerGamePacketListenerImpl.class) public abstract class GauntletInventoryMixin { @Shadow public ServerPlayer player; + @ModifyVariable(method="handleSetCreativeModeSlot",at=@At("HEAD"),argsOnly=true) + private ServerboundSetCreativeModeSlotPacket astraweapons$restore(ServerboundSetCreativeModeSlotPacket packet) { + var restored=WeaponPresentation.restorePresentation(packet.itemStack()); + return restored==packet.itemStack() ? packet : new ServerboundSetCreativeModeSlotPacket(packet.slotNum(),restored); + } // Each injection occurs AFTER vanilla's packet thread validation. @Inject(method="handleContainerClick",at=@At(value="INVOKE",target="Lnet/minecraft/server/level/ServerPlayer;resetLastActionTime()V"),cancellable=true) private void astraweapons$slot(ServerboundContainerClickPacket p,CallbackInfo ci) { diff --git a/src/main/java/online/astradev/weapons/mixin/TwinbladeSwingMixin.java b/src/main/java/online/astradev/weapons/mixin/TwinbladeSwingMixin.java index 8dfb476..0637c58 100644 --- a/src/main/java/online/astradev/weapons/mixin/TwinbladeSwingMixin.java +++ b/src/main/java/online/astradev/weapons/mixin/TwinbladeSwingMixin.java @@ -18,14 +18,17 @@ public abstract class TwinbladeSwingMixin { @Shadow public ServerPlayer player; @Inject(method = "handleAnimate", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerPlayer;swing(Lnet/minecraft/world/InteractionHand;)V")) + target = "Lnet/minecraft/server/level/ServerPlayer;swing(Lnet/minecraft/world/InteractionHand;)V"), cancellable=true) private void astraplus$airSwing(ServerboundSwingPacket packet, CallbackInfo ci) { if (packet.getHand() != InteractionHand.MAIN_HAND || player.isSpectator() || (!TwinbladeCombat.holdsTwinblade(player) && !online.astradev.weapons.behavior.GauntletCombat.holds(player))) { return; } // Mining/interacting with a block is not an air attack. Entity-hit packets already consume charge. if (player.pick(player.blockInteractionRange(), 1, false).getType() == HitResult.Type.BLOCK) { return; } // Run after packet thread validation, but before vanilla swing resets the attack charge. - if (online.astradev.weapons.behavior.GauntletCombat.holds(player)) online.astradev.weapons.behavior.GauntletCombat.strike(player); + if (online.astradev.weapons.behavior.GauntletCombat.holds(player)) { + online.astradev.weapons.behavior.GauntletCombat.strike(player); + ci.cancel(); // Do not broadcast an extra right-hand swing over the accepted combo hand. + } else TwinbladeCombat.strike(player); } } diff --git a/src/main/java/online/astradev/weapons/resource/SlashDisplay.java b/src/main/java/online/astradev/weapons/resource/SlashDisplay.java index b78a43e..7e7616c 100644 --- a/src/main/java/online/astradev/weapons/resource/SlashDisplay.java +++ b/src/main/java/online/astradev/weapons/resource/SlashDisplay.java @@ -14,20 +14,25 @@ import org.joml.*; public final class SlashDisplay extends Display.ItemDisplay { private static final List ACTIVE = new ArrayList<>(); private final long expires; + private final long born; + private final boolean fiery; private final ServerPlayer owner; private SlashDisplay(ServerPlayer p,double reach,boolean fiery) { - super(EntityTypes.ITEM_DISPLAY,p.level()); owner=p; expires=p.level().getGameTime()+5; + super(EntityTypes.ITEM_DISPLAY,p.level()); owner=p; born=p.level().getGameTime(); expires=born+4; this.fiery=fiery; setNoGravity(true);setInvulnerable(true); - setPos(p.getX(),p.getY()+1,p.getZ()); + setPos(p.getX(),p.getY()+1.15,p.getZ()); // Vanilla ItemDisplayRenderer adds a 180-degree item rotation; compensate so +Z is the hit sector. setYRot(p.getYRot()+180); - var item=new ItemStack(Items.PAPER); - item.set(DataComponents.ITEM_MODEL,Identifier.parse("astraweapons:slash"+(fiery?"_fire":""))); - getSlot(0).set(item); + frame(0); ((online.astradev.weapons.mixin.DisplayAccess)(Object)this).astraweapons$transform(new Transformation(new Vector3f(),new Quaternionf(),new Vector3f((float)reach*2),new Quaternionf())); ((online.astradev.weapons.mixin.DisplayAccess)(Object)this).astraweapons$brightness(new net.minecraft.util.Brightness(15,15)); addTag("astraweapons:slash"); } + private void frame(int frame) { + var item=new ItemStack(Items.PAPER); + item.set(DataComponents.ITEM_MODEL,Identifier.parse("astraweapons:v2/slash_"+(fiery?"fire_":"")+frame)); + getSlot(0).set(item); + } public static void spawn(ServerPlayer player,double reach,boolean fiery) { var display=new SlashDisplay(player,reach,fiery); if(player.level().addFreshEntity(display)) ACTIVE.add(display); @@ -37,6 +42,7 @@ public final class SlashDisplay extends Display.ItemDisplay { if(display.isRemoved() || !display.owner.isAlive() || display.owner.level()!=display.level() || display.level().getGameTime()>=display.expires) { display.discard();return true; } + display.frame((int)(display.level().getGameTime()-display.born)); return false; }); } diff --git a/src/main/java/online/astradev/weapons/resource/WeaponPresentation.java b/src/main/java/online/astradev/weapons/resource/WeaponPresentation.java index f354543..3bfa806 100644 --- a/src/main/java/online/astradev/weapons/resource/WeaponPresentation.java +++ b/src/main/java/online/astradev/weapons/resource/WeaponPresentation.java @@ -18,8 +18,9 @@ import online.astradev.weapons.behavior.TwinbladeCombat; public final class WeaponPresentation { private record Animation(ItemStack weapon, String pose, boolean left, long start, int ticks, Object level) {} private static final Map ANIMATIONS = new HashMap<>(); - private static final Set WEARING = new HashSet<>(); - private static final Identifier GHOST = Identifier.parse("astraweapons:gauntlet_offhand"); + private record Presentation(String kind, int slot, ItemStack weapon) {} + private static final Map PRESENTED = new HashMap<>(); + private static final Set SWING_SENT = new HashSet<>(); private WeaponPresentation() {} public static boolean reserveOffhand(ServerPlayer p) { if (!GauntletCombat.holds(p)) return false; @@ -44,29 +45,31 @@ public final class WeaponPresentation { return true; } public static void animate(ServerPlayer p,String pose,boolean left,int ticks) { + SWING_SENT.remove(p.getUUID()); ANIMATIONS.put(p.getUUID(),new Animation(p.getMainHandItem(),pose,left,p.level().getGameTime(),ticks,p.level())); sync(p); } private static ItemStack visual(ServerPlayer p,ItemStack original,boolean offhand) { boolean gloves = GauntletCombat.holds(p) && p.getOffhandItem().isEmpty() && !p.isSpectator() && p.isAlive(); var animation = ANIMATIONS.get(p.getUUID()); boolean animating = animation != null && animation.weapon == p.getMainHandItem() && animation.level == p.level(); - if (offhand) { - if (!gloves) return original; - var ghost = new ItemStack(Items.PAPER); - ghost.set(DataComponents.ITEM_NAME,net.minecraft.network.chat.Component.literal("Левая боевая перчатка")); - ghost.set(DataComponents.ITEM_MODEL,animating && animation.left ? frame(p,animation) : GHOST); - return ghost; + if (gloves) { + var copy = offhand ? new ItemStack(Items.PAPER) : original.copy(); + boolean active = animating && animation.left == offhand; + String pose = active ? animation.pose : "guard"; + copy.set(DataComponents.ITEM_MODEL,Identifier.parse("astraweapons:v2/"+pose)); + if (offhand) copy.set(DataComponents.ITEM_NAME,net.minecraft.network.chat.Component.literal("Левая боевая перчатка")); + var type = !active ? SwingAnimationType.NONE : pose.equals("hook") ? SwingAnimationType.WHACK : SwingAnimationType.STAB; + copy.set(DataComponents.SWING_ANIMATION,new net.minecraft.world.item.component.SwingAnimation(type,active ? Math.max(1,animation.ticks-1) : 1)); + return copy; } - if (animating && (!gloves || !animation.left)) { - var copy = original.copy(); copy.set(DataComponents.ITEM_MODEL,frame(p,animation)); return copy; + if (!offhand && TwinbladeCombat.holdsTwinblade(p)) { + var copy=original.copy(); + copy.set(DataComponents.ITEM_MODEL,Identifier.parse("astraweapons:v2/twinblade")); + copy.set(DataComponents.SWING_ANIMATION,new net.minecraft.world.item.component.SwingAnimation(SwingAnimationType.WHACK,9)); + return copy; } return original; } - private static Identifier frame(ServerPlayer p,Animation animation) { - int elapsed = (int)(p.level().getGameTime()-animation.start); - int frame = Math.clamp(elapsed*6/Math.max(1,animation.ticks),0,5); - return Identifier.parse("astraweapons:animation/"+animation.pose+"_"+frame); - } /** Used only by the outgoing packet mixin on the server thread. */ public static Packet project(ServerPlayer viewer,Packet packet) { if (packet instanceof ClientboundBundlePacket bundle) { @@ -107,7 +110,16 @@ public final class WeaponPresentation { } public static boolean ghost(ItemStack stack) { var id=stack.get(DataComponents.ITEM_MODEL); - return id!=null && (id.equals(GHOST) || id.getNamespace().equals("astraweapons") && id.getPath().startsWith("animation/")); + return id!=null && id.getNamespace().equals("astraweapons") && (id.getPath().startsWith("animation/") || stack.is(Items.PAPER) && id.getPath().startsWith("v2/")); + } + /** A creative inventory move sends the visible copy back; strip only our presentation fields. */ + public static ItemStack restorePresentation(ItemStack stack) { + var model=stack.get(DataComponents.ITEM_MODEL); + String id=online.astradev.plus.content.PlusContent.id(stack); + boolean weapon=GauntletCombat.ID.equals(id) && stack.is(Items.IRON_SWORD) + || TwinbladeCombat.ID.equals(id) && stack.is(Items.NETHERITE_SWORD); + if(!weapon || model==null || !model.getNamespace().equals("astraweapons") || !model.getPath().startsWith("v2/")) return stack; + var copy=stack.copy();copy.set(DataComponents.ITEM_MODEL,Identifier.parse(id));copy.set(DataComponents.SWING_ANIMATION,online.astradev.plus.AstraPlus.content().entry(id).stack(1).get(DataComponents.SWING_ANIMATION));return copy; } public static void sync(ServerPlayer p) { if (p.connection==null) return; @@ -121,18 +133,27 @@ public final class WeaponPresentation { for(var p:server.getPlayerList().getPlayers()) { online.add(p.getUUID()); boolean wearing=GauntletCombat.holds(p) && p.isAlive() && !p.isSpectator() && reserveOffhand(p); - boolean changed=wearing ? WEARING.add(p.getUUID()) : WEARING.remove(p.getUUID()); + String presented=wearing ? "gauntlets" : TwinbladeCombat.holdsTwinblade(p) ? "twinblade" : "none"; + var presentation=new Presentation(presented,presented.equals("none") ? -1 : p.getInventory().getSelectedSlot(),presented.equals("none") ? ItemStack.EMPTY : p.getMainHandItem()); + boolean changed=!presentation.equals(PRESENTED.put(p.getUUID(),presentation)); var animation=ANIMATIONS.get(p.getUUID()); if(animation!=null) { if(!p.isAlive() || p.level()!=animation.level || p.getMainHandItem()!=animation.weapon || p.level().getGameTime()-animation.start>=animation.ticks) - ANIMATIONS.remove(p.getUUID()); - sync(p); + { + ANIMATIONS.remove(p.getUUID()); SWING_SENT.remove(p.getUUID()); sync(p); + } + else if(GauntletCombat.holds(p) && p.level().getGameTime()-animation.start>=1 && SWING_SENT.add(p.getUUID())) { + // The local one-tick NONE swing has finished. Send the accepted hand once; + // vanilla now interpolates the arm and weapon together, without model-frame spam. + p.swinging=false; p.swingTime=-1; + p.swing(animation.left ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND,true); + } } else if(changed) sync(p); } - WEARING.retainAll(online); ANIMATIONS.keySet().retainAll(online); + PRESENTED.keySet().retainAll(online); ANIMATIONS.keySet().retainAll(online); SWING_SENT.retainAll(online); } public static void close(MinecraftServer server) { - ANIMATIONS.clear(); WEARING.clear(); + ANIMATIONS.clear(); PRESENTED.clear(); SWING_SENT.clear(); // Projection naturally ends when the connection closes; no stored items need restoration. } } diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/guard.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/guard.json new file mode 100644 index 0000000..e482a3f --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/guard.json @@ -0,0 +1,24 @@ +{ + "hand_animation_on_swap": false, + "model": { + "type": "minecraft:select", + "property": "minecraft:display_context", + "cases": [ + { + "when": [ + "gui", + "ground", + "fixed" + ], + "model": { + "type": "minecraft:model", + "model": "astraweapons:item/iron_gauntlet_2d" + } + } + ], + "fallback": { + "type": "minecraft:model", + "model": "astraweapons:v2/guard" + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/hook.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/hook.json new file mode 100644 index 0000000..ba35913 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/hook.json @@ -0,0 +1,24 @@ +{ + "hand_animation_on_swap": false, + "model": { + "type": "minecraft:select", + "property": "minecraft:display_context", + "cases": [ + { + "when": [ + "gui", + "ground", + "fixed" + ], + "model": { + "type": "minecraft:model", + "model": "astraweapons:item/iron_gauntlet_2d" + } + } + ], + "fallback": { + "type": "minecraft:model", + "model": "astraweapons:v2/hook" + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/jab.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/jab.json new file mode 100644 index 0000000..8929d20 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/jab.json @@ -0,0 +1,24 @@ +{ + "hand_animation_on_swap": false, + "model": { + "type": "minecraft:select", + "property": "minecraft:display_context", + "cases": [ + { + "when": [ + "gui", + "ground", + "fixed" + ], + "model": { + "type": "minecraft:model", + "model": "astraweapons:item/iron_gauntlet_2d" + } + } + ], + "fallback": { + "type": "minecraft:model", + "model": "astraweapons:v2/jab" + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/lunge.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/lunge.json new file mode 100644 index 0000000..3273b15 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/lunge.json @@ -0,0 +1,24 @@ +{ + "hand_animation_on_swap": false, + "model": { + "type": "minecraft:select", + "property": "minecraft:display_context", + "cases": [ + { + "when": [ + "gui", + "ground", + "fixed" + ], + "model": { + "type": "minecraft:model", + "model": "astraweapons:item/iron_gauntlet_2d" + } + } + ], + "fallback": { + "type": "minecraft:model", + "model": "astraweapons:v2/lunge" + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_0.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_0.json new file mode 100644 index 0000000..ec4be0d --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_0.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "astraweapons:v2/slash_0" + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_1.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_1.json new file mode 100644 index 0000000..d178da2 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_1.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "astraweapons:v2/slash_1" + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_2.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_2.json new file mode 100644 index 0000000..5f46e5a --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_2.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "astraweapons:v2/slash_2" + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_3.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_3.json new file mode 100644 index 0000000..a558850 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_3.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "astraweapons:v2/slash_3" + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_0.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_0.json new file mode 100644 index 0000000..7417393 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_0.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "astraweapons:v2/slash_fire_0" + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_1.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_1.json new file mode 100644 index 0000000..7668262 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_1.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "astraweapons:v2/slash_fire_1" + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_2.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_2.json new file mode 100644 index 0000000..c7d33b0 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_2.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "astraweapons:v2/slash_fire_2" + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_3.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_3.json new file mode 100644 index 0000000..28d4a8f --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/slash_fire_3.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "astraweapons:v2/slash_fire_3" + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/twinblade.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/twinblade.json new file mode 100644 index 0000000..275f38d --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/twinblade.json @@ -0,0 +1,24 @@ +{ + "hand_animation_on_swap": false, + "model": { + "type": "minecraft:select", + "property": "minecraft:display_context", + "cases": [ + { + "when": [ + "gui", + "ground", + "fixed" + ], + "model": { + "type": "minecraft:model", + "model": "astraplus:internal/twinblade_gui" + } + } + ], + "fallback": { + "type": "minecraft:model", + "model": "astraweapons:v2/twinblade" + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/items/v2/uppercut.json b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/uppercut.json new file mode 100644 index 0000000..279b23f --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/items/v2/uppercut.json @@ -0,0 +1,24 @@ +{ + "hand_animation_on_swap": false, + "model": { + "type": "minecraft:select", + "property": "minecraft:display_context", + "cases": [ + { + "when": [ + "gui", + "ground", + "fixed" + ], + "model": { + "type": "minecraft:model", + "model": "astraweapons:item/iron_gauntlet_2d" + } + } + ], + "fallback": { + "type": "minecraft:model", + "model": "astraweapons:v2/uppercut" + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/guard.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/guard.json new file mode 100644 index 0000000..cc90242 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/guard.json @@ -0,0 +1,39 @@ +{ + "parent": "astraweapons:item/iron_gauntlet_3d", + "display": { + "firstperson_righthand": { + "rotation": [ + -24, + 0, + -8 + ], + "translation": [ + 0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + }, + "firstperson_lefthand": { + "rotation": [ + -24, + 0, + 8 + ], + "translation": [ + -0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/hook.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/hook.json new file mode 100644 index 0000000..b235ee6 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/hook.json @@ -0,0 +1,39 @@ +{ + "parent": "astraweapons:item/iron_gauntlet_3d", + "display": { + "firstperson_righthand": { + "rotation": [ + -24, + 0, + 4 + ], + "translation": [ + 0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + }, + "firstperson_lefthand": { + "rotation": [ + -24, + 0, + -4 + ], + "translation": [ + -0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/jab.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/jab.json new file mode 100644 index 0000000..cc90242 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/jab.json @@ -0,0 +1,39 @@ +{ + "parent": "astraweapons:item/iron_gauntlet_3d", + "display": { + "firstperson_righthand": { + "rotation": [ + -24, + 0, + -8 + ], + "translation": [ + 0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + }, + "firstperson_lefthand": { + "rotation": [ + -24, + 0, + 8 + ], + "translation": [ + -0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/lunge.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/lunge.json new file mode 100644 index 0000000..cc90242 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/lunge.json @@ -0,0 +1,39 @@ +{ + "parent": "astraweapons:item/iron_gauntlet_3d", + "display": { + "firstperson_righthand": { + "rotation": [ + -24, + 0, + -8 + ], + "translation": [ + 0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + }, + "firstperson_lefthand": { + "rotation": [ + -24, + 0, + 8 + ], + "translation": [ + -0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_0.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_0.json new file mode 100644 index 0000000..586e64c --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_0.json @@ -0,0 +1,43 @@ +{ + "textures": { + "slash": "astraweapons:item/v2/slash_0", + "particle": "astraweapons:item/v2/slash_0" + }, + "elements": [ + { + "from": [ + 0, + 8, + 0 + ], + "to": [ + 16, + 8, + 16 + ], + "shade": false, + "light_emission": 15, + "faces": { + "up": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ] + }, + "down": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ], + "rotation": 180 + } + } + } + ] +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_1.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_1.json new file mode 100644 index 0000000..4d7c962 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_1.json @@ -0,0 +1,43 @@ +{ + "textures": { + "slash": "astraweapons:item/v2/slash_1", + "particle": "astraweapons:item/v2/slash_1" + }, + "elements": [ + { + "from": [ + 0, + 8, + 0 + ], + "to": [ + 16, + 8, + 16 + ], + "shade": false, + "light_emission": 15, + "faces": { + "up": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ] + }, + "down": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ], + "rotation": 180 + } + } + } + ] +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_2.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_2.json new file mode 100644 index 0000000..90d9e83 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_2.json @@ -0,0 +1,43 @@ +{ + "textures": { + "slash": "astraweapons:item/v2/slash_2", + "particle": "astraweapons:item/v2/slash_2" + }, + "elements": [ + { + "from": [ + 0, + 8, + 0 + ], + "to": [ + 16, + 8, + 16 + ], + "shade": false, + "light_emission": 15, + "faces": { + "up": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ] + }, + "down": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ], + "rotation": 180 + } + } + } + ] +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_3.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_3.json new file mode 100644 index 0000000..96923e4 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_3.json @@ -0,0 +1,43 @@ +{ + "textures": { + "slash": "astraweapons:item/v2/slash_3", + "particle": "astraweapons:item/v2/slash_3" + }, + "elements": [ + { + "from": [ + 0, + 8, + 0 + ], + "to": [ + 16, + 8, + 16 + ], + "shade": false, + "light_emission": 15, + "faces": { + "up": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ] + }, + "down": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ], + "rotation": 180 + } + } + } + ] +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_0.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_0.json new file mode 100644 index 0000000..7752368 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_0.json @@ -0,0 +1,43 @@ +{ + "textures": { + "slash": "astraweapons:item/v2/slash_fire_0", + "particle": "astraweapons:item/v2/slash_fire_0" + }, + "elements": [ + { + "from": [ + 0, + 8, + 0 + ], + "to": [ + 16, + 8, + 16 + ], + "shade": false, + "light_emission": 15, + "faces": { + "up": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ] + }, + "down": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ], + "rotation": 180 + } + } + } + ] +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_1.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_1.json new file mode 100644 index 0000000..1057b8e --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_1.json @@ -0,0 +1,43 @@ +{ + "textures": { + "slash": "astraweapons:item/v2/slash_fire_1", + "particle": "astraweapons:item/v2/slash_fire_1" + }, + "elements": [ + { + "from": [ + 0, + 8, + 0 + ], + "to": [ + 16, + 8, + 16 + ], + "shade": false, + "light_emission": 15, + "faces": { + "up": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ] + }, + "down": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ], + "rotation": 180 + } + } + } + ] +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_2.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_2.json new file mode 100644 index 0000000..72dcf62 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_2.json @@ -0,0 +1,43 @@ +{ + "textures": { + "slash": "astraweapons:item/v2/slash_fire_2", + "particle": "astraweapons:item/v2/slash_fire_2" + }, + "elements": [ + { + "from": [ + 0, + 8, + 0 + ], + "to": [ + 16, + 8, + 16 + ], + "shade": false, + "light_emission": 15, + "faces": { + "up": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ] + }, + "down": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ], + "rotation": 180 + } + } + } + ] +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_3.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_3.json new file mode 100644 index 0000000..25cc069 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/slash_fire_3.json @@ -0,0 +1,43 @@ +{ + "textures": { + "slash": "astraweapons:item/v2/slash_fire_3", + "particle": "astraweapons:item/v2/slash_fire_3" + }, + "elements": [ + { + "from": [ + 0, + 8, + 0 + ], + "to": [ + 16, + 8, + 16 + ], + "shade": false, + "light_emission": 15, + "faces": { + "up": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ] + }, + "down": { + "texture": "#slash", + "uv": [ + 0, + 0, + 16, + 16 + ], + "rotation": 180 + } + } + } + ] +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/twinblade.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/twinblade.json new file mode 100644 index 0000000..fc13cad --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/twinblade.json @@ -0,0 +1,39 @@ +{ + "parent": "astraplus:item/netherite_twinblade", + "display": { + "firstperson_righthand": { + "rotation": [ + 0, + -90, + 55 + ], + "translation": [ + 1.1, + 1.4, + 0 + ], + "scale": [ + 1.85, + 1.85, + 0.68 + ] + }, + "firstperson_lefthand": { + "rotation": [ + 0, + 90, + -55 + ], + "translation": [ + 1.1, + 1.4, + 0 + ], + "scale": [ + 1.85, + 1.85, + 0.68 + ] + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/models/v2/uppercut.json b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/uppercut.json new file mode 100644 index 0000000..2e27529 --- /dev/null +++ b/src/main/resources/defaults/resources/assets/astraweapons/models/v2/uppercut.json @@ -0,0 +1,39 @@ +{ + "parent": "astraweapons:item/iron_gauntlet_3d", + "display": { + "firstperson_righthand": { + "rotation": [ + -36, + 0, + -8 + ], + "translation": [ + 0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + }, + "firstperson_lefthand": { + "rotation": [ + -36, + 0, + 8 + ], + "translation": [ + -0.5, + 5.0, + 0 + ], + "scale": [ + 0.9, + 0.9, + 0.9 + ] + } + } +} diff --git a/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_0.png b/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_0.png new file mode 100644 index 0000000000000000000000000000000000000000..43825b7515eea8a8a6657f24263904e326d75462 GIT binary patch literal 524 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zf+;V7%<<;uumf=k0Arze52ctQX=R zd!^_bO?djs;k#1w%0vZ2-wmu$b@lHpl@B$P9C*4fyv~~usGAC)p)hu5(Eaa!-@jhp z|M=(Mzlr5v(;ajDx9T&@;&QlNTKDoM53hp>qrxl(0bhm=H3pa2x(xH*-+%s}eSxS{ zLk5$>mfcJretk2#Kh=R1$Tw$waH)`^+hFZQ1{Yz5MR#Qz9xCPVEK&tYu^%XA%xPp( zxTV9mf&GFOFIek+xd(XyfxHi51ays<1amJkNHpK5Vfgos@t8u?<{unOSR;(B87`)A z9=IU^WNQO8-DFz8nlTY*OcLV;ZUJ$I^Bfmuxwaz6+tP4*(Gi`4eeOVUT?cKs zBIz$d+!C!fav0il6GW8OG4?pEx$FF&(~L_{ykX_y3AGKA>cl)aZlo~i9GUWk&46p8 z+iIyszi;h#Uj%Yx7%?R4J~-{)Qg`5!x9<6+M&|_tUVb?p|67V+xNA)Q!!Ye^)@(NO QqAHMLPgg&ebxsLQ06+_+`~Uy| literal 0 HcmV?d00001 diff --git a/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_1.png b/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_1.png new file mode 100644 index 0000000000000000000000000000000000000000..ad6c71c64f8241911a57d743724f7ff9432a2b89 GIT binary patch literal 718 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zf+;V4CXb;uumf=j|PDzt;{Tu7T|f z55z2BJlx85hILs|2(NdThsT_dr0}_0txV>zOiXxv@6&T$W}tRzfRJxL|Jh#qH*dqT z_RxB(H9ib3!VDK#984Gmd_l}P*)s0m8Bfe($ZNYOtStbM$qi)KeK)UscRy2a3}=zR zGVw5lMVt*8ObWLiF)VA|P|UDV_`%Pw8~>>{ibgbcl!Y=}Q&3{oc+QY5V7q}y@a-#x zHI7@(uqfO*%4orUp;=4#fRsxP!#XxW=>vcMG6Xk>S+WQN6+LTD3~snKgTZCBSc9fR z4ny3u<)NYB3c(FG7eDF+SqWK{k755y5WejU~ zyj(2sSu;UYNvk1~E26byE<>2&ws(5|%~7o#ybmsDJ+X1P!Xm&J{j^nL(Oq4j#fr5| z9YBIrh%tK8E6D>>6_uDRzTIm$z4(YvLvp`YN5c$J4;G%6-x*yTN*G!>B2FJX{37aD zq0H&)>-*>1|Nr*s+m@B*z2wad8P8R=A9y(99kYhZ0o&ZNwKJ|QJmlqahQ*>}^BFIf z7@*#c*v4sVoLg7Blt>?_V`&xW;7Ul65|DLB1QG`(ad16n-o>4u#IlIlLge7e&VU(Q zCBg?(FDEFqy77G~=^LmOM*aQ*mV9Mxb&|-Vo fFAqym2@yy2HHC$|PnQW>gTy>t{an^LB{Ts5d93x! literal 0 HcmV?d00001 diff --git a/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_2.png b/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_2.png new file mode 100644 index 0000000000000000000000000000000000000000..a3d50cf69c88bddc25aa2e43167b8eada6c5e62b GIT binary patch literal 567 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zf+;VEpIl;uumf=j|QGq9y|gwtyX8 z)#5Q*j^~Ph(|a5GVu|rgqrSi^j+6epUmGLz*Um}6hzF>bK47a=UCsGwd1i(Kelc8( z42@?$zgZ`+F_K?ko)8c*xTFR8RCqa{pp`8D)D=ur6>LE0f#k7;pM+{^|NW`8+p|Bc zcFl&FTMV{YtUJDOajg9;%hk_r9`Fh9|G+PM=9Dk*0oB0T^uNxJRVAYT9zK(^;s4Wf zU%najJiZarHf@$|#pZ+m9-fcVbKJ~cXC?i`Kz6&>A0I}oS-e87H=eyaS0eOpTJwBU z`-V$76EqH)9el6)$5XsHBBc4UFX13C6@^GHI+Gu zTm>tGg_0&@cU=gUyk@uBn3b#LF4@so#-?CvEi0|p@=d#Wzp$Pz8eZxlp literal 0 HcmV?d00001 diff --git a/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_3.png b/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_3.png new file mode 100644 index 0000000000000000000000000000000000000000..50c5bbd9ae1d3b76858e5db7fe80556e75579322 GIT binary patch literal 678 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zf+;V9ND$aSW-L^Y*Tz-(v>>)(b6* z55y)I%1n>^a))(YQplxyWhT7ykRrX|F=8a7%rrIx9?)Ou;jUYe|wBOL&mP(@$0Y0K4)N5$oB0jULf|7Op%R)PCv13FGT`nk@ZaE_v;5y1U?<{-0~z_9lBP-mNb& zd8hL-Nmyomi3O06W&9@GO0Ilb$@Yam&(>7dzN+eX*F4Epf9375Wo?NPRr@-trz~l; ze^uAKrdsND@p9vT)PYrNj$GVsm_Oid; z^UJS)u768j|DWE9w+p|qIs`Mmm>2iw(q>7ih72YL6Gnwu3z30mm1De?sZiO;RSn(waE;9w|*>aotL$;t9+eIN>hb^m_AM9n==D;kF zJCET8bH)^)YG1}5`TQSDI@Yii=ykA3Hg;^wVCZqov173R#*i$~8(G70iD}JD*@leG zED1S0K=xFirX0o#Oj|sF#_VLc!Ro=?P|lKZc9Zf1F$G1E`sZPv;<3bP0l+XkKr;?&k literal 0 HcmV?d00001 diff --git a/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_1.png b/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_1.png new file mode 100644 index 0000000000000000000000000000000000000000..144d817af24a068a73f0ad3878d3aaf30ae14555 GIT binary patch literal 720 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zf+;V4Cjf;uumf=j|O^KV?Ue){AD6 z-HJ)3DIKkfMq$oJk~n&~E}meL-u*VKJp694(vpd6*=_#sL;oA_0F9sq2)Oy}XI}L0 z_bsY-b$;DVOk`4+#n7R~u!yrE1H^m~a=YLBJL8FY40&xAg|!7PvN)J93giYc%)b5m zY>hmt)J~x%3O@R499)DMfO1<-GWM`1K4&OWKXBOlD?gL>1}4F`ix}289x1YKkc(*S zC@W;RrVy3JbYSNk=8V{>oC&;2<_zXXJ$Mto|78en5VK@)UVC_hrbD(5!=kI)4}Kfu za0!SvOn;ggdRO#>h=M6d%~gAr*-T5=61XnRs?=+q1!R7x=Gvj-^{m%`|Kvoe22BU; zXSE_p>0A-59b6AUl*e3#FvV-{to)m!T7g#G*Lq^(aD_#HG5cw&#G+VTprMMjOdUXi zRfsWr(;LYHQx%1nExz1qIKB9YPlI#6S4YDPQ4bcLm){v(97-5kIU-KoJN#nO{^T#O zyRRR&uisW#6@N8-DgWvj49oX8KPd3|&M2bvU{=`fus>^@Tc>tR;oR^&ZRXUDEeu?O z0=t=fBip&cJ71VJ*b9m{DQGrK%mf(Mb$h0~ZCfjs$Ql z(k*11BXWqLLNAjBW-kwukNV du=JD=aYTJdI?vh2#ohlvVxF#kF6*2UngH`l`85Cl literal 0 HcmV?d00001 diff --git a/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_2.png b/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_2.png new file mode 100644 index 0000000000000000000000000000000000000000..1f06d5ac770f36f87bda1df5e5b4205a64cbcfa3 GIT binary patch literal 575 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zf+;U}E!haSW-L^Y)H)UbBM;>jg)z z$w!x*%6hRz=Zx3%t4mHL1tkUcxTqvEPh))SE%~*A_x7_T8{h!d&suh~OQtEr>@wOF7Db4AN=B{H=WHPpu?h$$D>0kb9|HJ&B zC*n=*8?wK%O;xf{{}Fh|p3AU9(>1~{{P~`P>z#Phyae;k^gcMQ@353(@=k$2HLN>A zTX?>6c2Cp&@=?F^*%FB-laySv4nNvzReSG2_)0eG-<)X;Mm9pfdJe7+;;YJ)?2G6K z)i!FaySA|G)kC{8^ED6GizR=)^jJDSXS3Yf^@f7k|AICy5ZJwQvy0=4^}!A9^|v>< zYl^KoF8Cu=hL literal 0 HcmV?d00001 diff --git a/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_3.png b/src/main/resources/defaults/resources/assets/astraweapons/textures/item/v2/slash_fire_3.png new file mode 100644 index 0000000000000000000000000000000000000000..ad675a8b2f843627fe8b877b773e94063a4a4600 GIT binary patch literal 685 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zf+;U@Gx+aSW-L^Y*S`-W>x0)_~ky zGHRiIkM%wrY$~zr)s{b|+N{Z;(RD3MWvy$`J!YOAlTKd!bMS)Ml1wI`Av6UI-gnmh z+_=I2=g+lQ-shiR-~Rgh>5JS4LQmcH?p&{YU4UWNn}6wo48Oj7c|GMc2SaT6|J&E! zx1VEVa=7(Qo~2>SU3(6O%-!_@442COD=?H?|9f8Rp8~^@Uwi*gVwkY)H#_5kzwhcl z9W3`_@F@Qdkr0z5n|o{#gBa$F-Szt+U&1usqjh?gKJz@f@Gpczmwu;oOW$V_>K`zyGMC z8u>8%a9+;3J$t82%zq@PnhE6QPw4eeu9hl3_TOXG*);k7P36B$HO=?R^e?+_zbx?Z zhq#OBdVjROK6B?ed^f!N)wk8V_FkMX+IFExVVg+JiF+^Ke_Z&6<4EYjitk4+a@C15 zS_pL*a377Af792HQ)m3^)Mt~@AGItG0uM&)5}s0D^I=0oD<3Gi9N2PKo@>SPd57X( Q`~&elUHx3vIVCg!0R0gZn*aa+ literal 0 HcmV?d00001 diff --git a/src/main/resources/weapons-index.txt b/src/main/resources/weapons-index.txt index 09888f5..c77770c 100644 --- a/src/main/resources/weapons-index.txt +++ b/src/main/resources/weapons-index.txt @@ -40,6 +40,20 @@ resources/assets/astraweapons/items/animation/uppercut_5.json resources/assets/astraweapons/items/gauntlet_offhand.json resources/assets/astraweapons/items/slash.json resources/assets/astraweapons/items/slash_fire.json +resources/assets/astraweapons/items/v2/guard.json +resources/assets/astraweapons/items/v2/hook.json +resources/assets/astraweapons/items/v2/jab.json +resources/assets/astraweapons/items/v2/lunge.json +resources/assets/astraweapons/items/v2/slash_0.json +resources/assets/astraweapons/items/v2/slash_1.json +resources/assets/astraweapons/items/v2/slash_2.json +resources/assets/astraweapons/items/v2/slash_3.json +resources/assets/astraweapons/items/v2/slash_fire_0.json +resources/assets/astraweapons/items/v2/slash_fire_1.json +resources/assets/astraweapons/items/v2/slash_fire_2.json +resources/assets/astraweapons/items/v2/slash_fire_3.json +resources/assets/astraweapons/items/v2/twinblade.json +resources/assets/astraweapons/items/v2/uppercut.json resources/assets/astraweapons/lang/en_us.json resources/assets/astraweapons/lang/ru_ru.json resources/assets/astraweapons/models/animation/hook_0.json @@ -76,6 +90,20 @@ resources/assets/astraweapons/models/effect/slash.json resources/assets/astraweapons/models/effect/slash_fire.json resources/assets/astraweapons/models/item/iron_gauntlet_2d.json resources/assets/astraweapons/models/item/iron_gauntlet_3d.json +resources/assets/astraweapons/models/v2/guard.json +resources/assets/astraweapons/models/v2/hook.json +resources/assets/astraweapons/models/v2/jab.json +resources/assets/astraweapons/models/v2/lunge.json +resources/assets/astraweapons/models/v2/slash_0.json +resources/assets/astraweapons/models/v2/slash_1.json +resources/assets/astraweapons/models/v2/slash_2.json +resources/assets/astraweapons/models/v2/slash_3.json +resources/assets/astraweapons/models/v2/slash_fire_0.json +resources/assets/astraweapons/models/v2/slash_fire_1.json +resources/assets/astraweapons/models/v2/slash_fire_2.json +resources/assets/astraweapons/models/v2/slash_fire_3.json +resources/assets/astraweapons/models/v2/twinblade.json +resources/assets/astraweapons/models/v2/uppercut.json resources/assets/astraweapons/sounds.json resources/assets/astraweapons/sounds/gauntlets/sfx_item_gauntletshitimpactkick-001_soundwave.ogg resources/assets/astraweapons/sounds/gauntlets/sfx_item_gauntletshitimpactkick-002_soundwave.ogg @@ -107,3 +135,11 @@ resources/assets/astraweapons/textures/item/slash.png resources/assets/astraweapons/textures/item/slash.png.mcmeta resources/assets/astraweapons/textures/item/slash_fire.png resources/assets/astraweapons/textures/item/slash_fire.png.mcmeta +resources/assets/astraweapons/textures/item/v2/slash_0.png +resources/assets/astraweapons/textures/item/v2/slash_1.png +resources/assets/astraweapons/textures/item/v2/slash_2.png +resources/assets/astraweapons/textures/item/v2/slash_3.png +resources/assets/astraweapons/textures/item/v2/slash_fire_0.png +resources/assets/astraweapons/textures/item/v2/slash_fire_1.png +resources/assets/astraweapons/textures/item/v2/slash_fire_2.png +resources/assets/astraweapons/textures/item/v2/slash_fire_3.png diff --git a/src/test/java/online/astradev/weapons/WeaponsResourcesTest.java b/src/test/java/online/astradev/weapons/WeaponsResourcesTest.java index 8e18445..16dea37 100644 --- a/src/test/java/online/astradev/weapons/WeaponsResourcesTest.java +++ b/src/test/java/online/astradev/weapons/WeaponsResourcesTest.java @@ -28,6 +28,13 @@ class WeaponsResourcesTest { assertTrue(Files.readString(assets.resolve("credits/THIRD_PARTY_NOTICES.md")).contains("joshieman")); for(String pose:java.util.List.of("jab","hook","uppercut","lunge","twinblade")) for(int frame=0;frame<6;frame++) assertTrue(Files.exists(assets.resolve("items/animation/"+pose+"_"+frame+".json"))); + for(String pose:java.util.List.of("guard","jab","hook","uppercut","lunge","twinblade")) { + var item=JsonParser.parseString(Files.readString(assets.resolve("items/v2/"+pose+".json"))).getAsJsonObject(); + assertFalse(item.get("hand_animation_on_swap").getAsBoolean()); + var display=JsonParser.parseString(Files.readString(assets.resolve("models/v2/"+pose+".json"))).getAsJsonObject().getAsJsonObject("display"); + assertFalse(display.has("thirdperson_righthand"),"Pose must not detach model from vanilla arm"); + assertFalse(display.has("thirdperson_lefthand"),"Pose must not detach model from vanilla arm"); + } assertFalse(Files.exists(root.resolve("astraplus/resources/assets/minecraft/items/iron_sword.json"))); } } diff --git a/src/verification/java/online/astradev/weapons/verification/CaptureFixture.java b/src/verification/java/online/astradev/weapons/verification/CaptureFixture.java index 1fc37de..0f93804 100644 --- a/src/verification/java/online/astradev/weapons/verification/CaptureFixture.java +++ b/src/verification/java/online/astradev/weapons/verification/CaptureFixture.java @@ -31,22 +31,16 @@ final class CaptureFixture { if(!ready || server.getPlayerList().getPlayers().isEmpty()) return; ServerPlayer p=server.getPlayerList().getPlayers().getFirst(); if(stage<0 || Files.exists(Path.of("capture-ack-"+stage+".txt"))) { - if(++stage>6) return; + if(++stage>3) return; age=0; p.setGameMode(GameType.CREATIVE);p.setNoGravity(true);p.getInventory().clearContent(); p.teleportTo(server.overworld(),100,65,100,java.util.Set.of(),0,15,true); - p.setItemInHand(InteractionHand.MAIN_HAND,AstraPlus.content().entry(stage==6?TwinbladeCombat.ID:GauntletCombat.ID).stack(1)); + p.setItemInHand(InteractionHand.MAIN_HAND,AstraPlus.content().entry(stage>=2?TwinbladeCombat.ID:GauntletCombat.ID).stack(1)); p.setItemInHand(InteractionHand.OFF_HAND,ItemStack.EMPTY); Files.writeString(Path.of("capture-stage-"+stage+".txt"),"ready"); } - if(stage>6) return; + if(stage>3) return; ++age; - if(age==20 && stage>0) { - String pose=stage==1||stage==2?"jab":stage==3?"hook":stage==4?"uppercut":stage==5?"lunge":"twinblade"; - WeaponPresentation.animate(p,pose,stage==1||stage==3,80); - } - // Repeated flashes overlap one tick so screenshot cadence cannot land in a spawn/metadata gap. - if(stage==6 && age>=40 && age<80 && age%3==0) SlashDisplay.spawn(p,3,false); } catch(Throwable error) { error.printStackTrace(); try { Files.writeString(Path.of("capture-failure.txt"),error.toString()); } catch(Exception ignored) {} diff --git a/src/verification/java/online/astradev/weapons/verification/GauntletVerification.java b/src/verification/java/online/astradev/weapons/verification/GauntletVerification.java index d770788..7abd4d1 100644 --- a/src/verification/java/online/astradev/weapons/verification/GauntletVerification.java +++ b/src/verification/java/online/astradev/weapons/verification/GauntletVerification.java @@ -44,6 +44,12 @@ final class GauntletVerification { p.attack(front); check(Math.abs(front.getHealth()-(100-total))<.002,"combo step "+step+" exact damage: "+front.getHealth()); check(side.getHealth()==100 && rear.getHealth()==100 && far.getHealth()==100,"small hit area excludes side/rear/far"); + var mainVisual=(ClientboundSetPlayerInventoryPacket)WeaponPresentation.project(p,new ClientboundSetPlayerInventoryPacket(p.getInventory().getSelectedSlot(),p.getMainHandItem())); + var offVisual=(ClientboundSetPlayerInventoryPacket)WeaponPresentation.project(p,new ClientboundSetPlayerInventoryPacket(40,ItemStack.EMPTY)); + check(ItemStack.matches(WeaponPresentation.restorePresentation(mainVisual.contents()),p.getMainHandItem()),"creative movement restores real glove components"); + var active=(Combo.left(step) ? offVisual : mainVisual).contents(); + check(active.getSwingAnimation().type()==(step==4 ? SwingAnimationType.WHACK : SwingAnimationType.STAB),"accepted hand uses native interpolated swing "+step); + check(active.getSwingAnimation().duration()==4,"native swing finishes inside five-tick combo window"); float hp=front.getHealth();p.attack(front);GauntletCombat.strike(p); check(front.getHealth()==hp,"same tick click/swing cannot duplicate a hit"); check(!WeaponPresentation.ghost(p.getMainHandItem()) && p.getOffhandItem().isEmpty(),"animated model only exists in packets"); diff --git a/tools/build_visuals.py b/tools/build_visuals.py index 2c5ef75..80a16da 100644 --- a/tools/build_visuals.py +++ b/tools/build_visuals.py @@ -28,7 +28,7 @@ def main(): band=max(0,1-abs(r-(.85+frame*.012))/.16) sweep=max(0,1-abs(angle-(-1.0+frame*.5))/2.25) # Use an opaque core: vanilla item cutout discards a translucent-only crescent. - alpha=255 if band*sweep > .18+frame*.09 else 0 + alpha=255 if band*sweep > .18+frame*.09 else 0 image.putpixel((x,y+frame*size),(255,184,79,alpha) if fiery else (222,208,255,alpha)) name='slash_fire' if fiery else 'slash' (D/'textures/item').mkdir(parents=True,exist_ok=True) diff --git a/tools/build_visuals_v2.py b/tools/build_visuals_v2.py new file mode 100644 index 0000000..9a25a7d --- /dev/null +++ b/tools/build_visuals_v2.py @@ -0,0 +1,64 @@ +"""Stable hand models driven by vanilla swing animations, plus timed slash frames.""" +from pathlib import Path +import json, math +from PIL import Image + +ROOT = Path(__file__).resolve().parents[1] / 'src/main/resources' +D = ROOT / 'defaults/resources/assets/astraweapons' + +def write(path, value): + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(value, ensure_ascii=False, indent=2)+'\n', encoding='utf-8') + +def model(name): + return {'type':'minecraft:model','model':name} + +def hand_item(name, parent, gui, display): + write(D/f'models/v2/{name}.json', {'parent':parent, 'display':display}) + write(D/f'items/v2/{name}.json', {'hand_animation_on_swap':False, 'model':{ + 'type':'minecraft:select','property':'minecraft:display_context', + 'cases':[{'when':['gui','ground','fixed'],'model':model(gui)}], + 'fallback':model(f'astraweapons:v2/{name}')}}) + +def main(): + # No third-person pose offsets: the glove stays attached to the wrist while + # the vanilla STAB/WHACK animation moves the actual arm with frame interpolation. + base=json.loads((D/'models/item/iron_gauntlet_3d.json').read_text(encoding='utf-8')) + for pose, pitch, roll in [('guard',0,0),('jab',0,0),('hook',0,12),('uppercut',-12,0),('lunge',0,0)]: + display={} + for side,sign in [('righthand',1),('lefthand',-1)]: + src=base['display']['firstperson_'+side] + display['firstperson_'+side]={'rotation':[src['rotation'][0]+pitch,0,sign*(-8+roll)], + 'translation':[sign*.5,5.0,0], 'scale':[.9,.9,.9]} + hand_item(pose,'astraweapons:item/iron_gauntlet_3d','astraweapons:item/iron_gauntlet_2d',display) + hand_item('twinblade','astraplus:item/netherite_twinblade','astraplus:internal/twinblade_gui',{ + 'firstperson_righthand':{'rotation':[0,-90,55],'translation':[1.1,1.4,0],'scale':[1.85,1.85,.68]}, + 'firstperson_lefthand':{'rotation':[0,90,-55],'translation':[1.1,1.4,0],'scale':[1.85,1.85,.68]}}) + # Each transient display selects frames by its own age. No globally running + # animated texture, so every slash starts at the beginning of the same trail. + for fiery in (False, True): + for frame in range(4): + name=f'slash_{"fire_" if fiery else ""}{frame}' + size=192; im=Image.new('RGBA',(size,size)) + lead=(-.9,-.15,.6,1.15)[frame] + for y in range(size): + for x in range(size): + dx=(x+.5-size/2)/(size/2);z=(y+.5-size/2)/(size/2) + r=math.hypot(dx,z);a=math.atan2(dx,z) + tail=lead-a + if z<=0 or not 0