优化HUD,音效,简化部分配方
This commit is contained in:
parent
859346998a
commit
2a66820647
11 changed files with 67 additions and 35 deletions
|
@ -2,10 +2,12 @@ package com.atsuishio.superbwarfare.client.overlay;
|
|||
|
||||
import com.atsuishio.superbwarfare.ModUtils;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.IHelicopterEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.MobileVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
@ -18,6 +20,7 @@ import net.minecraft.client.gui.GuiGraphics;
|
|||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -26,6 +29,7 @@ import net.minecraftforge.client.event.RenderGuiEvent;
|
|||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.joml.Math;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
|
@ -33,6 +37,7 @@ import java.text.DecimalFormat;
|
|||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*;
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity.WEAPON_TYPE;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||
public class HelicopterHudOverlay {
|
||||
|
@ -61,6 +66,7 @@ public class HelicopterHudOverlay {
|
|||
if (player.getVehicle() instanceof IHelicopterEntity iHelicopterEntity && player.getVehicle() instanceof MobileVehicleEntity mobileVehicle && iHelicopterEntity.isDriver(player)) {
|
||||
poseStack.pushPose();
|
||||
|
||||
poseStack.translate(-6 * ClientEventHandler.turnRot[1],-6 * ClientEventHandler.turnRot[0],0);
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableBlend();
|
||||
|
@ -78,7 +84,7 @@ public class HelicopterHudOverlay {
|
|||
|
||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/helicopter/heli_base.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
|
||||
renderDriverAngle(guiGraphics, player, mobileVehicle, k, l, i, j);
|
||||
poseStack.pushPose();
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(-iHelicopterEntity.getRotZ(event.getPartialTick())), w / 2f, h / 2f, 0);
|
||||
float pitch = iHelicopterEntity.getRotX(event.getPartialTick());
|
||||
|
@ -103,18 +109,26 @@ public class HelicopterHudOverlay {
|
|||
lerpVy = (float) Mth.lerp(0.021f * event.getPartialTick(), lerpVy, mobileVehicle.getDeltaMovement().y());
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/helicopter/heli_vy_move.png"), (float) w / 2 + 138, ((float) h / 2 - 3 - Math.max(lerpVy * 20, -24) * 2.5f), 0, 0, 8, 8, 8, 8);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##").format(lerpVy * 20) + "m/s"),
|
||||
w / 2 + 146, (int) (h / 2 - 3 - Math.max(lerpVy * 20, -24) * 2.5), (((lerpVy < -20 || lerpVy * 20 < -5 || (lerpVy * 20 < -1 && length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y + 0.06, mobileVehicle.getDeltaMovement().z) * 72 > 100)) && height < 36) || (length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y + 0.06, mobileVehicle.getDeltaMovement().z) * 72 > 40 && blockInWay < 72) ? -65536 : 0x66FF00), false);
|
||||
w / 2 + 146, (int) (h / 2 - 3 - Math.max(lerpVy * 20, -24) * 2.5), (lerpVy * 20 < -24 || ((lerpVy * 20 < -10 || (lerpVy * 20 < -1 && length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 100)) && height < 36) || (length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 40 && blockInWay < 72) ? -65536 : 0x66FF00), false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##").format(mobileVehicle.getY())),
|
||||
w / 2 + 104, h / 2, 0x66FF00, false);
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/helicopter/speed_frame.png"), (float) w / 2 - 144, (float) h / 2 - 6, 0, 0, 50, 18, 50, 18);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(new DecimalFormat("##").format(length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72) + "KM/H"),
|
||||
w / 2 - 140, h / 2, 0x66FF00, false);
|
||||
|
||||
if (lerpVy * 20 < -20) {
|
||||
if (mobileVehicle instanceof Ah6Entity ah6Entity) {
|
||||
if (ah6Entity.getEntityData().get(WEAPON_TYPE) == 0) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())) ? "∞" : ah6Entity.getAmmoCount(player))), w / 2 - 160, h / 2 - 60, 0x66FF00, false);
|
||||
} else {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + ah6Entity.getAmmoCount(player)), w / 2 - 160, h / 2 - 60, 0x66FF00, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (lerpVy * 20 < -24) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("SINK RATE,PULL UP!"),
|
||||
w / 2 - 53, h / 2 + 24, -65536, false);
|
||||
} else if (((lerpVy * 20 < -5 || (lerpVy * 20 < -1 && length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y + 0.06, mobileVehicle.getDeltaMovement().z) * 72 > 100)) && height < 36)
|
||||
|| (length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y + 0.06, mobileVehicle.getDeltaMovement().z) * 72 > 40 && blockInWay < 72)) {
|
||||
} else if (((lerpVy * 20 < -10 || (lerpVy * 20 < -1 && length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 100)) && height < 36)
|
||||
|| (length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 40 && blockInWay < 72)) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("TERRAIN TERRAIN"),
|
||||
w / 2 - 42, h / 2 + 24, -65536, false);
|
||||
}
|
||||
|
@ -186,6 +200,13 @@ public class HelicopterHudOverlay {
|
|||
}
|
||||
}
|
||||
|
||||
private static void renderDriverAngle(GuiGraphics guiGraphics, Player player, Entity heli, float k, float l, float i, float j) {
|
||||
float diffY = Mth.wrapDegrees(player.getYHeadRot() - heli.getYRot()) * 0.35f;
|
||||
float diffX = Mth.wrapDegrees(player.getXRot() - heli.getXRot()) * 0.072f;
|
||||
|
||||
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/helicopter/heli_driver_angle.png"), k + diffY, l + diffX, 0, 0.0F, i, j, i, j);
|
||||
}
|
||||
|
||||
public static Matrix4f getVehicleTransform(VehicleEntity vehicle) {
|
||||
Matrix4f transform = new Matrix4f();
|
||||
transform.translate((float) vehicle.getX(), (float) vehicle.getY(), (float) vehicle.getZ());
|
||||
|
|
|
@ -58,7 +58,7 @@ import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
|
|||
public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHelicopterEntity, MultiWeaponVehicleEntity {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static final float MAX_HEALTH = 400;
|
||||
public static final float MAX_HEALTH = 500;
|
||||
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);
|
||||
|
@ -421,12 +421,12 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
|||
|
||||
ProjectileEntity projectileRight = new ProjectileEntity(player.level())
|
||||
.shooter(player)
|
||||
.damage(25)
|
||||
.damage(18)
|
||||
.headShot(2f)
|
||||
.zoom(false);
|
||||
|
||||
projectileRight.heBullet(true, 3);
|
||||
projectileRight.bypassArmorRate(0.5f);
|
||||
projectileRight.heBullet(true, 2);
|
||||
projectileRight.bypassArmorRate(0.2f);
|
||||
projectileRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z);
|
||||
projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.025, this.getLookAngle().z, 20,
|
||||
(float) 0.2);
|
||||
|
@ -435,12 +435,12 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
|||
|
||||
ProjectileEntity projectileLeft = new ProjectileEntity(player.level())
|
||||
.shooter(player)
|
||||
.damage(25)
|
||||
.damage(18)
|
||||
.headShot(2f)
|
||||
.zoom(false);
|
||||
|
||||
projectileLeft.heBullet(true, 3);
|
||||
projectileLeft.bypassArmorRate(0.5f);
|
||||
projectileLeft.heBullet(true, 2);
|
||||
projectileLeft.bypassArmorRate(0.2f);
|
||||
projectileLeft.setPos(worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z);
|
||||
projectileLeft.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.025, this.getLookAngle().z, 20,
|
||||
(float) 0.2);
|
||||
|
@ -477,7 +477,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
|||
if (fireIndex == 0) {
|
||||
HeliRocketEntity heliRocketEntityRight = new HeliRocketEntity(player, player.level(),
|
||||
140,
|
||||
40,
|
||||
50,
|
||||
5);
|
||||
|
||||
heliRocketEntityRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z);
|
||||
|
@ -487,7 +487,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
|||
} else if (fireIndex == 1) {
|
||||
HeliRocketEntity heliRocketEntityLeft = new HeliRocketEntity(player, player.level(),
|
||||
140,
|
||||
40,
|
||||
50,
|
||||
5);
|
||||
|
||||
heliRocketEntityLeft.setPos(worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z);
|
||||
|
@ -558,7 +558,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
|||
|
||||
@Override
|
||||
public int mainGunRpm() {
|
||||
return 480;
|
||||
return 360;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -183,10 +183,12 @@ 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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.event;
|
|||
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.MobileVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.tools.SeekTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -45,8 +46,11 @@ public class ClientSoundHandler {
|
|||
float distanceReduce;
|
||||
if (e instanceof Ah6Entity ah6Entity) {
|
||||
distanceReduce = (float) (1 - distance / 64);
|
||||
if (player.getVehicle() == ah6Entity) {
|
||||
player.playSound(ModSounds.HELICOPTER_ENGINE_1P.get(), 2 * (mobileVehicle.getEntityData().get(PROPELLER_ROT) - 0.012f), (float) ((2 * Math.random() - 1) * 0.1f + 1.0f));
|
||||
} else {
|
||||
player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (mobileVehicle.getEntityData().get(PROPELLER_ROT) - 0.012f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1.0f), false);
|
||||
// player.displayClientMessage(Component.literal("Angle:" + engineSoundPos), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -359,6 +359,7 @@ public class ModSounds {
|
|||
|
||||
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")));
|
||||
public static final RegistryObject<SoundEvent> HELICOPTER_ENGINE_1P = REGISTRY.register("helicopter_engine_1p", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("helicopter_engine_1p")));
|
||||
public static final RegistryObject<SoundEvent> HELICOPTER_CANNON_FIRE_1P = REGISTRY.register("heli_cannon_fire_1p", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("heli_cannon_fire_1p")));
|
||||
public static final RegistryObject<SoundEvent> HELICOPTER_CANNON_FIRE_3P = REGISTRY.register("heli_cannon_fire_3p", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("heli_cannon_fire_3p")));
|
||||
public static final RegistryObject<SoundEvent> HELICOPTER_CANNON_FAR = REGISTRY.register("heli_cannon_far", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("heli_cannon_far")));
|
||||
|
|
|
@ -2522,6 +2522,13 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"helicopter_engine_1p": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:helicopter/heli_engine_1p"
|
||||
}
|
||||
]
|
||||
},
|
||||
"heli_cannon_fire_1p": {
|
||||
"sounds": [
|
||||
{
|
||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 50 KiB |
|
@ -2,26 +2,26 @@
|
|||
"type": "minecraft:crafting_shaped",
|
||||
"category": "misc",
|
||||
"pattern": [
|
||||
"aba",
|
||||
"aba",
|
||||
"cdc"
|
||||
" a ",
|
||||
"bcd",
|
||||
"bcd"
|
||||
],
|
||||
"key": {
|
||||
"a": {
|
||||
"tag": "forge:plates/copper"
|
||||
},
|
||||
"b": {
|
||||
"item": "minecraft:iron_ingot"
|
||||
},
|
||||
"c": {
|
||||
"item": "minecraft:iron_nugget"
|
||||
},
|
||||
"b": {
|
||||
"item": "minecraft:lapis_lazuli"
|
||||
},
|
||||
"c": {
|
||||
"item": "minecraft:copper_ingot"
|
||||
},
|
||||
"d": {
|
||||
"item": "minecraft:lodestone"
|
||||
"item": "minecraft:redstone"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "superbwarfare:motor",
|
||||
"count": 32
|
||||
"count": 2
|
||||
}
|
||||
}
|
|
@ -2,19 +2,16 @@
|
|||
"type": "minecraft:crafting_shaped",
|
||||
"category": "misc",
|
||||
"pattern": [
|
||||
"aba",
|
||||
" b ",
|
||||
"cdc",
|
||||
"aea"
|
||||
" e "
|
||||
],
|
||||
"key": {
|
||||
"a": {
|
||||
"item": "minecraft:light_blue_concrete"
|
||||
},
|
||||
"b": {
|
||||
"tag": "forge:plates/copper"
|
||||
},
|
||||
"c": {
|
||||
"tag": "forge:stained_glass_panes"
|
||||
"tag": "forge:glass_panes"
|
||||
},
|
||||
"d": {
|
||||
"item": "minecraft:redstone"
|
||||
|
@ -25,6 +22,6 @@
|
|||
},
|
||||
"result": {
|
||||
"item": "superbwarfare:cell",
|
||||
"count": 2
|
||||
"count": 1
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue