理论上修复了载具类旋转问题
This commit is contained in:
parent
09b04af3a8
commit
d16a6b29ad
19 changed files with 149 additions and 209 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SpeedboatEntityMobile> {
|
||||
public class SpeedBoatHeatLayer extends GeoRenderLayer<SpeedboatEntity> {
|
||||
private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_heat.png");
|
||||
|
||||
public SpeedBoatHeatLayer(GeoRenderer<SpeedboatEntityMobile> entityRenderer) {
|
||||
public SpeedBoatHeatLayer(GeoRenderer<SpeedboatEntity> 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);
|
||||
|
|
|
@ -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<SpeedboatEntityMobile> {
|
||||
public class SpeedBoatLayer extends GeoRenderLayer<SpeedboatEntity> {
|
||||
|
||||
private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_e.png");
|
||||
|
||||
public SpeedBoatLayer(GeoRenderer<SpeedboatEntityMobile> entityRenderer) {
|
||||
public SpeedBoatLayer(GeoRenderer<SpeedboatEntity> 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);
|
||||
}
|
||||
|
|
|
@ -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<SpeedboatEntityMobile> {
|
||||
public class SpeedBoatPowerLayer extends GeoRenderLayer<SpeedboatEntity> {
|
||||
|
||||
private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_power.png");
|
||||
|
||||
public SpeedBoatPowerLayer(GeoRenderer<SpeedboatEntityMobile> entityRenderer) {
|
||||
public SpeedBoatPowerLayer(GeoRenderer<SpeedboatEntity> 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);
|
||||
|
|
|
@ -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<SpeedboatEntityMobile> {
|
||||
public class SpeedboatModel extends GeoModel<SpeedboatEntity> {
|
||||
|
||||
@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<SpeedboatEntityMobile> animationState) {
|
||||
public void setCustomAnimations(SpeedboatEntity animatable, long instanceId, AnimationState<SpeedboatEntity> animationState) {
|
||||
CoreGeoBone rotor = getAnimationProcessor().getBone("Rotor");
|
||||
CoreGeoBone duo = getAnimationProcessor().getBone("duo");
|
||||
|
||||
|
|
|
@ -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<WheelChairEntityMobile> {
|
||||
public class WheelChairModel extends GeoModel<WheelChairEntity> {
|
||||
|
||||
@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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<SpeedboatEntityMobile> {
|
||||
public class SpeedboatRenderer extends GeoEntityRenderer<SpeedboatEntity> {
|
||||
|
||||
public SpeedboatRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new SpeedboatModel());
|
||||
|
@ -27,12 +27,12 @@ public class SpeedboatRenderer extends GeoEntityRenderer<SpeedboatEntityMobile>
|
|||
}
|
||||
|
||||
@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<SpeedboatEntityMobile>
|
|||
}
|
||||
|
||||
@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<SpeedboatEntityMobile>
|
|||
}
|
||||
|
||||
@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<SpeedboatEntityMobile>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(SpeedboatEntityMobile entityLivingBaseIn) {
|
||||
protected float getDeathMaxRotation(SpeedboatEntity entityLivingBaseIn) {
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<WheelChairEntityMobile> {
|
||||
public class WheelChairRenderer extends GeoEntityRenderer<WheelChairEntity> {
|
||||
|
||||
public WheelChairRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new WheelChairModel());
|
||||
|
@ -23,12 +20,12 @@ public class WheelChairRenderer extends GeoEntityRenderer<WheelChairEntityMobile
|
|||
}
|
||||
|
||||
@Override
|
||||
public RenderType getRenderType(WheelChairEntityMobile animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
public RenderType getRenderType(WheelChairEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
return RenderType.entityTranslucent(getTextureLocation(animatable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRender(PoseStack poseStack, WheelChairEntityMobile entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, float red, float green,
|
||||
public void preRender(PoseStack poseStack, WheelChairEntity 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;
|
||||
|
@ -37,9 +34,9 @@ public class WheelChairRenderer extends GeoEntityRenderer<WheelChairEntityMobile
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(WheelChairEntityMobile entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
|
||||
public void render(WheelChairEntity 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())));
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(-entityYaw));
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.atsuishio.superbwarfare.ModUtils;
|
|||
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
||||
import com.atsuishio.superbwarfare.entity.IChargeEntity;
|
||||
import com.atsuishio.superbwarfare.entity.IVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
@ -134,7 +134,7 @@ public class VehicleHudOverlay {
|
|||
if (stack.getItem() == ModItems.HE_5_INCHES.get() && iVehicle instanceof ICannonEntity) {
|
||||
return Component.translatable("des.superbwarfare.tips.ammo_type.he").getString();
|
||||
}
|
||||
if (iVehicle instanceof SpeedboatEntityMobile) {
|
||||
if (iVehicle instanceof SpeedboatEntity) {
|
||||
return Component.translatable("des.superbwarfare.tips.ammo_type.cal50").getString();
|
||||
}
|
||||
return "";
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.atsuishio.superbwarfare.client.screens;
|
|||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
@ -68,6 +68,6 @@ public class VehicleMgHudOverlay {
|
|||
private static boolean shouldRenderCrossHair(Player player) {
|
||||
if (player == null) return false;
|
||||
return !player.isSpectator()
|
||||
&& player.getVehicle() instanceof SpeedboatEntityMobile && ClientEventHandler.zoom && !player.getMainHandItem().is(ModTags.Items.GUN);
|
||||
&& player.getVehicle() instanceof SpeedboatEntity && ClientEventHandler.zoom && !player.getMainHandItem().is(ModTags.Items.GUN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import net.minecraft.world.phys.*;
|
|||
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;
|
||||
|
@ -59,8 +60,6 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit
|
|||
public static final EntityDataAccessor<Float> LASER_RIGHT_LENGTH = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> ENERGY = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> OFFSET_ANGLE = SynchedEntityData.defineId(AnnihilatorEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> 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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> 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) {
|
||||
|
|
|
@ -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<Integer> COOL_DOWN = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Integer> TYPE = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> 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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<Integer> FIRE_ANIM = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> ENERGY = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> ROT_Y = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> POWER = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> ROTOR = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Integer> HEAT = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.INT);
|
||||
protected static final EntityDataAccessor<String> LAST_ATTACKER_UUID = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.STRING);
|
||||
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(SpeedboatEntityMobile.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Integer> FIRE_ANIM = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> ENERGY = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> POWER = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> ROTOR = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Integer> HEAT = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.INT);
|
||||
protected static final EntityDataAccessor<String> LAST_ATTACKER_UUID = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.STRING);
|
||||
public static final EntityDataAccessor<Integer> 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<SpeedboatEntityMobile> type, Level world) {
|
||||
public SpeedboatEntity(EntityType<SpeedboatEntity> 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<SpeedboatEntityMobile> event) {
|
||||
private PlayState firePredicate(AnimationState<SpeedboatEntity> event) {
|
||||
if (this.entityData.get(FIRE_ANIM) > 1) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.speedboat.fire"));
|
||||
}
|
|
@ -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<Float> POWER = SynchedEntityData.defineId(WheelChairEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> ROT_Y = SynchedEntityData.defineId(WheelChairEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> POWER = SynchedEntityData.defineId(WheelChairEntity.class, EntityDataSerializers.FLOAT);
|
||||
|
||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(WheelChairEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> 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<WheelChairEntityMobile> type, Level world) {
|
||||
public WheelChairEntity(EntityType<WheelChairEntity> 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))));
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,10 +61,10 @@ public class ModEntities {
|
|||
EntityType.Builder.<JavelinMissileEntity>of(JavelinMissileEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(1).setCustomClientFactory(JavelinMissileEntity::new).sized(0.5f, 0.5f));
|
||||
public static final RegistryObject<EntityType<LaserEntity>> LASER = register("laser",
|
||||
EntityType.Builder.<LaserEntity>of(LaserEntity::new, MobCategory.MISC).sized(0.1f, 0.1f).fireImmune().setUpdateInterval(1));
|
||||
public static final RegistryObject<EntityType<SpeedboatEntityMobile>> SPEEDBOAT = register("speedboat",
|
||||
EntityType.Builder.<SpeedboatEntityMobile>of(SpeedboatEntityMobile::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(SpeedboatEntityMobile::new).fireImmune().sized(3.0f, 2.0f));
|
||||
public static final RegistryObject<EntityType<WheelChairEntityMobile>> WHEEL_CHAIR = register("wheel_chair",
|
||||
EntityType.Builder.<WheelChairEntityMobile>of(WheelChairEntityMobile::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(WheelChairEntityMobile::new).fireImmune().sized(1.0f, 1.0f));
|
||||
public static final RegistryObject<EntityType<SpeedboatEntity>> SPEEDBOAT = register("speedboat",
|
||||
EntityType.Builder.<SpeedboatEntity>of(SpeedboatEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(SpeedboatEntity::new).fireImmune().sized(3.0f, 2.0f));
|
||||
public static final RegistryObject<EntityType<WheelChairEntity>> WHEEL_CHAIR = register("wheel_chair",
|
||||
EntityType.Builder.<WheelChairEntity>of(WheelChairEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(WheelChairEntity::new).fireImmune().sized(1.0f, 1.0f));
|
||||
|
||||
private static <T extends Entity> RegistryObject<EntityType<T>> register(String name, EntityType.Builder<T> entityTypeBuilder) {
|
||||
return REGISTRY.register(name, () -> entityTypeBuilder.build(name));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue