修复载具卡斜坡的bug,优化载具车体旋转
This commit is contained in:
parent
f8484d1f2b
commit
035017846d
11 changed files with 74 additions and 160 deletions
|
@ -14,6 +14,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
@ -43,9 +44,10 @@ public class Bmp2Renderer extends GeoEntityRenderer<Bmp2Entity> {
|
|||
@Override
|
||||
public void render(Bmp2Entity 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.XP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.prevRoll, entityIn.getRoll())));
|
||||
Vec3 root = new Vec3(0, entityIn.rotateYOffset(), 0);
|
||||
poseStack.rotateAround(Axis.YP.rotationDegrees(-entityYaw), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.XP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.prevRoll, entityIn.getRoll())), (float) root.x, (float) root.y, (float) root.z);
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
@ -43,9 +44,10 @@ public class Lav150Renderer extends GeoEntityRenderer<Lav150Entity> {
|
|||
@Override
|
||||
public void render(Lav150Entity 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.XP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.prevRoll, entityIn.getRoll())));
|
||||
Vec3 root = new Vec3(0, entityIn.rotateYOffset(), 0);
|
||||
poseStack.rotateAround(Axis.YP.rotationDegrees(-entityYaw), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.XP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.prevRoll, entityIn.getRoll())), (float) root.x, (float) root.y, (float) root.z);
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
@ -48,9 +49,10 @@ public class PrismTankRenderer extends GeoEntityRenderer<PrismTankEntity> {
|
|||
@Override
|
||||
public void render(PrismTankEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, @NotNull MultiBufferSource bufferIn, int packedLightIn) {
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(-Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot())));
|
||||
poseStack.mulPose(Axis.XP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.prevRoll, entityIn.getRoll())));
|
||||
Vec3 root = new Vec3(0, entityIn.rotateYOffset(), 0);
|
||||
poseStack.rotateAround(Axis.YP.rotationDegrees(-entityYaw), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.XP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.prevRoll, entityIn.getRoll())), (float) root.x, (float) root.y, (float) root.z);
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class SpeedboatRenderer extends GeoEntityRenderer<SpeedboatEntity> {
|
|||
@Override
|
||||
public void render(SpeedboatEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
|
||||
poseStack.pushPose();
|
||||
Vec3 root = new Vec3(0, 0.9, 0);
|
||||
Vec3 root = new Vec3(0, entityIn.rotateYOffset(), 0);
|
||||
poseStack.rotateAround(Axis.YP.rotationDegrees(-entityYaw), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.XP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.prevRoll, entityIn.getRoll())), (float) root.x, (float) root.y, (float) root.z);
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
@ -43,9 +44,10 @@ public class Yx100Renderer extends GeoEntityRenderer<Yx100Entity> {
|
|||
@Override
|
||||
public void render(Yx100Entity 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.XP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.prevRoll, entityIn.getRoll())));
|
||||
Vec3 root = new Vec3(0, entityIn.rotateYOffset(), 0);
|
||||
poseStack.rotateAround(Axis.YP.rotationDegrees(-entityYaw), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.XP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())), (float) root.x, (float) root.y, (float) root.z);
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.prevRoll, entityIn.getRoll())), (float) root.x, (float) root.y, (float) root.z);
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
|
|
@ -56,8 +56,6 @@ import software.bernie.geckolib.animation.*;
|
|||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
|
@ -225,42 +223,6 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terrainCompact(float w, float l) {
|
||||
if (onGround()) {
|
||||
float x1 = terrainCompactTrackValue(w, l)[0];
|
||||
float x2 = terrainCompactTrackValue(w, l - 1)[0];
|
||||
float x3 = terrainCompactTrackValue(w, l - 2)[0];
|
||||
float x4 = terrainCompactTrackValue(w, l - 3)[0];
|
||||
float x5 = terrainCompactTrackValue(w, l - 4)[0];
|
||||
float x6 = terrainCompactTrackValue(w, l - 5)[0];
|
||||
|
||||
List<Float> numbersX = Arrays.asList(x1, x2, x3, x4, x5, x6);
|
||||
float maxX = Collections.max(numbersX);
|
||||
float minX = Collections.min(numbersX);
|
||||
|
||||
float z1 = terrainCompactTrackValue(w, l)[1];
|
||||
float z2 = terrainCompactTrackValue(w, l - 1)[1];
|
||||
float z3 = terrainCompactTrackValue(w, l - 2)[1];
|
||||
float z4 = terrainCompactTrackValue(w, l - 3)[1];
|
||||
float z5 = terrainCompactTrackValue(w, l - 4)[1];
|
||||
float z6 = terrainCompactTrackValue(w, l - 5)[1];
|
||||
|
||||
List<Float> numbersZ = Arrays.asList(z1, z2, z3, z4, z5, z6);
|
||||
float maxZ = Collections.max(numbersZ);
|
||||
float minZ = Collections.min(numbersZ);
|
||||
|
||||
float diffX = Math.clamp(-15f, 15f, (minX + maxX) / 2);
|
||||
setXRot(Mth.clamp(getXRot() + 0.15f * diffX, -45f, 45f));
|
||||
|
||||
float diffZ = Math.clamp(-15f, 15f, minZ + maxZ);
|
||||
setZRot(Mth.clamp(getRoll() + 0.15f * diffZ, -45f, 45f));
|
||||
} else if (isInWater()) {
|
||||
setXRot(getXRot() * 0.9f);
|
||||
setZRot(getRoll() * 0.9f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideHardBlock() {
|
||||
return getDeltaMovement().horizontalDistance() > 0.07 || Mth.abs(this.entityData.get(POWER)) > 0.12;
|
||||
|
@ -413,11 +375,11 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
}
|
||||
|
||||
if (forwardInputDown) {
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + (this.entityData.get(POWER) < 0 ? 0.004f : 0.0024f), 0.21f));
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + (this.entityData.get(POWER) < 0 ? 0.004f : 0.0024f) * (1 + getXRot() / 55), 0.21f));
|
||||
}
|
||||
|
||||
if (backInputDown) {
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.entityData.get(POWER) > 0 ? 0.004f : 0.0024f), -0.16f));
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.entityData.get(POWER) > 0 ? 0.004f : 0.0024f) * (1 - getXRot() / 55), -0.16f));
|
||||
if (rightInputDown) {
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 0.1f);
|
||||
} else if (this.leftInputDown) {
|
||||
|
@ -467,8 +429,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
|
||||
this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0));
|
||||
if (this.isInWater() || onGround()) {
|
||||
float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.13f : (isInWater() && !onGround() ? 2 : 2.4f)) * power)));
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.13f : (isInWater() && !onGround() ? 2 : 2.4f)) * this.entityData.get(POWER))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,6 +550,11 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
|||
return transformV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float rotateYOffset() {
|
||||
return 2.7f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (level() instanceof ServerLevel) {
|
||||
|
|
|
@ -301,11 +301,11 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
|||
}
|
||||
|
||||
if (forwardInputDown) {
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + (this.entityData.get(POWER) < 0 ? 0.012f : 0.0024f), 0.18f));
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + (this.entityData.get(POWER) < 0 ? 0.012f : 0.0024f) * (1 + getXRot() / 55), 0.18f));
|
||||
}
|
||||
|
||||
if (backInputDown) {
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.entityData.get(POWER) > 0 ? 0.012f : 0.0024f), -0.13f));
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.entityData.get(POWER) > 0 ? 0.012f : 0.0024f) * (1 - getXRot() / 55), -0.13f));
|
||||
}
|
||||
|
||||
if (rightInputDown) {
|
||||
|
@ -349,8 +349,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
|||
|
||||
this.setYRot((float) (this.getYRot() - Math.max((isInWater() && !onGround() ? 5 : 10) * this.getDeltaMovement().horizontalDistance(), 0) * this.getRudderRot() * (this.entityData.get(POWER) > 0 ? 1 : -1) - i * s0));
|
||||
if (this.isInWater() || onGround()) {
|
||||
float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.05f : (isInWater() && !onGround() ? 0.3f : 1)) * power)));
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.05f : (isInWater() && !onGround() ? 0.3f : 1)) * this.entityData.get(POWER))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,6 +456,11 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
|||
return transformV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float rotateYOffset() {
|
||||
return 2.2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (level() instanceof ServerLevel) {
|
||||
|
|
|
@ -62,8 +62,6 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
|||
import software.bernie.geckolib.animation.AnimatableManager;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
|
@ -217,42 +215,6 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terrainCompact(float w, float l) {
|
||||
if (onGround()) {
|
||||
float x1 = terrainCompactTrackValue(w, l)[0];
|
||||
float x2 = terrainCompactTrackValue(w, l - 1)[0];
|
||||
float x3 = terrainCompactTrackValue(w, l - 2)[0];
|
||||
float x4 = terrainCompactTrackValue(w, l - 3)[0];
|
||||
float x5 = terrainCompactTrackValue(w, l - 4)[0];
|
||||
float x6 = terrainCompactTrackValue(w, l - 5)[0];
|
||||
|
||||
List<Float> numbersX = Arrays.asList(x1, x2, x3, x4, x5, x6);
|
||||
float maxX = Collections.max(numbersX);
|
||||
float minX = Collections.min(numbersX);
|
||||
|
||||
float z1 = terrainCompactTrackValue(w, l)[1];
|
||||
float z2 = terrainCompactTrackValue(w, l - 1)[1];
|
||||
float z3 = terrainCompactTrackValue(w, l - 2)[1];
|
||||
float z4 = terrainCompactTrackValue(w, l - 3)[1];
|
||||
float z5 = terrainCompactTrackValue(w, l - 4)[1];
|
||||
float z6 = terrainCompactTrackValue(w, l - 5)[1];
|
||||
|
||||
List<Float> numbersZ = Arrays.asList(z1, z2, z3, z4, z5, z6);
|
||||
float maxZ = Collections.max(numbersZ);
|
||||
float minZ = Collections.min(numbersZ);
|
||||
|
||||
float diffX = Math.clamp(-15f, 15f, (minX + maxX) / 2);
|
||||
setXRot(Mth.clamp(getXRot() + 0.15f * diffX, -45f, 45f));
|
||||
|
||||
float diffZ = Math.clamp(-15f, 15f, minZ + maxZ);
|
||||
setZRot(Mth.clamp(getRoll() + 0.15f * diffZ, -45f, 45f));
|
||||
} else if (isInWater()) {
|
||||
setXRot(getXRot() * 0.9f);
|
||||
setZRot(getRoll() * 0.9f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideHardBlock() {
|
||||
return getDeltaMovement().horizontalDistance() > 0.07 || Mth.abs(this.entityData.get(POWER)) > 0.12;
|
||||
|
@ -477,11 +439,11 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
}
|
||||
|
||||
if (forwardInputDown) {
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + (this.entityData.get(POWER) < 0 ? 0.004f : 0.0024f), 0.24f));
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + (this.entityData.get(POWER) < 0 ? 0.004f : 0.0024f) * (1 + getXRot() / 55), 0.24f));
|
||||
}
|
||||
|
||||
if (backInputDown) {
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.entityData.get(POWER) > 0 ? 0.004f : 0.0024f), -0.16f));
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.entityData.get(POWER) > 0 ? 0.004f : 0.0024f) * (1 - getXRot() / 55), -0.16f));
|
||||
if (rightInputDown) {
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 0.1f);
|
||||
} else if (this.leftInputDown) {
|
||||
|
@ -532,8 +494,7 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0));
|
||||
|
||||
if (this.isInWater() || onGround()) {
|
||||
float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.13f : (isInWater() && !onGround() ? 2 : 2.4f)) * power)));
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.13f : (isInWater() && !onGround() ? 2 : 2.4f)) * entityData.get(POWER))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,6 +617,11 @@ public class PrismTankEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
return transformV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float rotateYOffset() {
|
||||
return 3.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (level() instanceof ServerLevel) {
|
||||
|
|
|
@ -49,7 +49,6 @@ import java.util.List;
|
|||
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
||||
|
||||
public class SpeedboatEntity extends ContainerMobileVehicleEntity implements GeoEntity, ArmedVehicleEntity, WeaponVehicleEntity, LandArmorEntity, OBBEntity {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public OBB obb;
|
||||
public OBB obb2;
|
||||
|
@ -192,7 +191,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
|
||||
projectile.bypassArmorRate(0.4f);
|
||||
projectile.setPos(worldPosition.x + 0.5 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z + 0.5 * this.getDeltaMovement().z);
|
||||
projectile.shoot(player, getBarrelVector(1).x, getBarrelVector(1).y + 0.005f, getBarrelVector(1).z, 20,
|
||||
projectile.shoot(player, getBarrelVector(1).x, getBarrelVector(1).y, getBarrelVector(1).z, 20,
|
||||
(float) 0.4);
|
||||
this.level().addFreshEntity(projectile);
|
||||
|
||||
|
@ -308,7 +307,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
Matrix4f transform = getVehicleTransform(1);
|
||||
int i = this.getOrderedPassengers().indexOf(passenger);
|
||||
|
||||
float y = -0.65f;
|
||||
float y = 0.35f;
|
||||
|
||||
Vector4f worldPosition = switch (i) {
|
||||
case 0 -> transformPosition(transform, 0, y + 0.25f, -0.2f);
|
||||
|
@ -450,7 +449,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
Matrix4f transformV = getVehicleTransform(ticks);
|
||||
|
||||
Matrix4f transform = new Matrix4f();
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 1.5616625f, -0.565625f);
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 2.5616625f, -0.565625f);
|
||||
|
||||
transformV.translate(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
transformV.rotate(Axis.YP.rotationDegrees(Mth.lerp(ticks, turretYRotO, getTurretYRot())));
|
||||
|
@ -458,13 +457,8 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
}
|
||||
|
||||
@Override
|
||||
public Matrix4f getVehicleTransform(float ticks) {
|
||||
Matrix4f transform = new Matrix4f();
|
||||
transform.translate((float) Mth.lerp(ticks, xo, getX()), (float) Mth.lerp(ticks, yo + 0.9f, getY() + 0.9f), (float) Mth.lerp(ticks, zo, getZ()));
|
||||
transform.rotate(Axis.YP.rotationDegrees(-Mth.lerp(ticks, yRotO, getYRot())));
|
||||
transform.rotate(Axis.XP.rotationDegrees(Mth.lerp(ticks, xRotO, getXRot())));
|
||||
transform.rotate(Axis.ZP.rotationDegrees(Mth.lerp(ticks, prevRoll, getRoll())));
|
||||
return transform;
|
||||
public float rotateYOffset() {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
private PlayState firePredicate(AnimationState<SpeedboatEntity> event) {
|
||||
|
@ -574,11 +568,11 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
|||
public void updateOBB() {
|
||||
Matrix4f transform = getVehicleTransform(1);
|
||||
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 0.875f - 0.9f, 0.375f);
|
||||
Vector4f worldPosition = transformPosition(transform, 0, 0.875f, 0.375f);
|
||||
this.obb.center().set(new Vector3f(worldPosition.x, worldPosition.y, worldPosition.z));
|
||||
this.obb.setRotation(VectorTool.combineRotations(1, this));
|
||||
|
||||
Vector4f worldPosition2 = transformPosition(transform, 0, 2.0625f - 0.9f, -0.71875f);
|
||||
Vector4f worldPosition2 = transformPosition(transform, 0, 2.0625f, -0.71875f);
|
||||
this.obb2.center().set(new Vector3f(worldPosition2.x, worldPosition2.y, worldPosition2.z));
|
||||
this.obb2.setRotation(VectorTool.combineRotations(1, this));
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
|||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
|
@ -333,44 +331,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terrainCompact(float w, float l) {
|
||||
if (onGround()) {
|
||||
float x1 = terrainCompactTrackValue(w, l)[0];
|
||||
float x2 = terrainCompactTrackValue(w, l - 1)[0];
|
||||
float x3 = terrainCompactTrackValue(w, l - 2)[0];
|
||||
float x4 = terrainCompactTrackValue(w, l - 3)[0];
|
||||
float x5 = terrainCompactTrackValue(w, l - 4)[0];
|
||||
float x6 = terrainCompactTrackValue(w, l - 5)[0];
|
||||
float x7 = terrainCompactTrackValue(w, l - 6)[0];
|
||||
|
||||
List<Float> numbersX = Arrays.asList(x1, x2, x3, x4, x5, x6, x7);
|
||||
float maxX = Collections.max(numbersX);
|
||||
float minX = Collections.min(numbersX);
|
||||
|
||||
float z1 = terrainCompactTrackValue(w, l)[1];
|
||||
float z2 = terrainCompactTrackValue(w, l - 1)[1];
|
||||
float z3 = terrainCompactTrackValue(w, l - 2)[1];
|
||||
float z4 = terrainCompactTrackValue(w, l - 3)[1];
|
||||
float z5 = terrainCompactTrackValue(w, l - 4)[1];
|
||||
float z6 = terrainCompactTrackValue(w, l - 5)[1];
|
||||
float z7 = terrainCompactTrackValue(w, l - 6)[1];
|
||||
|
||||
List<Float> numbersZ = Arrays.asList(z1, z2, z3, z4, z5, z6, z7);
|
||||
float maxZ = Collections.max(numbersZ);
|
||||
float minZ = Collections.min(numbersZ);
|
||||
|
||||
float diffX = Math.clamp(-15f, 15f, (minX + maxX) / 2);
|
||||
setXRot(Mth.clamp(getXRot() + 0.15f * diffX, -45f, 45f));
|
||||
|
||||
float diffZ = Math.clamp(-15f, 15f, minZ + maxZ);
|
||||
setZRot(Mth.clamp(getRoll() + 0.15f * diffZ, -45f, 45f));
|
||||
} else if (isInWater()) {
|
||||
setXRot(getXRot() * 0.9f);
|
||||
setZRot(getRoll() * 0.9f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCollideHardBlock() {
|
||||
return getDeltaMovement().horizontalDistance() > 0.05 || Mth.abs(this.entityData.get(POWER)) > 0.1;
|
||||
|
@ -690,11 +650,11 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
}
|
||||
|
||||
if (forwardInputDown) {
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + (this.entityData.get(POWER) < 0 ? 0.004f : 0.0024f), 0.21f));
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + (this.entityData.get(POWER) < 0 ? 0.004f : 0.0024f) * (1 + getXRot() / 55), 0.21f));
|
||||
}
|
||||
|
||||
if (backInputDown) {
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.entityData.get(POWER) > 0 ? 0.004f : 0.0024f), -0.16f));
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.entityData.get(POWER) > 0 ? 0.004f : 0.0024f) * (1 - getXRot() / 55), -0.16f));
|
||||
if (rightInputDown) {
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 0.1f);
|
||||
} else if (this.leftInputDown) {
|
||||
|
@ -744,8 +704,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
|
||||
this.setYRot((float) (this.getYRot() - (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT) - i * s0));
|
||||
if (this.isInWater() || onGround()) {
|
||||
float power = this.entityData.get(POWER) * Mth.clamp(1 + (s0 > 0 ? 1 : -1) * getXRot() / 35, 0, 2);
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.13f : (isInWater() && !onGround() ? 2 : 2.4f)) * power)));
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale((!isInWater() && !onGround() ? 0.13f : (isInWater() && !onGround() ? 2 : 2.4f)) * this.entityData.get(POWER))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -910,6 +869,11 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
|||
return transformG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float rotateYOffset() {
|
||||
return 3.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (level() instanceof ServerLevel) {
|
||||
|
|
|
@ -1009,15 +1009,27 @@ public abstract class VehicleEntity extends Entity {
|
|||
}
|
||||
|
||||
// From Immersive_Aircraft
|
||||
public Matrix4f getVehicleTransform(float ticks) {
|
||||
public Matrix4f getVehicleYOffsetTransform(float ticks) {
|
||||
Matrix4f transform = new Matrix4f();
|
||||
transform.translate((float) Mth.lerp(ticks, xo, getX()), (float) Mth.lerp(ticks, yo, getY()), (float) Mth.lerp(ticks, zo, getZ()));
|
||||
transform.translate((float) Mth.lerp(ticks, xo, getX()), (float) Mth.lerp(ticks, yo + rotateYOffset(), getY() + rotateYOffset()), (float) Mth.lerp(ticks, zo, getZ()));
|
||||
transform.rotate(Axis.YP.rotationDegrees(-Mth.lerp(ticks, yRotO, getYRot())));
|
||||
transform.rotate(Axis.XP.rotationDegrees(Mth.lerp(ticks, xRotO, getXRot())));
|
||||
transform.rotate(Axis.ZP.rotationDegrees(Mth.lerp(ticks, prevRoll, getRoll())));
|
||||
return transform;
|
||||
}
|
||||
|
||||
public Matrix4f getVehicleTransform(float ticks) {
|
||||
Matrix4f transformV = getVehicleYOffsetTransform(ticks);
|
||||
Matrix4f transform = new Matrix4f();
|
||||
Vector4f worldPosition = transformPosition(transform, 0, -rotateYOffset(), 0);
|
||||
transformV.translate(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
return transformV;
|
||||
}
|
||||
|
||||
public float rotateYOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Matrix4f getVehicleFlatTransform(float ticks) {
|
||||
Matrix4f transform = new Matrix4f();
|
||||
transform.translate((float) Mth.lerp(ticks, xo, getX()), (float) Mth.lerp(ticks, yo, getY()), (float) Mth.lerp(ticks, zo, getZ()));
|
||||
|
|
Loading…
Add table
Reference in a new issue