From 43e5ca19a8f9a4e2bc4a7ad43559a1b4d6f87e8a Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Thu, 11 Jul 2024 15:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96minigun=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/model/item/MinigunItemModel.java | 8 ++--- .../net/mcreator/target/item/gun/Minigun.java | 31 +++++++------------ 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/main/java/net/mcreator/target/client/model/item/MinigunItemModel.java b/src/main/java/net/mcreator/target/client/model/item/MinigunItemModel.java index 4af8705c1..417234aa7 100644 --- a/src/main/java/net/mcreator/target/client/model/item/MinigunItemModel.java +++ b/src/main/java/net/mcreator/target/client/model/item/MinigunItemModel.java @@ -47,7 +47,7 @@ public class MinigunItemModel extends GeoModel { } float times = 250f / fps; - float heat = (float)stack.getOrCreateTag().getDouble("heat"); + float heat = (float) stack.getOrCreateTag().getDouble("heat"); heat_barrels.setScaleZ(4 * heat); @@ -61,7 +61,7 @@ public class MinigunItemModel extends GeoModel { shen.setPosZ(2.2f * (float) (0.5 * fp + 1.54f * fr)); shen.setRotX(0.05f * (float) (0.18f * fp + fr)); shen.setRotZ(-0.02f * (float) (fp + 1.3 * fr)); - shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon * fp)); + shen.setPosX(0.5f * (float) fr * (float) ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon * fp)); if (stack.getOrCreateTag().getInt("fire_animation") > 0) { flare.setHidden(false); @@ -77,8 +77,8 @@ public class MinigunItemModel extends GeoModel { CoreGeoBone root = getAnimationProcessor().getBone("root"); - float PosX = (float)player.getPersistentData().getDouble("gun_move_posX"); - float PosY = (float)player.getPersistentData().getDouble("gun_move_posY"); + float PosX = (float) player.getPersistentData().getDouble("gun_move_posX"); + float PosY = (float) player.getPersistentData().getDouble("gun_move_posY"); double y = 0; double x = 0; diff --git a/src/main/java/net/mcreator/target/item/gun/Minigun.java b/src/main/java/net/mcreator/target/item/gun/Minigun.java index 1b16593ff..a8e50a4ef 100644 --- a/src/main/java/net/mcreator/target/item/gun/Minigun.java +++ b/src/main/java/net/mcreator/target/item/gun/Minigun.java @@ -46,7 +46,7 @@ import java.util.UUID; import java.util.function.Consumer; public class Minigun extends GunItem implements GeoItem, AnimatedItem { - private static final String TAG_HEAT = "heat_bar"; + private static final String TAG_HEAT = "heat"; private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public String animationProcedure = "empty"; public static ItemDisplayContext transformType; @@ -57,17 +57,18 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem { @Override public boolean isBarVisible(ItemStack pStack) { - return ItemNBTTool.getInt(pStack, TAG_HEAT, 0) != 51; + return ItemNBTTool.getDouble(pStack, TAG_HEAT, 0) != 0; } @Override public int getBarWidth(ItemStack pStack) { - return Math.round((float) ItemNBTTool.getInt(pStack, TAG_HEAT, 0) * 13.0F / 51F); + return Math.round((float) ItemNBTTool.getDouble(pStack, TAG_HEAT, 0) * 13.0F / 51F); } @Override public int getBarColor(ItemStack pStack) { - return 0xFF0000; + double f = 1 - ItemNBTTool.getDouble(pStack, TAG_HEAT, 0) / 55.0F; + return Mth.hsvToRgb((float) f / 3.0F, 1.0F, 1.0F); } @Override @@ -82,8 +83,7 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem { } private static final HumanoidModel.ArmPose MinigunPose = HumanoidModel.ArmPose.create("Minigun", false, (model, entity, arm) -> { - if (arm == HumanoidArm.LEFT) { - } else { + if (arm != HumanoidArm.LEFT) { model.rightArm.xRot = -0.2F + model.head.xRot; model.rightArm.yRot = -0.2F; model.leftArm.xRot = -1F + model.head.xRot; @@ -108,7 +108,7 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem { transformType = type; } - private PlayState idlePredicate(AnimationState event) { + private PlayState idlePredicate(AnimationState event) { LocalPlayer player = Minecraft.getInstance().player; if (player == null) return PlayState.STOP; ItemStack stack = player.getMainHandItem(); @@ -128,7 +128,7 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem { return PlayState.STOP; } - private PlayState procedurePredicate(AnimationState event) { + private PlayState procedurePredicate(AnimationState event) { if (transformType != null && transformType.firstPerson()) { if (!this.animationProcedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) { event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationProcedure)); @@ -186,25 +186,18 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem { @Override public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) { super.inventoryTick(itemstack, world, entity, slot, selected); - if (entity == null) - return; double cooldown = 0; - if(entity.wasInPowderSnow){ + if (entity.wasInPowderSnow) { cooldown = 0.75; - } else if (entity.isInWaterOrRain()){ + } else if (entity.isInWaterOrRain()) { cooldown = 0.2; - } else if (entity.isOnFire() || entity.isInLava()){ + } else if (entity.isOnFire() || entity.isInLava()) { cooldown = -0.5; } - itemstack.getOrCreateTag().putDouble("heat", Mth.clamp(itemstack.getOrCreateTag().getDouble("heat") - 0.25 - cooldown,0,55)); + itemstack.getOrCreateTag().putDouble("heat", Mth.clamp(itemstack.getOrCreateTag().getDouble("heat") - 0.25 - cooldown, 0, 55)); - if (itemstack.getOrCreateTag().getDouble("heat") == 0) { - itemstack.getOrCreateTag().putDouble("heat_bar", 51); - } else { - itemstack.getOrCreateTag().putDouble("heat_bar", (itemstack.getOrCreateTag().getDouble("heat"))); - } if (itemstack.getOrCreateTag().getDouble("overheat") > 0) { itemstack.getOrCreateTag().putDouble("overheat", (itemstack.getOrCreateTag().getDouble("overheat") - 1)); }