From d16a6b29ad1f719e5d4b061e902dab07590d5a69 Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Thu, 26 Dec 2024 18:43:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=90=86=E8=AE=BA=E4=B8=8A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BA=86=E8=BD=BD=E5=85=B7=E7=B1=BB=E6=97=8B=E8=BD=AC=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/client/ClickHandler.java | 4 +- .../client/layer/SpeedBoatHeatLayer.java | 10 +-- .../client/layer/SpeedBoatLayer.java | 8 +- .../client/layer/SpeedBoatPowerLayer.java | 10 +-- .../client/model/entity/SpeedboatModel.java | 14 ++-- .../client/model/entity/WheelChairModel.java | 10 +-- .../renderer/entity/SpeedboatRenderer.java | 14 ++-- .../renderer/entity/WheelChairRenderer.java | 15 ++-- .../client/screens/VehicleHudOverlay.java | 4 +- .../client/screens/VehicleMgHudOverlay.java | 4 +- .../entity/AnnihilatorEntity.java | 44 ++++------- .../superbwarfare/entity/Mk42Entity.java | 25 +------ .../superbwarfare/entity/Mle1934Entity.java | 28 +------ .../entity/MobileVehicleEntity.java | 75 ++++++++++++------- ...EntityMobile.java => SpeedboatEntity.java} | 36 ++++----- ...ntityMobile.java => WheelChairEntity.java} | 35 +++------ .../event/ClientEventHandler.java | 10 +-- .../superbwarfare/init/ModEntities.java | 8 +- .../superbwarfare/mixins/CameraMixin.java | 4 +- 19 files changed, 149 insertions(+), 209 deletions(-) rename src/main/java/com/atsuishio/superbwarfare/entity/{SpeedboatEntityMobile.java => SpeedboatEntity.java} (95%) rename src/main/java/com/atsuishio/superbwarfare/entity/{WheelChairEntityMobile.java => WheelChairEntity.java} (84%) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java index 92e4d3713..7769d17a4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/ClickHandler.java @@ -7,7 +7,7 @@ import com.atsuishio.superbwarfare.config.client.ReloadConfig; import com.atsuishio.superbwarfare.entity.ICannonEntity; import com.atsuishio.superbwarfare.entity.IVehicleEntity; import com.atsuishio.superbwarfare.entity.MortarEntity; -import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile; +import com.atsuishio.superbwarfare.entity.SpeedboatEntity; import com.atsuishio.superbwarfare.event.ClientEventHandler; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.ModVariables; @@ -107,7 +107,7 @@ public class ClickHandler { if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) { if (stack.is(ModTags.Items.GUN) || (player.isPassenger() && player.getVehicle() instanceof ICannonEntity) - || (player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntityMobile boat && boat.getFirstPassenger() == player && stack.is(ItemStack.EMPTY.getItem()))) { + || (player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player && stack.is(ItemStack.EMPTY.getItem()))) { event.setCanceled(true); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatHeatLayer.java b/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatHeatLayer.java index 851fdeeb5..4c5aa312f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatHeatLayer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatHeatLayer.java @@ -1,7 +1,7 @@ package com.atsuishio.superbwarfare.client.layer; import com.atsuishio.superbwarfare.ModUtils; -import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile; +import com.atsuishio.superbwarfare.entity.SpeedboatEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.renderer.MultiBufferSource; @@ -12,17 +12,17 @@ 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.SpeedboatEntityMobile.HEAT; +import static com.atsuishio.superbwarfare.entity.SpeedboatEntity.HEAT; -public class SpeedBoatHeatLayer extends GeoRenderLayer { +public class SpeedBoatHeatLayer extends GeoRenderLayer { private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_heat.png"); - public SpeedBoatHeatLayer(GeoRenderer entityRenderer) { + public SpeedBoatHeatLayer(GeoRenderer entityRenderer) { super(entityRenderer); } @Override - public void render(PoseStack poseStack, SpeedboatEntityMobile animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { + 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/layer/SpeedBoatLayer.java b/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatLayer.java index 400f06720..18fe23f42 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatLayer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatLayer.java @@ -1,7 +1,7 @@ package com.atsuishio.superbwarfare.client.layer; import com.atsuishio.superbwarfare.ModUtils; -import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile; +import com.atsuishio.superbwarfare.entity.SpeedboatEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.renderer.MultiBufferSource; @@ -12,16 +12,16 @@ import software.bernie.geckolib.cache.object.BakedGeoModel; import software.bernie.geckolib.renderer.GeoRenderer; import software.bernie.geckolib.renderer.layer.GeoRenderLayer; -public class SpeedBoatLayer extends GeoRenderLayer { +public class SpeedBoatLayer extends GeoRenderLayer { private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_e.png"); - public SpeedBoatLayer(GeoRenderer entityRenderer) { + public SpeedBoatLayer(GeoRenderer entityRenderer) { super(entityRenderer); } @Override - public void render(PoseStack poseStack, SpeedboatEntityMobile animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { + public void render(PoseStack poseStack, SpeedboatEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { RenderType glowRenderType = RenderType.energySwirl(LAYER,1,1); getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1); } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatPowerLayer.java b/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatPowerLayer.java index f25653ae3..397894419 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatPowerLayer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/layer/SpeedBoatPowerLayer.java @@ -1,7 +1,7 @@ package com.atsuishio.superbwarfare.client.layer; import com.atsuishio.superbwarfare.ModUtils; -import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile; +import com.atsuishio.superbwarfare.entity.SpeedboatEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.renderer.MultiBufferSource; @@ -12,18 +12,18 @@ 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.SpeedboatEntityMobile.ENERGY; +import static com.atsuishio.superbwarfare.entity.SpeedboatEntity.ENERGY; -public class SpeedBoatPowerLayer extends GeoRenderLayer { +public class SpeedBoatPowerLayer extends GeoRenderLayer { private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_power.png"); - public SpeedBoatPowerLayer(GeoRenderer entityRenderer) { + public SpeedBoatPowerLayer(GeoRenderer entityRenderer) { super(entityRenderer); } @Override - public void render(PoseStack poseStack, SpeedboatEntityMobile animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { + public void render(PoseStack poseStack, SpeedboatEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { if (animatable.getEntityData().get(ENERGY) <= 0) return; RenderType glowRenderType = RenderType.eyes(LAYER); getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/entity/SpeedboatModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/SpeedboatModel.java index ffae227bf..a0999b882 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/entity/SpeedboatModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/SpeedboatModel.java @@ -1,33 +1,33 @@ package com.atsuishio.superbwarfare.client.model.entity; import com.atsuishio.superbwarfare.ModUtils; -import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile; +import com.atsuishio.superbwarfare.entity.SpeedboatEntity; import net.minecraft.resources.ResourceLocation; import software.bernie.geckolib.core.animatable.model.CoreGeoBone; import software.bernie.geckolib.core.animation.AnimationState; import software.bernie.geckolib.model.GeoModel; -import static com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile.*; +import static com.atsuishio.superbwarfare.entity.SpeedboatEntity.*; -public class SpeedboatModel extends GeoModel { +public class SpeedboatModel extends GeoModel { @Override - public ResourceLocation getAnimationResource(SpeedboatEntityMobile entity) { + public ResourceLocation getAnimationResource(SpeedboatEntity entity) { return ModUtils.loc("animations/speedboat.animation.json"); } @Override - public ResourceLocation getModelResource(SpeedboatEntityMobile entity) { + public ResourceLocation getModelResource(SpeedboatEntity entity) { return new ResourceLocation(ModUtils.MODID, "geo/speedboat.geo.json"); } @Override - public ResourceLocation getTextureResource(SpeedboatEntityMobile entity) { + public ResourceLocation getTextureResource(SpeedboatEntity entity) { return ModUtils.loc("textures/entity/speedboat.png"); } @Override - public void setCustomAnimations(SpeedboatEntityMobile animatable, long instanceId, AnimationState animationState) { + public void setCustomAnimations(SpeedboatEntity animatable, long instanceId, AnimationState animationState) { CoreGeoBone rotor = getAnimationProcessor().getBone("Rotor"); CoreGeoBone duo = getAnimationProcessor().getBone("duo"); diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/entity/WheelChairModel.java b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/WheelChairModel.java index 1bcff7bf6..ae38a6830 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/entity/WheelChairModel.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/WheelChairModel.java @@ -1,25 +1,25 @@ package com.atsuishio.superbwarfare.client.model.entity; import com.atsuishio.superbwarfare.ModUtils; -import com.atsuishio.superbwarfare.entity.WheelChairEntityMobile; +import com.atsuishio.superbwarfare.entity.WheelChairEntity; import net.minecraft.resources.ResourceLocation; import software.bernie.geckolib.model.GeoModel; -public class WheelChairModel extends GeoModel { +public class WheelChairModel extends GeoModel { @Override - public ResourceLocation getAnimationResource(WheelChairEntityMobile entity) { + public ResourceLocation getAnimationResource(WheelChairEntity entity) { return null; // return ModUtils.loc("animations/wheel_chair.animation.json"); } @Override - public ResourceLocation getModelResource(WheelChairEntityMobile entity) { + public ResourceLocation getModelResource(WheelChairEntity entity) { return new ResourceLocation(ModUtils.MODID, "geo/wheel_chair.geo.json"); } @Override - public ResourceLocation getTextureResource(WheelChairEntityMobile entity) { + public ResourceLocation getTextureResource(WheelChairEntity entity) { return ModUtils.loc("textures/entity/wheel_chair.png"); } } 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 929b50dbd..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 @@ -4,7 +4,7 @@ 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; -import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile; +import com.atsuishio.superbwarfare.entity.SpeedboatEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; @@ -17,7 +17,7 @@ import software.bernie.geckolib.cache.object.BakedGeoModel; import software.bernie.geckolib.cache.object.GeoBone; import software.bernie.geckolib.renderer.GeoEntityRenderer; -public class SpeedboatRenderer extends GeoEntityRenderer { +public class SpeedboatRenderer extends GeoEntityRenderer { public SpeedboatRenderer(EntityRendererProvider.Context renderManager) { super(renderManager, new SpeedboatModel()); @@ -27,12 +27,12 @@ public class SpeedboatRenderer extends GeoEntityRenderer } @Override - public RenderType getRenderType(SpeedboatEntityMobile animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) { + public RenderType getRenderType(SpeedboatEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) { return RenderType.entityTranslucent(getTextureLocation(animatable)); } @Override - public void preRender(PoseStack poseStack, SpeedboatEntityMobile entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green, + public void preRender(PoseStack poseStack, SpeedboatEntity entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { float scale = 1f; this.scaleHeight = scale; @@ -41,7 +41,7 @@ public class SpeedboatRenderer extends GeoEntityRenderer } @Override - public void render(SpeedboatEntityMobile entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) { + public void render(SpeedboatEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) { poseStack.pushPose(); poseStack.mulPose(Axis.YP.rotationDegrees(-Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()))); super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn); @@ -49,7 +49,7 @@ public class SpeedboatRenderer extends GeoEntityRenderer } @Override - public void renderRecursively(PoseStack poseStack, SpeedboatEntityMobile animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { + public void renderRecursively(PoseStack poseStack, SpeedboatEntity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { String name = bone.getName(); if (name.equals("paota")) { bone.setRotY(Mth.lerp(partialTick, animatable.turretYRotO, animatable.getTurretYRot()) * Mth.DEG_TO_RAD); @@ -64,7 +64,7 @@ public class SpeedboatRenderer extends GeoEntityRenderer } @Override - protected float getDeathMaxRotation(SpeedboatEntityMobile entityLivingBaseIn) { + protected float getDeathMaxRotation(SpeedboatEntity entityLivingBaseIn) { return 0.0F; } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/WheelChairRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/WheelChairRenderer.java index 6131dd0ec..617357346 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/WheelChairRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/WheelChairRenderer.java @@ -1,7 +1,7 @@ package com.atsuishio.superbwarfare.client.renderer.entity; import com.atsuishio.superbwarfare.client.model.entity.WheelChairModel; -import com.atsuishio.superbwarfare.entity.WheelChairEntityMobile; +import com.atsuishio.superbwarfare.entity.WheelChairEntity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; @@ -9,13 +9,10 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; import software.bernie.geckolib.cache.object.BakedGeoModel; import software.bernie.geckolib.renderer.GeoEntityRenderer; -; - -public class WheelChairRenderer extends GeoEntityRenderer { +public class WheelChairRenderer extends GeoEntityRenderer { public WheelChairRenderer(EntityRendererProvider.Context renderManager) { super(renderManager, new WheelChairModel()); @@ -23,12 +20,12 @@ public class WheelChairRenderer extends GeoEntityRenderer LASER_RIGHT_LENGTH = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor ENERGY = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor OFFSET_ANGLE = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor ROT_Y = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT); - private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public static final float MAX_HEALTH = CannonConfig.ANNIHILATOR_HP.get(); @@ -90,7 +89,6 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit this.entityData.define(LASER_RIGHT_LENGTH, 0f); this.entityData.define(ENERGY, 0f); this.entityData.define(OFFSET_ANGLE, 0f); - this.entityData.define(ROT_Y, 0f); } @Override @@ -258,8 +256,14 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit } } - if (this.level() instanceof ServerLevel) { - this.entityData.set(ROT_Y, this.getYRot()); + float delta = Math.abs(getYRot() - yRotO); + while (getYRot() > 180F) { + setYRot(getYRot() - 360F); + yRotO = getYRot() - delta; + } + while (getYRot() <= -180F) { + setYRot(getYRot() + 360F); + yRotO = delta + getYRot(); } if (this.entityData.get(HEALTH) <= 0) { @@ -468,27 +472,13 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit this.entityData.set(OFFSET_ANGLE, (float) calculateAngle(entity.getViewVector(1), barrelLookAt)); - float passengerY = entity.getYHeadRot(); - - if (passengerY > 180.0f) { - passengerY -= 360.0f; - } else if (passengerY < -180.0f) { - passengerY += 360.0f; - } - - float diffY = passengerY - this.getYRot(); + float diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(entity.getYHeadRot() - this.getYRot())); float diffX = entity.getXRot() - this.entityData.get(OFFSET_ANGLE) - this.getXRot(); - if (diffY > 180.0f) { - diffY -= 360.0f; - } else if (diffY < -180.0f) { - diffY += 360.0f; - } - diffY = Mth.clamp(diffY * 0.15f, -0.6f, 0.6f); + diffX = diffX * 0.15f; - this.setYRot(this.entityData.get(ROT_Y) + diffY); + this.setYRot(this.getYRot() + Mth.clamp(0.5f * diffY,-0.6f, 0.6f)); this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -2f, 2f), -45, 5f + this.entityData.get(OFFSET_ANGLE))); - this.setRot(this.getYRot(), this.getXRot()); } public void autoAim() { @@ -517,15 +507,9 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit this.setXRot(Mth.wrapDegrees((float) (-(Mth.atan2(d1, d3) * 57.2957763671875)))); float targetY = Mth.wrapDegrees((float) (Mth.atan2(d2, d0) * 57.2957763671875) - 90.0F); - float diffY = targetY - this.getYRot(); - if (diffY > 180.0f) { - diffY -= 360.0f; - } else if (diffY < -180.0f) { - diffY += 360.0f; - } - diffY = Mth.clamp(diffY * 0.15f, -1f, 1f); + float diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(targetY - this.getYRot())); - this.setYRot(this.getYRot() + diffY); + this.setYRot(this.getYRot() + Mth.clamp(0.5f * diffY,-1f, 1f)); this.setRot(this.getYRot(), this.getXRot()); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java index 77d137050..158d63ddb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java @@ -38,6 +38,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PlayMessages; +import org.joml.Math; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; import software.bernie.geckolib.core.animation.AnimatableManager; @@ -53,7 +54,6 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor ROT_Y = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public static final float MAX_HEALTH = CannonConfig.MK42_HP.get(); @@ -74,7 +74,6 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { protected void defineSynchedData() { this.entityData.define(COOL_DOWN, 0); this.entityData.define(HEALTH, MAX_HEALTH); - this.entityData.define(ROT_Y, 0f); } @Override @@ -248,10 +247,6 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { destroy(); } - if (this.level() instanceof ServerLevel) { - this.entityData.set(ROT_Y, this.getYRot()); - } - travel(); this.refreshDimensions(); } @@ -374,27 +369,13 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { if (!(passenger instanceof LivingEntity entity)) return; - float passengerY = entity.getYHeadRot(); + float diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(entity.getYHeadRot() - this.getYRot())); - if (passengerY > 180.0f) { - passengerY -= 360.0f; - } else if (passengerY < -180.0f) { - passengerY += 360.0f; - } - - float diffY = passengerY - this.getYRot(); float diffX = entity.getXRot() - 1.3f - this.getXRot(); - if (diffY > 180.0f) { - diffY -= 360.0f; - } else if (diffY < -180.0f) { - diffY += 360.0f; - } - diffY = Mth.clamp(diffY * 0.15f, -1.75f, 1.75f); diffX = diffX * 0.15f; - this.setYRot(this.entityData.get(ROT_Y) + diffY); + this.setYRot(this.getYRot() + Mth.clamp(0.5f * diffY,-1.75f, 1.75f)); this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -3f, 3f), -85, 16.3f)); - this.setRot(this.getYRot(), this.getXRot()); } protected void clampRotation(Entity entity) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java index f2eb48df9..2e29bbdea 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java @@ -38,6 +38,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PlayMessages; +import org.joml.Math; import org.joml.Vector3d; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; @@ -55,7 +56,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor TYPE = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor ROT_Y = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public static final float MAX_HEALTH = CannonConfig.MLE1934_HP.get(); @@ -77,8 +77,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { this.entityData.define(COOL_DOWN, 0); this.entityData.define(TYPE, 0); this.entityData.define(HEALTH, MAX_HEALTH); - this.entityData.define(HEALTH, MAX_HEALTH); - this.entityData.define(ROT_Y, 0f); } @Override @@ -263,10 +261,6 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { destroy(); } - if (this.level() instanceof ServerLevel) { - this.entityData.set(ROT_Y, this.getYRot()); - } - travel(); this.refreshDimensions(); } @@ -467,27 +461,13 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); if (!(passenger instanceof LivingEntity entity)) return; - float passengerY = entity.getYHeadRot(); - - if (passengerY > 180.0f) { - passengerY -= 360.0f; - } else if (passengerY < -180.0f) { - passengerY += 360.0f; - } - - float diffY = passengerY - this.getYRot(); + float diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(entity.getYHeadRot() - this.getYRot())); float diffX = entity.getXRot() - 1.2f - this.getXRot(); - if (diffY > 180.0f) { - diffY -= 360.0f; - } else if (diffY < -180.0f) { - diffY += 360.0f; - } - diffY = Mth.clamp(diffY * 0.15f, -1.25f, 1.25f); + diffX = diffX * 0.15f; - this.setYRot(this.entityData.get(ROT_Y) + diffY); + this.setYRot(this.getYRot() + Mth.clamp(0.5f * diffY,-1.25f, 1.25f)); this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -2f, 2f), -30, 4)); - this.setRot(this.getYRot(), this.getXRot()); } protected void clampRotation(Entity entity) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/MobileVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/MobileVehicleEntity.java index 1d2d57f48..076cc73e9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/MobileVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/MobileVehicleEntity.java @@ -10,12 +10,17 @@ import org.joml.Math; public class MobileVehicleEntity extends Entity { - protected int lerpSteps; - protected double lerpX; - protected double lerpY; - protected double lerpZ; - protected double lerpYRot; - protected double lerpXRot; + protected int interpolationSteps; + + protected double x; + protected double y; + protected double z; + + protected double serverYRot; + protected double serverXRot; + + public float roll; + public boolean leftInputDown; public boolean rightInputDown; public boolean forwardInputDown; @@ -36,37 +41,49 @@ public class MobileVehicleEntity extends Entity { public void baseTick() { super.baseTick(); - tickLerp(); + float delta = Math.abs(getYRot() - yRotO); + while (getYRot() > 180F) { + setYRot(getYRot() - 360F); + yRotO = getYRot() - delta; + } + while (getYRot() <= -180F) { + setYRot(getYRot() + 360F); + yRotO = delta + getYRot(); + } + + handleClientSync(); this.refreshDimensions(); } - private void tickLerp() { - if (this.isControlledByLocalInstance()) { - this.lerpSteps = 0; - this.syncPacketPositionCodec(this.getX(), this.getY(), this.getZ()); + protected void handleClientSync() { + if (isControlledByLocalInstance()) { + interpolationSteps = 0; + syncPacketPositionCodec(getX(), getY(), getZ()); } + if (interpolationSteps <= 0) { + return; + } + double interpolatedX = getX() + (x - getX()) / (double) interpolationSteps; + double interpolatedY = getY() + (y - getY()) / (double) interpolationSteps; + double interpolatedZ = getZ() + (z - getZ()) / (double) interpolationSteps; + double interpolatedYaw = Mth.wrapDegrees(serverYRot - (double) getYRot()); + setYRot(getYRot() + (float) interpolatedYaw / (float) interpolationSteps); + setXRot(getXRot() + (float) (serverXRot - (double) getXRot()) / (float) interpolationSteps); - if (this.lerpSteps > 0) { - double d0 = this.getX() + (this.lerpX - this.getX()) / (double) this.lerpSteps; - double d1 = this.getY() + (this.lerpY - this.getY()) / (double) this.lerpSteps; - double d2 = this.getZ() + (this.lerpZ - this.getZ()) / (double) this.lerpSteps; - double d3 = Mth.wrapDegrees(this.lerpYRot - (double) this.getYRot()); - this.setYRot(this.getYRot() + (float) d3 / (float) this.lerpSteps); - this.setXRot(this.getXRot() + (float) (this.lerpXRot - (double) this.getXRot()) / (float) this.lerpSteps); - --this.lerpSteps; - this.setPos(d0, d1, d2); - this.setRot(this.getYRot(), this.getXRot()); - } + setPos(interpolatedX, interpolatedY, interpolatedZ); + setRot(getYRot(), getXRot()); + + --interpolationSteps; } @Override - public void lerpTo(double pX, double pY, double pZ, float pYaw, float pPitch, int pPosRotationIncrements, boolean pTeleport) { - this.lerpX = pX; - this.lerpY = pY; - this.lerpZ = pZ; - this.lerpYRot = (double)pYaw; - this.lerpXRot = (double)pPitch; - this.lerpSteps = 10; + public void lerpTo(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) { + this.x = x; + this.y = y; + this.z = z; + serverYRot = yaw; + serverXRot = pitch; + this.interpolationSteps = 10; } public static double calculateAngle(Vec3 move, Vec3 view) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntityMobile.java b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java similarity index 95% rename from src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntityMobile.java rename to src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java index 750795a52..dd499241f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntityMobile.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java @@ -83,18 +83,17 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; -public class SpeedboatEntityMobile extends MobileVehicleEntity implements GeoEntity, IChargeEntity, IVehicleEntity, HasCustomInventoryScreen, ContainerEntity { +public class SpeedboatEntity extends MobileVehicleEntity implements GeoEntity, IChargeEntity, IVehicleEntity, HasCustomInventoryScreen, ContainerEntity { - public static final EntityDataAccessor FIRE_ANIM = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.INT); - public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor ENERGY = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor ROT_Y = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor DELTA_ROT = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor POWER = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor ROTOR = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor HEAT = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.INT); - protected static final EntityDataAccessor LAST_ATTACKER_UUID = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.STRING); - public static final EntityDataAccessor AMMO = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.INT); + public static final EntityDataAccessor FIRE_ANIM = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.INT); + public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT); + public static final EntityDataAccessor ENERGY = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT); + public static final EntityDataAccessor DELTA_ROT = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT); + 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 HEAT = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.INT); + protected static final EntityDataAccessor LAST_ATTACKER_UUID = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.STRING); + public static final EntityDataAccessor AMMO = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.INT); public static final float MAX_HEALTH = CannonConfig.SPEEDBOAT_HP.get(); public static final float MAX_ENERGY = CannonConfig.SPEEDBOAT_MAX_ENERGY.get().floatValue(); @@ -112,11 +111,11 @@ public class SpeedboatEntityMobile extends MobileVehicleEntity implements GeoEnt public boolean cannotFire; - public SpeedboatEntityMobile(PlayMessages.SpawnEntity packet, Level world) { + public SpeedboatEntity(PlayMessages.SpawnEntity packet, Level world) { this(ModEntities.SPEEDBOAT.get(), world); } - public SpeedboatEntityMobile(EntityType type, Level world) { + public SpeedboatEntity(EntityType type, Level world) { super(type, world); } @@ -126,7 +125,6 @@ public class SpeedboatEntityMobile extends MobileVehicleEntity implements GeoEnt this.entityData.define(FIRE_ANIM, 0); this.entityData.define(HEALTH, MAX_HEALTH); this.entityData.define(ENERGY, 0f); - this.entityData.define(ROT_Y, 0f); this.entityData.define(DELTA_ROT, 0f); this.entityData.define(POWER, 0f); this.entityData.define(ROTOR, 0f); @@ -330,10 +328,6 @@ public class SpeedboatEntityMobile extends MobileVehicleEntity implements GeoEnt this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.85, f)); } - if (this.level() instanceof ServerLevel) { - this.entityData.set(ROT_Y, this.getYRot()); - } - this.entityData.set(HEALTH, java.lang.Math.min(this.entityData.get(HEALTH) + 0.05f, MAX_HEALTH)); if (this.entityData.get(HEALTH) <= 0) { @@ -533,8 +527,8 @@ public class SpeedboatEntityMobile extends MobileVehicleEntity implements GeoEnt this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.8f); if (this.isInWater() || this.isUnderWater()) { - this.setYRot(this.entityData.get(ROT_Y) - this.entityData.get(DELTA_ROT)); - this.setDeltaMovement(this.getDeltaMovement().add(new Vec3(this.getLookAngle().x, 0, this.getLookAngle().z).scale(this.entityData.get(POWER)))); + this.setYRot(this.getYRot() - this.entityData.get(DELTA_ROT)); + this.setDeltaMovement(this.getDeltaMovement().add((double)(Mth.sin(-this.getYRot() * 0.017453292F) * this.entityData.get(POWER)), 0.0, (double)(Mth.cos(this.getYRot() * 0.017453292F) * this.entityData.get(POWER)))); } } @@ -645,7 +639,7 @@ public class SpeedboatEntityMobile extends MobileVehicleEntity implements GeoEnt this.clampRotation(entity); } - private PlayState firePredicate(AnimationState event) { + private PlayState firePredicate(AnimationState event) { if (this.entityData.get(FIRE_ANIM) > 1) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.speedboat.fire")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/WheelChairEntityMobile.java b/src/main/java/com/atsuishio/superbwarfare/entity/WheelChairEntity.java similarity index 84% rename from src/main/java/com/atsuishio/superbwarfare/entity/WheelChairEntityMobile.java rename to src/main/java/com/atsuishio/superbwarfare/entity/WheelChairEntity.java index ddf3b387d..b77a1b390 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/WheelChairEntityMobile.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/WheelChairEntity.java @@ -19,28 +19,27 @@ import net.minecraft.world.entity.*; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; +import org.joml.Math; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; import software.bernie.geckolib.core.animation.AnimatableManager; import software.bernie.geckolib.util.GeckoLibUtil; -public class WheelChairEntityMobile extends MobileVehicleEntity implements GeoEntity, IVehicleEntity { +public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity, IVehicleEntity { - public static final EntityDataAccessor POWER = SynchedEntityData.defineId(WheelChairEntityMobile.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor ROT_Y = SynchedEntityData.defineId(WheelChairEntityMobile.class, EntityDataSerializers.FLOAT); + public static final EntityDataAccessor POWER = SynchedEntityData.defineId(WheelChairEntity.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(WheelChairEntityMobile.class, EntityDataSerializers.FLOAT); + public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(WheelChairEntity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public static final float MAX_HEALTH = 50; - public WheelChairEntityMobile(PlayMessages.SpawnEntity packet, Level world) { + public WheelChairEntity(PlayMessages.SpawnEntity packet, Level world) { this(ModEntities.WHEEL_CHAIR.get(), world); } - public WheelChairEntityMobile(EntityType type, Level world) { + public WheelChairEntity(EntityType type, Level world) { super(type, world); this.setMaxUpStep(1.1f); } @@ -48,7 +47,6 @@ public class WheelChairEntityMobile extends MobileVehicleEntity implements GeoEn @Override protected void defineSynchedData() { this.entityData.define(HEALTH, MAX_HEALTH); - this.entityData.define(ROT_Y, 0f); this.entityData.define(POWER, 0f); } @@ -145,10 +143,6 @@ public class WheelChairEntityMobile extends MobileVehicleEntity implements GeoEn destroy(); } - if (this.level() instanceof ServerLevel) { - this.entityData.set(ROT_Y, this.getYRot()); - } - travel(); this.refreshDimensions(); } @@ -157,23 +151,16 @@ public class WheelChairEntityMobile extends MobileVehicleEntity implements GeoEn Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); if (!(passenger instanceof LivingEntity entity)) return; - float diffY = entity.getYRot() - this.getYRot(); - if (diffY > 180.0f) { - diffY -= 360.0f; - } else if (diffY < -180.0f) { - diffY += 360.0f; - } - diffY = Mth.clamp(diffY * 0.15f, -8f, 8f); + float diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(entity.getYHeadRot() - this.getYRot())); - this.setYRot(this.entityData.get(ROT_Y) + diffY); - this.setRot(this.getYRot(), this.getXRot()); + this.setYRot(this.getYRot() + Mth.clamp(0.4f * diffY,-5f, 5f)); if (this.forwardInputDown) { - this.entityData.set(POWER, this.entityData.get(POWER) + 0.02f); + this.entityData.set(POWER, this.entityData.get(POWER) + 0.01f); } if (this.backInputDown) { - this.entityData.set(POWER, this.entityData.get(POWER) - 0.02f); + this.entityData.set(POWER, this.entityData.get(POWER) - 0.01f); } if (this.upInputDown && this.onGround()) { @@ -188,7 +175,7 @@ public class WheelChairEntityMobile extends MobileVehicleEntity implements GeoEn this.entityData.set(POWER, this.entityData.get(POWER) * 0.87f); if (this.onGround()) { - this.setDeltaMovement(this.getDeltaMovement().add(new Vec3(this.getLookAngle().x, 0, this.getLookAngle().z).scale(this.entityData.get(POWER)))); + this.setDeltaMovement(this.getDeltaMovement().add((double)(Mth.sin(-this.getYRot() * 0.017453292F) * this.entityData.get(POWER)), 0.0, (double)(Mth.cos(this.getYRot() * 0.017453292F) * this.entityData.get(POWER)))); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java index 5ed1cecd3..75ac05d4d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/ClientEventHandler.java @@ -6,7 +6,7 @@ import com.atsuishio.superbwarfare.config.client.DisplayConfig; import com.atsuishio.superbwarfare.entity.DroneEntity; import com.atsuishio.superbwarfare.entity.ICannonEntity; import com.atsuishio.superbwarfare.entity.IVehicleEntity; -import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile; +import com.atsuishio.superbwarfare.entity.SpeedboatEntity; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.ModVariables; import com.atsuishio.superbwarfare.network.message.LaserShootMessage; @@ -52,7 +52,7 @@ import software.bernie.geckolib.core.animatable.model.CoreGeoBone; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; -import static com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile.HEAT; +import static com.atsuishio.superbwarfare.entity.SpeedboatEntity.HEAT; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class ClientEventHandler { @@ -584,7 +584,7 @@ public class ClientEventHandler { } public static void playVehicleClientSounds(Player player, IVehicleEntity iVehicle) { - if (iVehicle instanceof SpeedboatEntityMobile speedboat) { + if (iVehicle instanceof SpeedboatEntity speedboat) { float pitch = speedboat.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * java.lang.Math.abs(60 - speedboat.getEntityData().get(HEAT))); player.playSound(ModSounds.M_2_FIRE_1P.get(), 1f, pitch); player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1); @@ -750,7 +750,7 @@ public class ClientEventHandler { event.setCanceled(true); } - if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntityMobile boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoom && stack.is(ItemStack.EMPTY.getItem())) { + if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoom && stack.is(ItemStack.EMPTY.getItem())) { event.setCanceled(true); } } @@ -1238,7 +1238,7 @@ public class ClientEventHandler { return; } - if (mc.player.getVehicle() instanceof SpeedboatEntityMobile && zoom) { + if (mc.player.getVehicle() instanceof SpeedboatEntity && zoom) { event.setCanceled(true); } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModEntities.java b/src/main/java/com/atsuishio/superbwarfare/init/ModEntities.java index ec17d65c3..bc55ba825 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModEntities.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModEntities.java @@ -61,10 +61,10 @@ public class ModEntities { EntityType.Builder.of(JavelinMissileEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(1).setCustomClientFactory(JavelinMissileEntity::new).sized(0.5f, 0.5f)); public static final RegistryObject> LASER = register("laser", EntityType.Builder.of(LaserEntity::new, MobCategory.MISC).sized(0.1f, 0.1f).fireImmune().setUpdateInterval(1)); - public static final RegistryObject> SPEEDBOAT = register("speedboat", - EntityType.Builder.of(SpeedboatEntityMobile::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(SpeedboatEntityMobile::new).fireImmune().sized(3.0f, 2.0f)); - public static final RegistryObject> WHEEL_CHAIR = register("wheel_chair", - EntityType.Builder.of(WheelChairEntityMobile::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(WheelChairEntityMobile::new).fireImmune().sized(1.0f, 1.0f)); + public static final RegistryObject> SPEEDBOAT = register("speedboat", + EntityType.Builder.of(SpeedboatEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(SpeedboatEntity::new).fireImmune().sized(3.0f, 2.0f)); + public static final RegistryObject> WHEEL_CHAIR = register("wheel_chair", + EntityType.Builder.of(WheelChairEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(WheelChairEntity::new).fireImmune().sized(1.0f, 1.0f)); private static RegistryObject> register(String name, EntityType.Builder entityTypeBuilder) { return REGISTRY.register(name, () -> entityTypeBuilder.build(name)); diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java index 48011200f..e86ec3cbc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java @@ -40,7 +40,7 @@ public abstract class CameraMixin { if (player != null) { ItemStack stack = player.getMainHandItem(); - if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntityMobile boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoom && stack.is(ItemStack.EMPTY.getItem())) { + if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoom && stack.is(ItemStack.EMPTY.getItem())) { float yRot = boat.getYRot(); if (yRot < 0) { yRot += 360; @@ -92,7 +92,7 @@ public abstract class CameraMixin { move(-getMaxZoom(16), 1.3, 0.0); return; } - if (thirdPerson && entity.getVehicle() instanceof SpeedboatEntityMobile && !ClientEventHandler.zoom) { + if (thirdPerson && entity.getVehicle() instanceof SpeedboatEntity && !ClientEventHandler.zoom) { move(-getMaxZoom(3), 1, 0.0); return; }