From cb1b2d694fece71cbc6a8ff29cd191b693f9f17b Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Wed, 18 Dec 2024 18:28:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=AB=E8=89=87=E7=82=AE?= =?UTF-8?q?=E5=A1=94=E7=9A=84=E8=BF=87=E7=83=AD=E7=BA=A2=E6=B8=A9=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/layer/SpeedBoatHeatLayer.java | 31 +++ .../renderer/entity/SpeedboatRenderer.java | 2 + .../superbwarfare/entity/SpeedboatEntity.java | 17 +- .../animations/speedboat.animation.json | 13 +- .../superbwarfare/geo/speedboat.geo.json | 223 +++++++++--------- .../textures/entity/speedboat_heat.png | Bin 0 -> 1391 bytes 6 files changed, 166 insertions(+), 120 deletions(-) create mode 100644 src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatHeatLayer.java create mode 100644 src/main/resources/assets/superbwarfare/textures/entity/speedboat_heat.png diff --git a/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatHeatLayer.java b/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatHeatLayer.java new file mode 100644 index 000000000..4c5aa312f --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatHeatLayer.java @@ -0,0 +1,31 @@ +package com.atsuishio.superbwarfare.client.layer; + +import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.entity.SpeedboatEntity; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.resources.ResourceLocation; +import software.bernie.geckolib.cache.object.BakedGeoModel; +import software.bernie.geckolib.renderer.GeoRenderer; +import software.bernie.geckolib.renderer.layer.GeoRenderLayer; + +import static com.atsuishio.superbwarfare.entity.SpeedboatEntity.HEAT; + +public class SpeedBoatHeatLayer extends GeoRenderLayer { + private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_heat.png"); + + public SpeedBoatHeatLayer(GeoRenderer entityRenderer) { + super(entityRenderer); + } + + @Override + public void render(PoseStack poseStack, SpeedboatEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { + RenderType glowRenderType = RenderType.eyes(LAYER); + float heat = animatable.getEntityData().get(HEAT) < 20 ? 0 : animatable.getEntityData().get(HEAT) - 20; + getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, heat / 80, heat / 80, heat / 80, 1); + } +} + diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/SpeedboatRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/SpeedboatRenderer.java index 9bda4090f..1a06934fb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/SpeedboatRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/SpeedboatRenderer.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.client.renderer.entity; +import com.atsuishio.superbwarfare.client.layer.SpeedBoatHeatLayer; import com.atsuishio.superbwarfare.client.layer.SpeedBoatLayer; import com.atsuishio.superbwarfare.client.layer.SpeedBoatPowerLayer; import com.atsuishio.superbwarfare.client.model.entity.SpeedboatModel; @@ -22,6 +23,7 @@ public class SpeedboatRenderer extends GeoEntityRenderer { super(renderManager, new SpeedboatModel()); this.addRenderLayer(new SpeedBoatLayer(this)); this.addRenderLayer(new SpeedBoatPowerLayer(this)); + this.addRenderLayer(new SpeedBoatHeatLayer(this)); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java index dacdcde63..1d930c1d5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java @@ -84,6 +84,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, public static final EntityDataAccessor POWER = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor ROTOR = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.INT); + public static final EntityDataAccessor HEAT = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.INT); protected static final EntityDataAccessor LAST_ATTACKER_UUID = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.STRING); public static final float MAX_HEALTH = CannonConfig.SPEEDBOAT_HP.get(); @@ -106,7 +107,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, public float turretYRotO; public float turretXRotO; - public float heat; public boolean cannotFire; public SpeedboatEntity(PlayMessages.SpawnEntity packet, Level world) { @@ -126,6 +126,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, this.entityData.define(POWER, 0f); this.entityData.define(ROTOR, 0f); this.entityData.define(COOL_DOWN, 0); + this.entityData.define(HEAT, 0); this.entityData.define(LAST_ATTACKER_UUID, "undefined"); } @@ -292,11 +293,11 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1); } - if (heat > 0) { - heat--; + if (this.entityData.get(HEAT) > 0) { + this.entityData.set(HEAT, this.entityData.get(HEAT) - 1); } - if (heat < 40) { + if (this.entityData.get(HEAT) < 40) { cannotFire = false; } @@ -305,7 +306,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, Entity driver = this.getFirstPassenger(); if (driver instanceof Player player) { - if (heat > 100) { + if (this.entityData.get(HEAT) > 100) { cannotFire = true; if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) { SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f); @@ -385,7 +386,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, (float) 0.4); this.level().addFreshEntity(projectile); - float pitch = heat <= 60 ? 1 : (float) (1 - 0.015 * java.lang.Math.abs(60 - heat)); + float pitch = this.entityData.get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - this.entityData.get(HEAT))); if (player instanceof ServerPlayer serverPlayer) { SoundTool.playLocalSound(serverPlayer, ModSounds.M_2_FIRE_1P.get(), 2, 1); @@ -399,12 +400,12 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) { if (target instanceof ServerPlayer serverPlayer) { - ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 7, this.getX(), this.getEyeY(), this.getZ())); + ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 5, this.getX(), this.getEyeY(), this.getZ())); } } if (level instanceof ServerLevel) { this.entityData.set(COOL_DOWN, 3); - heat += 4; + this.entityData.set(HEAT, this.entityData.get(HEAT) + 4); } this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1)); } diff --git a/src/main/resources/assets/superbwarfare/animations/speedboat.animation.json b/src/main/resources/assets/superbwarfare/animations/speedboat.animation.json index c08abfbda..56baa0323 100644 --- a/src/main/resources/assets/superbwarfare/animations/speedboat.animation.json +++ b/src/main/resources/assets/superbwarfare/animations/speedboat.animation.json @@ -26,12 +26,19 @@ "gun": { "position": { "0.0": [0, 0, 0], - "0.0083": [0, 0.05, 0.1], - "0.05": [0, -0.025, 0], - "0.075": [0, 0.05, 0.05], + "0.0083": [-0.035, 0.05, 0.1], + "0.05": [0.035, -0.025, 0], + "0.075": [-0.04, 0.05, 0.05], "0.0917": [0, 0, 0], "0.15": [0, 0, 0] } + }, + "action": { + "position": { + "0.0": [0, 0, 0], + "0.0083": [0, 0, 0.85], + "0.0667": [0, 0, 0] + } } } } diff --git a/src/main/resources/assets/superbwarfare/geo/speedboat.geo.json b/src/main/resources/assets/superbwarfare/geo/speedboat.geo.json index 6513810a6..2db111a50 100644 --- a/src/main/resources/assets/superbwarfare/geo/speedboat.geo.json +++ b/src/main/resources/assets/superbwarfare/geo/speedboat.geo.json @@ -382,7 +382,12 @@ { "name": "barrel", "parent": "gun", - "pivot": [-0.9802, 137.6418, 34.1014], + "pivot": [-0.9802, 137.6418, 34.1014] + }, + { + "name": "action", + "parent": "barrel", + "pivot": [0, 47.55715, -12.40832], "cubes": [ { "origin": [-0.22291, 47.02159, -19.62486], @@ -426,6 +431,114 @@ } ] }, + { + "name": "bone18", + "parent": "action", + "pivot": [0, 47.55715, -0.15721], + "rotation": [0, 180, 0], + "cubes": [ + { + "origin": [-0.31104, 46.80986, 3.84279], + "size": [0.62208, 1.49457, 1], + "pivot": [0, 47.55715, 8.89546], + "rotation": [0, 0, 22.5], + "uv": { + "south": {"uv": [3.5, 78.5], "uv_size": [0.25, 0.75]}, + "up": {"uv": [12, 78.5], "uv_size": [0.25, 0.5]}, + "down": {"uv": [19, 72], "uv_size": [0.25, -0.5]} + } + }, + { + "origin": [-0.31104, 46.80986, 3.84279], + "size": [0.62208, 1.49457, 1], + "pivot": [0, 47.55715, 8.89546], + "rotation": [0, 0, 67.5], + "uv": { + "south": {"uv": [4.5, 78.5], "uv_size": [0.25, 0.75]}, + "up": {"uv": [12.5, 78.5], "uv_size": [0.25, 0.5]}, + "down": {"uv": [19, 72.5], "uv_size": [0.25, -0.5]} + } + }, + { + "origin": [-0.31104, 46.80986, 3.84279], + "size": [0.62208, 1.49457, 1], + "pivot": [0, 47.55715, 8.89546], + "rotation": [0, 0, 112.5], + "uv": { + "south": {"uv": [5, 78.5], "uv_size": [0.25, 0.75]}, + "up": {"uv": [19, 72.5], "uv_size": [0.25, 0.5]}, + "down": {"uv": [19, 73.5], "uv_size": [0.25, -0.5]} + } + }, + { + "origin": [-0.31104, 46.80986, 3.84279], + "size": [0.62208, 1.49457, 1], + "pivot": [0, 47.55715, 8.89546], + "rotation": [0, 0, 157.5], + "uv": { + "south": {"uv": [5.5, 78.5], "uv_size": [0.25, 0.75]}, + "up": {"uv": [19, 73.5], "uv_size": [0.25, 0.5]}, + "down": {"uv": [19, 74.5], "uv_size": [0.25, -0.5]} + } + } + ] + }, + { + "name": "bone17", + "parent": "action", + "pivot": [0, 47.55715, -24.65721], + "rotation": [0, 180, 0], + "cubes": [ + { + "origin": [-0.25505, 46.94437, -29.67721], + "size": [0.51011, 1.22555, 2.46], + "pivot": [0, 47.55715, -28.44721], + "rotation": [0, 0, 22.5], + "uv": { + "north": {"uv": [19, 70.5], "uv_size": [0.25, 0.5]}, + "south": {"uv": [19, 71], "uv_size": [0.25, 0.5]}, + "up": {"uv": [12, 76.5], "uv_size": [0.25, 1.25]}, + "down": {"uv": [12.5, 77.75], "uv_size": [0.25, -1.25]} + } + }, + { + "origin": [-0.25505, 46.94437, -29.67721], + "size": [0.51011, 1.22555, 2.46], + "pivot": [0, 47.55715, -28.44721], + "rotation": [0, 0, 67.5], + "uv": { + "north": {"uv": [19, 69.5], "uv_size": [0.25, 0.5]}, + "south": {"uv": [10.5, 78.5], "uv_size": [0.25, 0.5]}, + "up": {"uv": [11, 76.5], "uv_size": [0.25, 1.25]}, + "down": {"uv": [11.5, 77.75], "uv_size": [0.25, -1.25]} + } + }, + { + "origin": [-0.25505, 46.94437, -29.67721], + "size": [0.51011, 1.22555, 2.46], + "pivot": [0, 47.55715, -28.44721], + "rotation": [0, 0, 112.5], + "uv": { + "north": {"uv": [19, 69], "uv_size": [0.25, 0.5]}, + "south": {"uv": [10, 78.5], "uv_size": [0.25, 0.5]}, + "up": {"uv": [10, 76.5], "uv_size": [0.25, 1.25]}, + "down": {"uv": [10.5, 77.75], "uv_size": [0.25, -1.25]} + } + }, + { + "origin": [-0.25505, 46.94437, -29.67721], + "size": [0.51011, 1.22555, 2.46], + "pivot": [0, 47.55715, -28.44721], + "rotation": [0, 0, 157.5], + "uv": { + "north": {"uv": [6, 78.5], "uv_size": [0.25, 0.5]}, + "south": {"uv": [19, 67], "uv_size": [0.25, 0.5]}, + "up": {"uv": [9, 76.5], "uv_size": [0.25, 1.25]}, + "down": {"uv": [9.5, 77.75], "uv_size": [0.25, -1.25]} + } + } + ] + }, { "name": "bone16", "parent": "barrel", @@ -629,114 +742,6 @@ } ] }, - { - "name": "bone17", - "parent": "barrel", - "pivot": [0, 47.55715, -24.65721], - "rotation": [0, 180, 0], - "cubes": [ - { - "origin": [-0.25505, 46.94437, -29.67721], - "size": [0.51011, 1.22555, 2.46], - "pivot": [0, 47.55715, -28.44721], - "rotation": [0, 0, 22.5], - "uv": { - "north": {"uv": [19, 70.5], "uv_size": [0.25, 0.5]}, - "south": {"uv": [19, 71], "uv_size": [0.25, 0.5]}, - "up": {"uv": [12, 76.5], "uv_size": [0.25, 1.25]}, - "down": {"uv": [12.5, 77.75], "uv_size": [0.25, -1.25]} - } - }, - { - "origin": [-0.25505, 46.94437, -29.67721], - "size": [0.51011, 1.22555, 2.46], - "pivot": [0, 47.55715, -28.44721], - "rotation": [0, 0, 67.5], - "uv": { - "north": {"uv": [19, 69.5], "uv_size": [0.25, 0.5]}, - "south": {"uv": [10.5, 78.5], "uv_size": [0.25, 0.5]}, - "up": {"uv": [11, 76.5], "uv_size": [0.25, 1.25]}, - "down": {"uv": [11.5, 77.75], "uv_size": [0.25, -1.25]} - } - }, - { - "origin": [-0.25505, 46.94437, -29.67721], - "size": [0.51011, 1.22555, 2.46], - "pivot": [0, 47.55715, -28.44721], - "rotation": [0, 0, 112.5], - "uv": { - "north": {"uv": [19, 69], "uv_size": [0.25, 0.5]}, - "south": {"uv": [10, 78.5], "uv_size": [0.25, 0.5]}, - "up": {"uv": [10, 76.5], "uv_size": [0.25, 1.25]}, - "down": {"uv": [10.5, 77.75], "uv_size": [0.25, -1.25]} - } - }, - { - "origin": [-0.25505, 46.94437, -29.67721], - "size": [0.51011, 1.22555, 2.46], - "pivot": [0, 47.55715, -28.44721], - "rotation": [0, 0, 157.5], - "uv": { - "north": {"uv": [6, 78.5], "uv_size": [0.25, 0.5]}, - "south": {"uv": [19, 67], "uv_size": [0.25, 0.5]}, - "up": {"uv": [9, 76.5], "uv_size": [0.25, 1.25]}, - "down": {"uv": [9.5, 77.75], "uv_size": [0.25, -1.25]} - } - } - ] - }, - { - "name": "bone18", - "parent": "barrel", - "pivot": [0, 47.55715, -0.15721], - "rotation": [0, 180, 0], - "cubes": [ - { - "origin": [-0.31104, 46.80986, 3.84279], - "size": [0.62208, 1.49457, 1], - "pivot": [0, 47.55715, 8.89546], - "rotation": [0, 0, 22.5], - "uv": { - "south": {"uv": [3.5, 78.5], "uv_size": [0.25, 0.75]}, - "up": {"uv": [12, 78.5], "uv_size": [0.25, 0.5]}, - "down": {"uv": [19, 72], "uv_size": [0.25, -0.5]} - } - }, - { - "origin": [-0.31104, 46.80986, 3.84279], - "size": [0.62208, 1.49457, 1], - "pivot": [0, 47.55715, 8.89546], - "rotation": [0, 0, 67.5], - "uv": { - "south": {"uv": [4.5, 78.5], "uv_size": [0.25, 0.75]}, - "up": {"uv": [12.5, 78.5], "uv_size": [0.25, 0.5]}, - "down": {"uv": [19, 72.5], "uv_size": [0.25, -0.5]} - } - }, - { - "origin": [-0.31104, 46.80986, 3.84279], - "size": [0.62208, 1.49457, 1], - "pivot": [0, 47.55715, 8.89546], - "rotation": [0, 0, 112.5], - "uv": { - "south": {"uv": [5, 78.5], "uv_size": [0.25, 0.75]}, - "up": {"uv": [19, 72.5], "uv_size": [0.25, 0.5]}, - "down": {"uv": [19, 73.5], "uv_size": [0.25, -0.5]} - } - }, - { - "origin": [-0.31104, 46.80986, 3.84279], - "size": [0.62208, 1.49457, 1], - "pivot": [0, 47.55715, 8.89546], - "rotation": [0, 0, 157.5], - "uv": { - "south": {"uv": [5.5, 78.5], "uv_size": [0.25, 0.75]}, - "up": {"uv": [19, 73.5], "uv_size": [0.25, 0.5]}, - "down": {"uv": [19, 74.5], "uv_size": [0.25, -0.5]} - } - } - ] - }, { "name": "bone19", "parent": "barrel", diff --git a/src/main/resources/assets/superbwarfare/textures/entity/speedboat_heat.png b/src/main/resources/assets/superbwarfare/textures/entity/speedboat_heat.png new file mode 100644 index 0000000000000000000000000000000000000000..c37506442854c61c00b525eec9b2bd2ef9a4acef GIT binary patch literal 1391 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&zE~)R&4Yzkn2Dage(c!@6@aFBuqEH9cJ% zLn`LHy=(1v*g=H#f_Wj2h9IxgBA2Gt3mY@a4od|rVECh9u)nRRy(i<`OQqQ3OW*I2 zR2KxAGYSZYfP?tbuZL#8RqGF5-EpF$V@LIkzrSL)FTefgUuC=;!;AF0RS%CE9QkSB za!&VAp8vlpTeq37oqT~Z%Xc!&>3w};N@!`FHP71ZObmQ$b}~%qsW_u)^x90Q?D7{o z#uaCn8UC7xH!RnDT)b?);Pl5cygxA<_@AlAusgFW=$UA3yA8ty|KBVM#c?OEpZzlZ z8Dm4;KLf^!-t{xsLh&UmqlTbj$thzt5>f#z-zZ@8{m zx93Lv1E3-2@2fF<-d4AA#w)NK(9Y?t$A5wioW*_M;wqQQ`&ave3@^veVrTdTw12in zpw~?PuW#!Yz|>FfzyEE$&9(YR`w55HsEW}L7-S*vV8K0x*Pru0C|%{V0Xfan)z4*} HQ$iB}Is>>z literal 0 HcmV?d00001