添加63式的炮弹模型和摇把音效
This commit is contained in:
parent
e4057e0bd7
commit
e5eff31afc
10 changed files with 54251 additions and 29762 deletions
|
@ -64,6 +64,7 @@ public class ClientRenderHandler {
|
|||
event.registerBelowAll(HelicopterHudOverlay.ID, new HelicopterHudOverlay());
|
||||
event.registerBelowAll(AircraftOverlay.ID, new AircraftOverlay());
|
||||
event.registerBelowAll(MortarInfoOverlay.ID, new MortarInfoOverlay());
|
||||
event.registerBelowAll(Type63InfoOverlay.ID, new Type63InfoOverlay());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.atsuishio.superbwarfare.client.overlay;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Type63Entity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import com.atsuishio.superbwarfare.tools.RangeTool;
|
||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.LayeredDraw;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Type63InfoOverlay implements LayeredDraw.Layer {
|
||||
|
||||
public static final ResourceLocation ID = Mod.loc("type_63_info");
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, @NotNull DeltaTracker deltaTracker) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
var screenWidth = guiGraphics.guiWidth();
|
||||
var screenHeight = guiGraphics.guiHeight();
|
||||
|
||||
Entity lookingEntity = null;
|
||||
if (player != null) {
|
||||
lookingEntity = TraceTool.findLookingEntity(player, 6);
|
||||
}
|
||||
if (lookingEntity instanceof Type63Entity type63Entity) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.pitch")
|
||||
.append(Component.literal(FormatTool.format2D(VehicleEntity.getXRotFromVector(type63Entity.getShootVector(deltaTracker.getGameTimeDeltaPartialTick(true))), "°"))),
|
||||
screenWidth / 2 - 90, screenHeight / 2 - 26, -1, false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.yaw")
|
||||
.append(Component.literal(FormatTool.format2D(-VehicleEntity.getYRotFromVector(type63Entity.getShootVector(deltaTracker.getGameTimeDeltaPartialTick(true))), "°"))),
|
||||
screenWidth / 2 - 90, screenHeight / 2 - 16, -1, false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.range")
|
||||
.append(Component.literal(FormatTool.format1D((int) RangeTool.getRange(VehicleEntity.getXRotFromVector(type63Entity.getShootVector(deltaTracker.getGameTimeDeltaPartialTick(true))), 10, 0.05), "m"))),
|
||||
screenWidth / 2 - 90, screenHeight / 2 - 6, -1, false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -71,6 +71,13 @@ public class Type63Renderer extends GeoEntityRenderer<Type63Entity> {
|
|||
bone.setRotZ(-Mth.lerp(partialTick, animatable.turretYRotO, animatable.getTurretYRot()) * 6);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 11; i++) {
|
||||
var items = animatable.getItemStacks();
|
||||
if (name.equals("shell" + i)) {
|
||||
bone.setHidden(items.get(i).isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
|||
import com.atsuishio.superbwarfare.entity.OBBEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.item.SmallShellItem;
|
||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||
import com.atsuishio.superbwarfare.tools.OBB;
|
||||
|
@ -17,6 +18,7 @@ import net.minecraft.network.syncher.EntityDataSerializers;
|
|||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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;
|
||||
|
@ -117,36 +119,40 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
|||
if (OBB.getLookingObb(player, player.entityInteractionRange()) == hoe1) {
|
||||
if (player.level() instanceof ServerLevel) {
|
||||
setYRot(getYRot() + (float) interactionTick);
|
||||
interactionTick++;
|
||||
interactEvent(new Vec3(hoe1.center()));
|
||||
}
|
||||
player.swing(InteractionHand.MAIN_HAND);
|
||||
}
|
||||
if (OBB.getLookingObb(player, player.entityInteractionRange()) == hoe2) {
|
||||
if (player.level() instanceof ServerLevel) {
|
||||
setYRot(getYRot() - (float) interactionTick);
|
||||
interactionTick++;
|
||||
interactEvent(new Vec3(hoe2.center()));
|
||||
}
|
||||
player.swing(InteractionHand.MAIN_HAND);
|
||||
}
|
||||
if (OBB.getLookingObb(player, player.entityInteractionRange()) == yawController) {
|
||||
if (player.level() instanceof ServerLevel) {
|
||||
interactionTick++;
|
||||
}
|
||||
entityData.set(YAW, Mth.clamp(entityData.get(YAW) + (player.isShiftKeyDown() ? -0.07f : 0.07f) * (float) interactionTick, -15, 15));
|
||||
interactEvent(new Vec3(yawController.center()));
|
||||
entityData.set(YAW, Mth.clamp(entityData.get(YAW) + (player.isShiftKeyDown() ? -0.01f : 0.01f) * (float) interactionTick, -15, 15));
|
||||
player.swing(InteractionHand.MAIN_HAND);
|
||||
}
|
||||
if (OBB.getLookingObb(player, player.entityInteractionRange()) == pitchController) {
|
||||
if (player.level() instanceof ServerLevel) {
|
||||
interactionTick++;
|
||||
}
|
||||
entityData.set(PITCH, Mth.clamp(entityData.get(PITCH) + (player.isShiftKeyDown() ? 0.15f : -0.15f) * (float) interactionTick, -60, 5));
|
||||
interactEvent(new Vec3(pitchController.center()));
|
||||
entityData.set(PITCH, Mth.clamp(entityData.get(PITCH) + (player.isShiftKeyDown() ? 0.02f : -0.02f) * (float) interactionTick, -60, 5));
|
||||
player.swing(InteractionHand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
public void interactEvent(Vec3 vec3) {
|
||||
if (level() instanceof ServerLevel serverLevel) {
|
||||
interactionTick++;
|
||||
if (tickCount % 5 == 0) {
|
||||
serverLevel.playSound(null, vec3.x, vec3.y, vec3.z, ModSounds.HAND_WHEEL_ROT.get(), SoundSource.PLAYERS, 1f, random.nextFloat() * 0.1f + 0.9f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void baseTick() {
|
||||
turretYRotO = this.getTurretYRot();
|
||||
|
@ -244,6 +250,13 @@ public class Type63Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
|||
return transformT;
|
||||
}
|
||||
|
||||
public Vec3 getShootVector(float pPartialTicks) {
|
||||
Matrix4f transform = getBarrelTransform(pPartialTicks);
|
||||
Vector4f rootPosition = transformPosition(transform, 0, 0, 0);
|
||||
Vector4f targetPosition = transformPosition(transform, 0, 0, 1);
|
||||
return new Vec3(rootPosition.x, rootPosition.y, rootPosition.z).vectorTo(new Vec3(targetPosition.x, targetPosition.y, targetPosition.z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||
}
|
||||
|
|
|
@ -496,5 +496,7 @@ public class ModSounds {
|
|||
public static final DeferredHolder<SoundEvent, SoundEvent> STEEL_PIPE_DROP = REGISTRY.register("steel_pipe_drop", () -> SoundEvent.createVariableRangeEvent(Mod.loc("steel_pipe_drop")));
|
||||
public static final DeferredHolder<SoundEvent, SoundEvent> SM0KE_GRENADE_RELEASE = REGISTRY.register("smoke_grenade_release", () -> SoundEvent.createVariableRangeEvent(Mod.loc("smoke_grenade_release")));
|
||||
|
||||
public static final DeferredHolder<SoundEvent, SoundEvent> HAND_WHEEL_ROT = REGISTRY.register("hand_wheel_rot", () -> SoundEvent.createVariableRangeEvent(Mod.loc("hand_wheel_rot")));
|
||||
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3394,5 +3394,17 @@
|
|||
"stream": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"hand_wheel_rot": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "superbwarfare:type63/rot1",
|
||||
"stream": true
|
||||
},
|
||||
{
|
||||
"name": "superbwarfare:type63/rot2",
|
||||
"stream": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
BIN
src/main/resources/assets/superbwarfare/sounds/type63/rot1.ogg
Normal file
BIN
src/main/resources/assets/superbwarfare/sounds/type63/rot1.ogg
Normal file
Binary file not shown.
BIN
src/main/resources/assets/superbwarfare/sounds/type63/rot2.ogg
Normal file
BIN
src/main/resources/assets/superbwarfare/sounds/type63/rot2.ogg
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Loading…
Add table
Reference in a new issue