添加轮椅
This commit is contained in:
parent
314cc0e6e2
commit
09b04af3a8
20 changed files with 3070 additions and 151 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.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
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 SpeedboatEntity boat && boat.getFirstPassenger() == player && stack.is(ItemStack.EMPTY.getItem()))) {
|
||||
|| (player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntityMobile boat && boat.getFirstPassenger() == player && stack.is(ItemStack.EMPTY.getItem()))) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
@ -409,6 +409,10 @@ public class ClickHandler {
|
|||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(2, state == 1));
|
||||
} else if (key == options.keyDown.getKey().getValue()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(3, state == 1));
|
||||
} else if (key == options.keyJump.getKey().getValue()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(4, state == 1));
|
||||
} else if (key == options.keySprint.getKey().getValue()) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new VehicleMovementMessage(5, state == 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.atsuishio.superbwarfare.client.layer;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
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.SpeedboatEntity.HEAT;
|
||||
import static com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile.HEAT;
|
||||
|
||||
public class SpeedBoatHeatLayer extends GeoRenderLayer<SpeedboatEntity> {
|
||||
public class SpeedBoatHeatLayer extends GeoRenderLayer<SpeedboatEntityMobile> {
|
||||
private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_heat.png");
|
||||
|
||||
public SpeedBoatHeatLayer(GeoRenderer<SpeedboatEntity> entityRenderer) {
|
||||
public SpeedBoatHeatLayer(GeoRenderer<SpeedboatEntityMobile> entityRenderer) {
|
||||
super(entityRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, SpeedboatEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
|
||||
public void render(PoseStack poseStack, SpeedboatEntityMobile 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.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
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<SpeedboatEntity> {
|
||||
public class SpeedBoatLayer extends GeoRenderLayer<SpeedboatEntityMobile> {
|
||||
|
||||
private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_e.png");
|
||||
|
||||
public SpeedBoatLayer(GeoRenderer<SpeedboatEntity> entityRenderer) {
|
||||
public SpeedBoatLayer(GeoRenderer<SpeedboatEntityMobile> entityRenderer) {
|
||||
super(entityRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, SpeedboatEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
|
||||
public void render(PoseStack poseStack, SpeedboatEntityMobile 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.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
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.SpeedboatEntity.ENERGY;
|
||||
import static com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile.ENERGY;
|
||||
|
||||
public class SpeedBoatPowerLayer extends GeoRenderLayer<SpeedboatEntity> {
|
||||
public class SpeedBoatPowerLayer extends GeoRenderLayer<SpeedboatEntityMobile> {
|
||||
|
||||
private static final ResourceLocation LAYER = ModUtils.loc("textures/entity/speedboat_power.png");
|
||||
|
||||
public SpeedBoatPowerLayer(GeoRenderer<SpeedboatEntity> entityRenderer) {
|
||||
public SpeedBoatPowerLayer(GeoRenderer<SpeedboatEntityMobile> entityRenderer) {
|
||||
super(entityRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, SpeedboatEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
|
||||
public void render(PoseStack poseStack, SpeedboatEntityMobile 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.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
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.SpeedboatEntity.*;
|
||||
import static com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile.*;
|
||||
|
||||
public class SpeedboatModel extends GeoModel<SpeedboatEntity> {
|
||||
public class SpeedboatModel extends GeoModel<SpeedboatEntityMobile> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(SpeedboatEntity entity) {
|
||||
public ResourceLocation getAnimationResource(SpeedboatEntityMobile entity) {
|
||||
return ModUtils.loc("animations/speedboat.animation.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(SpeedboatEntity entity) {
|
||||
public ResourceLocation getModelResource(SpeedboatEntityMobile entity) {
|
||||
return new ResourceLocation(ModUtils.MODID, "geo/speedboat.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(SpeedboatEntity entity) {
|
||||
public ResourceLocation getTextureResource(SpeedboatEntityMobile entity) {
|
||||
return ModUtils.loc("textures/entity/speedboat.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomAnimations(SpeedboatEntity animatable, long instanceId, AnimationState<SpeedboatEntity> animationState) {
|
||||
public void setCustomAnimations(SpeedboatEntityMobile animatable, long instanceId, AnimationState<SpeedboatEntityMobile> animationState) {
|
||||
CoreGeoBone rotor = getAnimationProcessor().getBone("Rotor");
|
||||
CoreGeoBone duo = getAnimationProcessor().getBone("duo");
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.atsuishio.superbwarfare.client.model.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.entity.WheelChairEntityMobile;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class WheelChairModel extends GeoModel<WheelChairEntityMobile> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(WheelChairEntityMobile entity) {
|
||||
return null;
|
||||
// return ModUtils.loc("animations/wheel_chair.animation.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(WheelChairEntityMobile entity) {
|
||||
return new ResourceLocation(ModUtils.MODID, "geo/wheel_chair.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(WheelChairEntityMobile 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.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
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<SpeedboatEntity> {
|
||||
public class SpeedboatRenderer extends GeoEntityRenderer<SpeedboatEntityMobile> {
|
||||
|
||||
public SpeedboatRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new SpeedboatModel());
|
||||
|
@ -27,12 +27,12 @@ public class SpeedboatRenderer extends GeoEntityRenderer<SpeedboatEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RenderType getRenderType(SpeedboatEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
public RenderType getRenderType(SpeedboatEntityMobile animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
return RenderType.entityTranslucent(getTextureLocation(animatable));
|
||||
}
|
||||
|
||||
@Override
|
||||
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,
|
||||
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,
|
||||
float blue, float alpha) {
|
||||
float scale = 1f;
|
||||
this.scaleHeight = scale;
|
||||
|
@ -41,7 +41,7 @@ public class SpeedboatRenderer extends GeoEntityRenderer<SpeedboatEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(SpeedboatEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
|
||||
public void render(SpeedboatEntityMobile 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<SpeedboatEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
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) {
|
||||
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<SpeedboatEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(SpeedboatEntity entityLivingBaseIn) {
|
||||
protected float getDeathMaxRotation(SpeedboatEntityMobile entityLivingBaseIn) {
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.model.entity.WheelChairModel;
|
||||
import com.atsuishio.superbwarfare.entity.WheelChairEntityMobile;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
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 WheelChairRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new WheelChairModel());
|
||||
this.shadowRadius = 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderType getRenderType(WheelChairEntityMobile 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,
|
||||
float blue, float alpha) {
|
||||
float scale = 1f;
|
||||
this.scaleHeight = scale;
|
||||
this.scaleWidth = scale;
|
||||
super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(WheelChairEntityMobile 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);
|
||||
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.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
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 SpeedboatEntity) {
|
||||
if (iVehicle instanceof SpeedboatEntityMobile) {
|
||||
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.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
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 SpeedboatEntity && ClientEventHandler.zoom && !player.getMainHandItem().is(ModTags.Items.GUN);
|
||||
&& player.getVehicle() instanceof SpeedboatEntityMobile && ClientEventHandler.zoom && !player.getMainHandItem().is(ModTags.Items.GUN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package com.atsuishio.superbwarfare.entity;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
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;
|
||||
public boolean leftInputDown;
|
||||
public boolean rightInputDown;
|
||||
public boolean forwardInputDown;
|
||||
public boolean backInputDown;
|
||||
public boolean upInputDown;
|
||||
public boolean downInputDown;
|
||||
|
||||
public MobileVehicleEntity(EntityType<?> pEntityType, Level pLevel) {
|
||||
super(pEntityType, pLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPickable() {
|
||||
return !this.isRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
|
||||
tickLerp();
|
||||
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
private void tickLerp() {
|
||||
if (this.isControlledByLocalInstance()) {
|
||||
this.lerpSteps = 0;
|
||||
this.syncPacketPositionCodec(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
@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 static double calculateAngle(Vec3 move, Vec3 view) {
|
||||
move = move.multiply(1, 0, 1).normalize();
|
||||
view = view.multiply(1, 0, 1).normalize();
|
||||
|
||||
double startLength = move.length();
|
||||
double endLength = view.length();
|
||||
if (startLength > 0.0D && endLength > 0.0D) {
|
||||
return Math.toDegrees(Math.acos(Mth.clamp(move.dot(view) / (startLength * endLength), -1, 1)));
|
||||
} else {
|
||||
return 0.0D;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void defineSynchedData() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readAdditionalSaveData(CompoundTag compoundTag) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compound) {
|
||||
}
|
||||
}
|
|
@ -83,18 +83,18 @@ import java.util.ArrayList;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, IVehicleEntity, HasCustomInventoryScreen, ContainerEntity {
|
||||
public class SpeedboatEntityMobile extends MobileVehicleEntity implements GeoEntity, IChargeEntity, IVehicleEntity, HasCustomInventoryScreen, ContainerEntity {
|
||||
|
||||
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> ROT_Y = 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 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 float MAX_HEALTH = CannonConfig.SPEEDBOAT_HP.get();
|
||||
public static final float MAX_ENERGY = CannonConfig.SPEEDBOAT_MAX_ENERGY.get().floatValue();
|
||||
|
@ -104,12 +104,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
private LazyOptional<?> itemHandler = LazyOptional.of(() -> new InvWrapper(this));
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
private int lerpSteps;
|
||||
private double lerpX;
|
||||
private double lerpY;
|
||||
private double lerpZ;
|
||||
private double lerpYRot;
|
||||
private double lerpXRot;
|
||||
|
||||
public float turretYRot;
|
||||
public float turretXRot;
|
||||
|
@ -118,11 +112,11 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
|
||||
public boolean cannotFire;
|
||||
|
||||
public SpeedboatEntity(PlayMessages.SpawnEntity packet, Level world) {
|
||||
public SpeedboatEntityMobile(PlayMessages.SpawnEntity packet, Level world) {
|
||||
this(ModEntities.SPEEDBOAT.get(), world);
|
||||
}
|
||||
|
||||
public SpeedboatEntity(EntityType<SpeedboatEntity> type, Level world) {
|
||||
public SpeedboatEntityMobile(EntityType<SpeedboatEntityMobile> type, Level world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
|
@ -200,7 +194,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
if (!this.level().isClientSide && pReason != RemovalReason.DISCARDED) {
|
||||
Containers.dropContents(this.level(), this, this);
|
||||
}
|
||||
|
||||
super.remove(pReason);
|
||||
}
|
||||
|
||||
|
@ -248,11 +241,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPickable() {
|
||||
return !this.isRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult interact(Player player, InteractionHand hand) {
|
||||
if (player.getVehicle() == this) return InteractionResult.PASS;
|
||||
|
@ -357,8 +345,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
crushEntities(this.getDeltaMovement());
|
||||
}
|
||||
|
||||
handleClientSync();
|
||||
tickLerp();
|
||||
controlBoat();
|
||||
collideBlock();
|
||||
gunnerAngle();
|
||||
|
@ -504,42 +490,42 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
if (this.entityData.get(ENERGY) <= 0) return;
|
||||
|
||||
if (passenger0 == null) {
|
||||
this.getPersistentData().putBoolean("left", false);
|
||||
this.getPersistentData().putBoolean("right", false);
|
||||
this.getPersistentData().putBoolean("forward", false);
|
||||
this.getPersistentData().putBoolean("backward", false);
|
||||
this.leftInputDown = false;
|
||||
this.rightInputDown = false;
|
||||
this.forwardInputDown = false;
|
||||
this.backInputDown = false;
|
||||
}
|
||||
|
||||
float diffY = 0;
|
||||
if (this.getPersistentData().getBoolean("forward")) {
|
||||
if (forwardInputDown) {
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) + 0.02f);
|
||||
}
|
||||
|
||||
if (this.getPersistentData().getBoolean("backward")) {
|
||||
if (backInputDown) {
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) - 0.02f);
|
||||
if (this.getPersistentData().getBoolean("right")) {
|
||||
if (rightInputDown) {
|
||||
diffY = Mth.clamp(diffY + 1f, 0, 10);
|
||||
handleSetDiffY(diffY);
|
||||
} else if (this.getPersistentData().getBoolean("left")) {
|
||||
} else if (leftInputDown) {
|
||||
diffY = Mth.clamp(diffY - 1f, -10, 0);
|
||||
handleSetDiffY(diffY);
|
||||
}
|
||||
} else {
|
||||
if (this.getPersistentData().getBoolean("right")) {
|
||||
if (rightInputDown) {
|
||||
diffY = Mth.clamp(diffY - 1f, -10, 0);
|
||||
handleSetDiffY(diffY);
|
||||
} else if (this.getPersistentData().getBoolean("left")) {
|
||||
} else if (this.leftInputDown) {
|
||||
diffY = Mth.clamp(diffY + 1f, 0, 10);
|
||||
handleSetDiffY(diffY);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getPersistentData().getBoolean("forward") || this.getPersistentData().getBoolean("backward")) {
|
||||
if (this.forwardInputDown || this.backInputDown) {
|
||||
this.entityData.set(ENERGY, Math.max(this.entityData.get(ENERGY) - CannonConfig.SPEEDBOAT_ENERGY_COST.get().floatValue(), 0));
|
||||
}
|
||||
|
||||
if (level().isClientSide) {
|
||||
level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), this.getEngineSound(), this.getSoundSource(), Math.min((this.getPersistentData().getBoolean("forward") || this.getPersistentData().getBoolean("backward") ? 7.5f : 5f) * 2 * Mth.abs(this.entityData.get(POWER)), 0.25f), (random.nextFloat() * 0.1f + 1f), false);
|
||||
level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), this.getEngineSound(), this.getSoundSource(), Math.min((this.forwardInputDown || this.backInputDown ? 7.5f : 5f) * 2 * Mth.abs(this.entityData.get(POWER)), 0.25f), (random.nextFloat() * 0.1f + 1f), false);
|
||||
}
|
||||
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) * 0.87f);
|
||||
|
@ -582,26 +568,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
this.entityData.set(DELTA_ROT, (float) Mth.clamp(diffY * 1.3 * Math.max(8 * this.getDeltaMovement().length(), 0.5), -2, 2));
|
||||
}
|
||||
|
||||
private void handleClientSync() {
|
||||
if (isControlledByLocalInstance()) {
|
||||
lerpSteps = 0;
|
||||
syncPacketPositionCodec(getX(), getY(), getZ());
|
||||
}
|
||||
if (lerpSteps <= 0) {
|
||||
return;
|
||||
}
|
||||
double interpolatedX = getX() + (lerpX - getX()) / (double) lerpSteps;
|
||||
double interpolatedY = getY() + (lerpY - getY()) / (double) lerpSteps;
|
||||
double interpolatedZ = getZ() + (lerpZ - getZ()) / (double) lerpSteps;
|
||||
double interpolatedYaw = Mth.wrapDegrees(lerpYRot - (double) getYRot());
|
||||
setYRot(getYRot() + (float) interpolatedYaw / (float) lerpSteps);
|
||||
setXRot(getXRot() + (float) (lerpXRot - (double) getXRot()) / (float) lerpSteps);
|
||||
|
||||
setPos(interpolatedX, interpolatedY, interpolatedZ);
|
||||
setRot(getYRot(), getXRot());
|
||||
|
||||
--lerpSteps;
|
||||
}
|
||||
|
||||
protected SoundEvent getEngineSound() {
|
||||
return ModSounds.BOAT_ENGINE.get();
|
||||
|
@ -648,49 +614,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static double calculateAngle(Vec3 move, Vec3 view) {
|
||||
move = move.multiply(1, 0, 1).normalize();
|
||||
view = view.multiply(1, 0, 1).normalize();
|
||||
|
||||
double startLength = move.length();
|
||||
double endLength = view.length();
|
||||
if (startLength > 0.0D && endLength > 0.0D) {
|
||||
return Math.toDegrees(Math.acos(Mth.clamp(move.dot(view) / (startLength * endLength), -1, 1)));
|
||||
} else {
|
||||
return 0.0D;
|
||||
}
|
||||
}
|
||||
|
||||
private void tickLerp() {
|
||||
if (this.isControlledByLocalInstance()) {
|
||||
this.lerpSteps = 0;
|
||||
this.syncPacketPositionCodec(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@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 = pYaw;
|
||||
this.lerpXRot = pPitch;
|
||||
this.lerpSteps = 10;
|
||||
}
|
||||
|
||||
private void destroy() {
|
||||
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
|
||||
CustomExplosion explosion = new CustomExplosion(this.level(), attacker,
|
||||
|
@ -722,7 +645,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
this.clampRotation(entity);
|
||||
}
|
||||
|
||||
private PlayState firePredicate(AnimationState<SpeedboatEntity> event) {
|
||||
private PlayState firePredicate(AnimationState<SpeedboatEntityMobile> event) {
|
||||
if (this.entityData.get(FIRE_ANIM) > 1) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.speedboat.fire"));
|
||||
}
|
|
@ -0,0 +1,258 @@
|
|||
package com.atsuishio.superbwarfare.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.init.ModEntities;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.damagesource.DamageTypes;
|
||||
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 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 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> HEALTH = SynchedEntityData.defineId(WheelChairEntityMobile.class, EntityDataSerializers.FLOAT);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static final float MAX_HEALTH = 50;
|
||||
|
||||
public WheelChairEntityMobile(PlayMessages.SpawnEntity packet, Level world) {
|
||||
this(ModEntities.WHEEL_CHAIR.get(), world);
|
||||
}
|
||||
|
||||
public WheelChairEntityMobile(EntityType<WheelChairEntityMobile> type, Level world) {
|
||||
super(type, world);
|
||||
this.setMaxUpStep(1.1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void defineSynchedData() {
|
||||
this.entityData.define(HEALTH, MAX_HEALTH);
|
||||
this.entityData.define(ROT_Y, 0f);
|
||||
this.entityData.define(POWER, 0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compound) {
|
||||
if (compound.contains("Health")) {
|
||||
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
||||
} else {
|
||||
this.entityData.set(HEALTH, MAX_HEALTH);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag compound) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideWith(Entity pEntity) {
|
||||
return (pEntity.canBeCollidedWith() || pEntity.isPushable()) && !this.isPassengerOfSameVehicle(pEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getEyeHeight(Pose pPose, EntityDimensions pSize) {
|
||||
return 0.75F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet<ClientGamePacketListener> getAddEntityPacket() {
|
||||
return NetworkHooks.getEntitySpawningPacket(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPassengersRidingOffset() {
|
||||
return super.getPassengersRidingOffset() - 0.05;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hurt(DamageSource source, float amount) {
|
||||
if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud)
|
||||
return false;
|
||||
if (source.is(DamageTypes.FALL))
|
||||
return false;
|
||||
if (source.is(DamageTypes.CACTUS))
|
||||
return false;
|
||||
if (source.is(DamageTypes.DROWN))
|
||||
return false;
|
||||
if (source.is(DamageTypes.LIGHTNING_BOLT))
|
||||
return false;
|
||||
if (source.is(DamageTypes.FALLING_ANVIL))
|
||||
return false;
|
||||
if (source.is(DamageTypes.DRAGON_BREATH))
|
||||
return false;
|
||||
if (source.is(DamageTypes.WITHER))
|
||||
return false;
|
||||
if (source.is(DamageTypes.WITHER_SKULL))
|
||||
return false;
|
||||
|
||||
this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
|
||||
this.entityData.set(HEALTH, this.entityData.get(HEALTH) - amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult interact(Player player, InteractionHand hand) {
|
||||
if (this.getFirstPassenger() == null) {
|
||||
player.startRiding(this);
|
||||
return InteractionResult.sidedSuccess(this.level().isClientSide());
|
||||
}
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
super.baseTick();
|
||||
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.078, 0.0));
|
||||
if (this.onGround()) {
|
||||
float f = 0.7f + 0.2f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90;
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.99, f));
|
||||
} else {
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.99, 0.99, 0.99));
|
||||
}
|
||||
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
|
||||
if (this.entityData.get(HEALTH) <= 0) {
|
||||
this.ejectPassengers();
|
||||
destroy();
|
||||
}
|
||||
|
||||
if (this.level() instanceof ServerLevel) {
|
||||
this.entityData.set(ROT_Y, this.getYRot());
|
||||
}
|
||||
|
||||
travel();
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
public void travel() {
|
||||
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);
|
||||
|
||||
this.setYRot(this.entityData.get(ROT_Y) + diffY);
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
|
||||
if (this.forwardInputDown) {
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) + 0.02f);
|
||||
}
|
||||
|
||||
if (this.backInputDown) {
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) - 0.02f);
|
||||
}
|
||||
|
||||
if (this.upInputDown && this.onGround()) {
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(0, 0.58, 0));
|
||||
}
|
||||
|
||||
// if (this.getPersistentData().getBoolean("forward") || this.getPersistentData().getBoolean("backward")) {
|
||||
// this.entityData.set(ENERGY, Math.max(this.entityData.get(ENERGY) - CannonConfig.SPEEDBOAT_ENERGY_COST.get().floatValue(), 0));
|
||||
// }
|
||||
|
||||
|
||||
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))));
|
||||
}
|
||||
}
|
||||
|
||||
protected void clampRotation(Entity entity) {
|
||||
entity.setYBodyRot(this.getYRot());
|
||||
float f2 = Mth.wrapDegrees(entity.getYRot() - this.getYRot());
|
||||
float f3 = Mth.clamp(f2, -90F, 90.0F);
|
||||
entity.yRotO += f3 - f2;
|
||||
entity.setYRot(entity.getYRot() + f3 - f2);
|
||||
entity.setYHeadRot(entity.getYRot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPassengerTurned(Entity entity) {
|
||||
this.clampRotation(entity);
|
||||
}
|
||||
|
||||
private void destroy() {
|
||||
if (level() instanceof ServerLevel) {
|
||||
level().explode(null, this.getX(), this.getY(), this.getZ(), 0, Level.ExplosionInteraction.NONE);
|
||||
}
|
||||
this.discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vehicleShoot(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatableInstanceCache getAnimatableInstanceCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHealth() {
|
||||
return this.entityData.get(HEALTH).intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxHealth() {
|
||||
return (int) MAX_HEALTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDriver(Player player) {
|
||||
return player == this.getFirstPassenger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int mainGunRpm() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShoot(Player player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmmoCount(Player player) {
|
||||
return -1;
|
||||
}
|
||||
}
|
|
@ -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.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile;
|
||||
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.SpeedboatEntity.HEAT;
|
||||
import static com.atsuishio.superbwarfare.entity.SpeedboatEntityMobile.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 SpeedboatEntity speedboat) {
|
||||
if (iVehicle instanceof SpeedboatEntityMobile 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 SpeedboatEntity boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoom && stack.is(ItemStack.EMPTY.getItem())) {
|
||||
if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntityMobile 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 SpeedboatEntity && zoom) {
|
||||
if (mc.player.getVehicle() instanceof SpeedboatEntityMobile && zoom) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,8 +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<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<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));
|
||||
|
||||
private static <T extends Entity> RegistryObject<EntityType<T>> register(String name, EntityType.Builder<T> entityTypeBuilder) {
|
||||
return REGISTRY.register(name, () -> entityTypeBuilder.build(name));
|
||||
|
|
|
@ -30,5 +30,6 @@ public class ModEntityRenderers {
|
|||
event.registerEntityRenderer(ModEntities.LASER.get(), LaserEntityRenderer::new);
|
||||
event.registerEntityRenderer(ModEntities.ANNIHILATOR.get(), AnnihilatorRenderer::new);
|
||||
event.registerEntityRenderer(ModEntities.SPEEDBOAT.get(), SpeedboatRenderer::new);
|
||||
event.registerEntityRenderer(ModEntities.WHEEL_CHAIR.get(), WheelChairRenderer::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public abstract class CameraMixin {
|
|||
if (player != null) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoom && stack.is(ItemStack.EMPTY.getItem())) {
|
||||
if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntityMobile 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 SpeedboatEntity && !ClientEventHandler.zoom) {
|
||||
if (thirdPerson && entity.getVehicle() instanceof SpeedboatEntityMobile && !ClientEventHandler.zoom) {
|
||||
move(-getMaxZoom(3), 1, 0.0);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.atsuishio.superbwarfare.network.message;
|
||||
|
||||
import com.atsuishio.superbwarfare.entity.MobileVehicleEntity;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
@ -31,19 +32,25 @@ public class VehicleMovementMessage {
|
|||
Player player = context.getSender();
|
||||
|
||||
var vehicle = player.getVehicle();
|
||||
if (vehicle != null) {
|
||||
if (vehicle instanceof MobileVehicleEntity mobileVehicleEntity) {
|
||||
switch (message.direction) {
|
||||
case 0:
|
||||
vehicle.getPersistentData().putBoolean("left", message.clicked);
|
||||
mobileVehicleEntity.leftInputDown = message.clicked;
|
||||
break;
|
||||
case 1:
|
||||
vehicle.getPersistentData().putBoolean("right", message.clicked);
|
||||
mobileVehicleEntity.rightInputDown = message.clicked;
|
||||
break;
|
||||
case 2:
|
||||
vehicle.getPersistentData().putBoolean("forward", message.clicked);
|
||||
mobileVehicleEntity.forwardInputDown = message.clicked;
|
||||
break;
|
||||
case 3:
|
||||
vehicle.getPersistentData().putBoolean("backward", message.clicked);
|
||||
mobileVehicleEntity.backInputDown = message.clicked;
|
||||
break;
|
||||
case 4:
|
||||
mobileVehicleEntity.upInputDown = message.clicked;
|
||||
break;
|
||||
case 5:
|
||||
mobileVehicleEntity.downInputDown = message.clicked;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
2557
src/main/resources/assets/superbwarfare/geo/wheel_chair.geo.json
Normal file
2557
src/main/resources/assets/superbwarfare/geo/wheel_chair.geo.json
Normal file
File diff suppressed because it is too large
Load diff
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
Loading…
Add table
Reference in a new issue