添加直升机模型和音效
This commit is contained in:
parent
e8a7cd05c9
commit
0f97b5e2b2
16 changed files with 4336 additions and 30 deletions
|
@ -103,8 +103,9 @@ 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() instanceof ICannonEntity)
|
||||
|| (player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && !stack.getItem().isEdible())
|
||||
|| (player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player && stack.is(ItemStack.EMPTY.getItem()))) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ public class Ah6Model extends GeoModel<Ah6Entity> {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(Ah6Entity entity) {
|
||||
return new ResourceLocation(ModUtils.MODID, "geo/wheel_chair.geo.json");
|
||||
return new ResourceLocation(ModUtils.MODID, "geo/ah_6.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(Ah6Entity entity) {
|
||||
return ModUtils.loc("textures/entity/wheel_chair.png");
|
||||
return ModUtils.loc("textures/entity/ah_6.png");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ 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.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
public class Ah6Renderer extends GeoEntityRenderer<Ah6Entity> {
|
||||
|
@ -44,9 +45,15 @@ public class Ah6Renderer extends GeoEntityRenderer<Ah6Entity> {
|
|||
poseStack.popPose();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void renderRecursively(PoseStack poseStack, Ah6Entity 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();
|
||||
// super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
// }
|
||||
@Override
|
||||
public void renderRecursively(PoseStack poseStack, Ah6Entity 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("propeller")) {
|
||||
bone.setRotY(Mth.lerp(partialTick, animatable.propellerRotO, animatable.getPropellerRot()));
|
||||
}
|
||||
if (name.equals("tailPropeller")) {
|
||||
bone.setRotX(-6 * Mth.lerp(partialTick, animatable.propellerRotO, animatable.getPropellerRot()));
|
||||
}
|
||||
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,11 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
|||
public static final float MAX_HEALTH = 200;
|
||||
public static final int MAX_ENERGY = 4000000;
|
||||
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Float> PROPELLER_ROT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.FLOAT);
|
||||
public boolean engineStart;
|
||||
public boolean engineStartOver;
|
||||
public float propellerRot;
|
||||
public float propellerRotO;
|
||||
|
||||
public Ah6Entity(PlayMessages.SpawnEntity packet, Level world) {
|
||||
this(ModEntities.AH_6.get(), world);
|
||||
|
@ -57,6 +62,7 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
|||
protected void defineSynchedData() {
|
||||
super.defineSynchedData();
|
||||
this.entityData.define(DELTA_ROT, 0f);
|
||||
this.entityData.define(PROPELLER_ROT, 0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,6 +90,8 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
|||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
propellerRotO = this.getPropellerRot();
|
||||
|
||||
super.baseTick();
|
||||
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.06, 0.0));
|
||||
|
@ -114,11 +122,11 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
|||
this.setXRot(this.getXRot() * 0.8f);
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) * 0.98f);
|
||||
} else if (passenger instanceof Player player) {
|
||||
if (level().isClientSide && this.getEnergy() > 0) {
|
||||
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);
|
||||
}
|
||||
// if (level().isClientSide && this.getEnergy() > 0) {
|
||||
// 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);
|
||||
// }
|
||||
|
||||
diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(passenger.getYHeadRot() - this.getYRot()));
|
||||
diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(passenger.getYRot() - this.getYRot()));
|
||||
diffX = Math.clamp(-60f, 60f, Mth.wrapDegrees(passenger.getXRot() - this.getXRot()));
|
||||
|
||||
if (rightInputDown) {
|
||||
|
@ -127,32 +135,47 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
|||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 0.15f);
|
||||
}
|
||||
|
||||
this.setYRot(this.getYRot() + Mth.clamp((this.onGround() ? 0.1f : 0.6f) * diffY * this.entityData.get(POWER) + 0.5f * this.entityData.get(DELTA_ROT), -3f, 3f));
|
||||
this.setYRot(this.getYRot() + Mth.clamp((this.onGround() ? 0.1f : 0.7f) * diffY * this.entityData.get(POWER) + 0.5f * this.entityData.get(DELTA_ROT), -5f, 5f));
|
||||
this.setXRot(Mth.clamp(this.getXRot() + (this.onGround() ? 0 : 0.6f) * diffX * this.entityData.get(POWER), -80, 80));
|
||||
this.setZRot(Mth.clamp(this.getRoll() - this.entityData.get(DELTA_ROT) + (this.onGround() ? 0 : 0.2f) * diffY * this.entityData.get(POWER), -50, 50));
|
||||
|
||||
if (this.level() instanceof ServerLevel) {
|
||||
if (this.upInputDown || this.forwardInputDown) {
|
||||
boolean up = this.upInputDown || this.forwardInputDown;
|
||||
boolean down = this.downInputDown || this.backInputDown;
|
||||
|
||||
|
||||
if (!engineStart && up) {
|
||||
engineStart = true;
|
||||
this.level().playSound(null, this, ModSounds.HELICOPTER_ENGINE_START.get(), this.getSoundSource(), 3, 1);
|
||||
}
|
||||
|
||||
if (up && engineStartOver) {
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.002f, 0.12f));
|
||||
}
|
||||
|
||||
if (this.downInputDown || this.backInputDown) {
|
||||
if (down && engineStartOver) {
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0015f, this.onGround() ? 0 : 0.0375f));
|
||||
}
|
||||
|
||||
if (engineStart && !engineStartOver) {
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.0012f, 0.045f));
|
||||
}
|
||||
|
||||
// player.displayClientMessage(Component.literal("Angle:" + new java.text.DecimalFormat("##.##").format(this.getDeltaMovement().y())), true);
|
||||
|
||||
if(!(this.upInputDown || this.forwardInputDown || this.downInputDown || this.backInputDown)) {
|
||||
if(!(up || down) && engineStartOver) {
|
||||
if (this.getDeltaMovement().y() + 0.06 < 0) {
|
||||
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.0002f, 0.12f));
|
||||
} else {
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0006f, 0));
|
||||
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - (this.onGround() ? 0.00005f : 0.0006f), 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.95f);
|
||||
this.entityData.set(PROPELLER_ROT, Mth.lerp(0.0001f, this.entityData.get(POWER), this.entityData.get(POWER)));
|
||||
this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(PROPELLER_ROT));
|
||||
|
||||
setDeltaMovement(getDeltaMovement().add(0.0f, Math.min(Math.sin((90 - this.getXRot()) * Mth.DEG_TO_RAD), Math.sin((90 + this.getRoll()) * Mth.DEG_TO_RAD)) * this.entityData.get(POWER), 0.0f));
|
||||
|
||||
|
@ -161,11 +184,31 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
|||
|
||||
Vector3f directionZ = getForwardDirection().mul(-Math.cos((this.getXRot() + 90) * Mth.DEG_TO_RAD) * this.entityData.get(POWER));
|
||||
setDeltaMovement(getDeltaMovement().add(new Vec3(directionZ.x, directionZ.y, directionZ.z).scale(0.35)));
|
||||
}
|
||||
|
||||
if (this.entityData.get(POWER) > 0.04f) {
|
||||
engineStartOver = true;
|
||||
}
|
||||
|
||||
if (this.entityData.get(POWER) < 0.0004f) {
|
||||
engineStart = false;
|
||||
engineStartOver = false;
|
||||
}
|
||||
|
||||
if (level().isClientSide) {
|
||||
level().playLocalSound(this.getX() + this.getDeltaMovement().x, this.getY() + this.getBbHeight() + this.getDeltaMovement().y + 0.06, this.getZ() + this.getDeltaMovement().z, this.getEngineSound(), this.getSoundSource(), Math.max((this.upInputDown? 10f : 3f) * 6 * this.entityData.get(POWER) - 0.038f, 0), (random.nextFloat() * 0.1f + 1.0f), false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public SoundEvent getEngineSound() {
|
||||
return ModSounds.WHEEL_CHAIR_ENGINE.get();
|
||||
return ModSounds.HELICOPTER_ENGINE.get();
|
||||
}
|
||||
|
||||
public float getPropellerRot() {
|
||||
return this.propellerRot;
|
||||
}
|
||||
|
||||
public void setPropellerRot(float pPropellerRot) {
|
||||
this.propellerRot = pPropellerRot;
|
||||
}
|
||||
|
||||
protected void clampRotation(Entity entity) {
|
||||
|
@ -176,7 +219,7 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
|||
|
||||
entity.setYBodyRot(this.getYRot());
|
||||
float f2 = Mth.wrapDegrees(entity.getYRot() - this.getYRot());
|
||||
float f3 = Mth.clamp(f2, -60.0F, 60.0F);
|
||||
float f3 = Mth.clamp(f2, -80.0F, 80.0F);
|
||||
entity.yRotO += f3 - f2;
|
||||
entity.setYRot(entity.getYRot() + f3 - f2);
|
||||
entity.setYHeadRot(entity.getYRot());
|
||||
|
@ -196,10 +239,9 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
|
|||
|
||||
Matrix4f transform = getVehicleTransform();
|
||||
|
||||
float x = 0;
|
||||
float y = 0.8f;
|
||||
float z = 0;
|
||||
|
||||
float x = 0.45f;
|
||||
float y = 1.2f;
|
||||
float z = 1f;
|
||||
|
||||
y += (float) passenger.getMyRidingOffset();
|
||||
|
||||
|
|
|
@ -119,12 +119,10 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
|||
@Override
|
||||
protected void readAdditionalSaveData(CompoundTag compound) {
|
||||
super.readAdditionalSaveData(compound);
|
||||
this.entityData.set(POWER, compound.getFloat("Power"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compound) {
|
||||
super.addAdditionalSaveData(compound);
|
||||
compound.putFloat("Power", this.entityData.get(POWER));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -796,11 +796,15 @@ public class ClientEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
if (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity) {
|
||||
if (player.getVehicle() instanceof ICannonEntity) {
|
||||
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() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && !stack.getItem().isEdible()) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if ((player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player) && ClientEventHandler.zoom && stack.is(ItemStack.EMPTY.getItem())) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
@ -1200,6 +1204,11 @@ public class ClientEventHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
if (player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && zoom) {
|
||||
event.setFOV(event.getFOV() / 3);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stack.is(ModTags.Items.GUN)) {
|
||||
if (!event.usedConfiguredFov()) {
|
||||
return;
|
||||
|
|
|
@ -66,7 +66,7 @@ public class ModEntities {
|
|||
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));
|
||||
public static final RegistryObject<EntityType<Ah6Entity>> AH_6 = register("ah_6",
|
||||
EntityType.Builder.<Ah6Entity>of(Ah6Entity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(Ah6Entity::new).fireImmune().sized(1.0f, 1.0f));
|
||||
EntityType.Builder.<Ah6Entity>of(Ah6Entity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(true).setTrackingRange(512).setUpdateInterval(3).setCustomClientFactory(Ah6Entity::new).fireImmune().sized(2.8f, 2.9f));
|
||||
|
||||
private static <T extends Entity> RegistryObject<EntityType<T>> register(String name, EntityType.Builder<T> entityTypeBuilder) {
|
||||
return REGISTRY.register(name, () -> entityTypeBuilder.build(name));
|
||||
|
|
|
@ -356,5 +356,8 @@ public class ModSounds {
|
|||
public static final RegistryObject<SoundEvent> RADAR_SEARCH_START = REGISTRY.register("radar_search_start", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("radar_search_start")));
|
||||
public static final RegistryObject<SoundEvent> RADAR_SEARCH_IDLE = REGISTRY.register("radar_search_idle", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("radar_search_idle")));
|
||||
public static final RegistryObject<SoundEvent> RADAR_SEARCH_END = REGISTRY.register("radar_search_end", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("radar_search_end")));
|
||||
|
||||
public static final RegistryObject<SoundEvent> HELICOPTER_ENGINE_START = REGISTRY.register("helicopter_engine_start", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("helicopter_engine_start")));
|
||||
public static final RegistryObject<SoundEvent> HELICOPTER_ENGINE = REGISTRY.register("helicopter_engine", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("helicopter_engine")));
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,10 @@ public abstract class CameraMixin {
|
|||
move(-getMaxZoom(3), 1, 0.0);
|
||||
return;
|
||||
}
|
||||
if (thirdPerson && entity.getVehicle() instanceof Ah6Entity) {
|
||||
move(-getMaxZoom(6), 1, -2.0);
|
||||
return;
|
||||
}
|
||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && entity instanceof Player player && player.getMainHandItem().is(ModTags.Items.GUN)) {
|
||||
move(-getMaxZoom(-2.9 * Math.max(ClientEventHandler.pullPos, ClientEventHandler.zoomPos)), 0, -ClientEventHandler.cameraLocation * Math.max(ClientEventHandler.pullPos, ClientEventHandler.zoomPos));
|
||||
}
|
||||
|
|
4226
src/main/resources/assets/superbwarfare/geo/ah_6.geo.json
Normal file
4226
src/main/resources/assets/superbwarfare/geo/ah_6.geo.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -370,6 +370,7 @@
|
|||
"entity.superbwarfare.annihilator": "Annihilator Energy Gun",
|
||||
"entity.superbwarfare.speedboat": "Speedboat",
|
||||
"entity.superbwarfare.wheel_chair": "WheelChair",
|
||||
"entity.superbwarfare.ah_6": "AH-6 Little Bird",
|
||||
|
||||
"key.categories.superbwarfare": "Superb Warfare",
|
||||
"key.superbwarfare.hold_zoom": "Zoom(Hold)",
|
||||
|
|
|
@ -370,6 +370,7 @@
|
|||
"entity.superbwarfare.annihilator": "歼灭者能量炮",
|
||||
"entity.superbwarfare.speedboat": "快艇",
|
||||
"entity.superbwarfare.wheel_chair": "轮椅",
|
||||
"entity.superbwarfare.ah_6": "AH-6 小鸟直升机",
|
||||
|
||||
"key.categories.superbwarfare": "卓越前线",
|
||||
"key.superbwarfare.hold_zoom": "瞄准(按住)",
|
||||
|
|
|
@ -2507,5 +2507,19 @@
|
|||
"name": "superbwarfare:radar/radar_search_end"
|
||||
}
|
||||
]
|
||||
},
|
||||
"helicopter_engine_start": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:helicopter/heli_engine_start"
|
||||
}
|
||||
]
|
||||
},
|
||||
"helicopter_engine": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:helicopter/heli_engine"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
BIN
src/main/resources/assets/superbwarfare/textures/entity/ah_6.png
Normal file
BIN
src/main/resources/assets/superbwarfare/textures/entity/ah_6.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Add table
Reference in a new issue