修复方向舵
This commit is contained in:
parent
edb1738d76
commit
0c5fe01ea4
4 changed files with 4 additions and 23 deletions
|
@ -2,9 +2,7 @@ package com.atsuishio.superbwarfare.client.model.entity;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntity;
|
import com.atsuishio.superbwarfare.entity.SpeedboatEntity;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
|
||||||
import software.bernie.geckolib.core.animation.AnimationState;
|
import software.bernie.geckolib.core.animation.AnimationState;
|
||||||
import software.bernie.geckolib.model.GeoModel;
|
import software.bernie.geckolib.model.GeoModel;
|
||||||
|
@ -12,8 +10,6 @@ import software.bernie.geckolib.model.GeoModel;
|
||||||
import static com.atsuishio.superbwarfare.entity.SpeedboatEntity.*;
|
import static com.atsuishio.superbwarfare.entity.SpeedboatEntity.*;
|
||||||
|
|
||||||
public class SpeedboatModel extends GeoModel<SpeedboatEntity> {
|
public class SpeedboatModel extends GeoModel<SpeedboatEntity> {
|
||||||
public static float lerpRotY = 0f;
|
|
||||||
public float rotorSpeed = 0f;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getAnimationResource(SpeedboatEntity entity) {
|
public ResourceLocation getAnimationResource(SpeedboatEntity entity) {
|
||||||
|
@ -33,15 +29,11 @@ public class SpeedboatModel extends GeoModel<SpeedboatEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomAnimations(SpeedboatEntity animatable, long instanceId, AnimationState<SpeedboatEntity> animationState) {
|
public void setCustomAnimations(SpeedboatEntity animatable, long instanceId, AnimationState<SpeedboatEntity> animationState) {
|
||||||
float times = Minecraft.getInstance().getDeltaFrameTime();
|
|
||||||
|
|
||||||
CoreGeoBone rotor = getAnimationProcessor().getBone("Rotor");
|
CoreGeoBone rotor = getAnimationProcessor().getBone("Rotor");
|
||||||
CoreGeoBone duo = getAnimationProcessor().getBone("duo");
|
CoreGeoBone duo = getAnimationProcessor().getBone("duo");
|
||||||
|
|
||||||
rotor.setRotZ(5 * animatable.getEntityData().get(ROTOR));
|
rotor.setRotZ(5 * animatable.getEntityData().get(ROTOR));
|
||||||
|
duo.setRotY((animatable.getEntityData().get(POWER) > 0 ? 0.5f : -0.5f) * animatable.getEntityData().get(DELTA_ROT));
|
||||||
lerpRotY = Mth.lerp(0.5f * times, lerpRotY, animatable.getEntityData().get(POWER) > 0 ? animatable.getEntityData().get(DELTA_ROT) : -animatable.getEntityData().get(DELTA_ROT));
|
|
||||||
|
|
||||||
duo.setRotY(0.5f * lerpRotY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
||||||
public static final float MAX_HEALTH = CannonConfig.MK42_HP.get();
|
public static final float MAX_HEALTH = CannonConfig.MK42_HP.get();
|
||||||
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
private boolean inputLeft;
|
|
||||||
private boolean inputRight;
|
|
||||||
private boolean inputUp;
|
|
||||||
private boolean inputDown;
|
|
||||||
private int lerpSteps;
|
private int lerpSteps;
|
||||||
private double lerpX;
|
private double lerpX;
|
||||||
private double lerpY;
|
private double lerpY;
|
||||||
|
@ -90,16 +86,10 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
compound.putFloat("Health", this.entityData.get(HEALTH));
|
compound.putFloat("Health", this.entityData.get(HEALTH));
|
||||||
compound.putFloat("Energy", this.entityData.get(ENERGY));
|
compound.putFloat("Energy", this.entityData.get(ENERGY));
|
||||||
compound.putFloat("Power", this.entityData.get(POWER));
|
|
||||||
compound.putFloat("DeltaRot", this.entityData.get(DELTA_ROT));
|
|
||||||
compound.putFloat("Rotor", this.entityData.get(ROTOR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readAdditionalSaveData(CompoundTag compound) {
|
public void readAdditionalSaveData(CompoundTag compound) {
|
||||||
this.entityData.set(ENERGY, compound.getFloat("Energy"));
|
|
||||||
this.entityData.set(POWER, compound.getFloat("Power"));
|
|
||||||
this.entityData.set(DELTA_ROT, compound.getFloat("DeltaRot"));
|
|
||||||
this.entityData.set(ROTOR, compound.getFloat("Rotor"));
|
this.entityData.set(ROTOR, compound.getFloat("Rotor"));
|
||||||
if (compound.contains("Health")) {
|
if (compound.contains("Health")) {
|
||||||
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
||||||
|
@ -298,9 +288,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
||||||
Entity passenger0 = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
Entity passenger0 = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
||||||
|
|
||||||
float diffY = 0;
|
float diffY = 0;
|
||||||
|
|
||||||
diffY = (float) Mth.lerp(0.1 * diffY, diffY, 0);
|
|
||||||
|
|
||||||
if (this.getPersistentData().getBoolean("forward")) {
|
if (this.getPersistentData().getBoolean("forward")) {
|
||||||
this.entityData.set(POWER, this.entityData.get(POWER) + 0.02f);
|
this.entityData.set(POWER, this.entityData.get(POWER) + 0.02f);
|
||||||
}
|
}
|
||||||
|
@ -325,7 +312,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level().isClientSide) {
|
if (level().isClientSide) {
|
||||||
level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), this.getEngineSound(), this.getSoundSource(), Math.min((this.inputUp || this.inputDown ? 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.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entityData.set(POWER, this.entityData.get(POWER) * 0.9f);
|
this.entityData.set(POWER, this.entityData.get(POWER) * 0.9f);
|
||||||
|
|
|
@ -356,6 +356,7 @@
|
||||||
"entity.superbwarfare.mle_1934": "138.6mm50 Mle1934 R1938",
|
"entity.superbwarfare.mle_1934": "138.6mm50 Mle1934 R1938",
|
||||||
"entity.superbwarfare.drone": "Drone",
|
"entity.superbwarfare.drone": "Drone",
|
||||||
"entity.superbwarfare.annihilator": "Annihilator Energy Gun",
|
"entity.superbwarfare.annihilator": "Annihilator Energy Gun",
|
||||||
|
"entity.superbwarfare.speedboat": "Speedboat",
|
||||||
|
|
||||||
"key.categories.superbwarfare": "Superb Warfare",
|
"key.categories.superbwarfare": "Superb Warfare",
|
||||||
"key.superbwarfare.hold_zoom": "Zoom(Hold)",
|
"key.superbwarfare.hold_zoom": "Zoom(Hold)",
|
||||||
|
|
|
@ -356,6 +356,7 @@
|
||||||
"entity.superbwarfare.mle_1934": "138.6mm50 Mle1934 R1938",
|
"entity.superbwarfare.mle_1934": "138.6mm50 Mle1934 R1938",
|
||||||
"entity.superbwarfare.drone": "无人机",
|
"entity.superbwarfare.drone": "无人机",
|
||||||
"entity.superbwarfare.annihilator": "歼灭者能量炮",
|
"entity.superbwarfare.annihilator": "歼灭者能量炮",
|
||||||
|
"entity.superbwarfare.speedboat": "快艇",
|
||||||
|
|
||||||
"key.categories.superbwarfare": "卓越前线",
|
"key.categories.superbwarfare": "卓越前线",
|
||||||
"key.superbwarfare.hold_zoom": "瞄准(按住)",
|
"key.superbwarfare.hold_zoom": "瞄准(按住)",
|
||||||
|
|
Loading…
Add table
Reference in a new issue