翻新快艇机木仓模型,修复yx100乘客武器站无法旋转的问题

This commit is contained in:
Atsuishio 2025-06-25 14:24:06 +08:00 committed by Light_Quanta
parent 91fec828ad
commit 0998f2dc30
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
8 changed files with 10346 additions and 440 deletions

View file

@ -25,8 +25,10 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import net.neoforged.api.distmarker.Dist;
@ -123,7 +125,29 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
this.handleAmmo();
}
this.turretAngle(40, 40);
if (getFirstPassenger() instanceof Player player) {
BlockHitResult result = player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getViewVector(1).scale(512)),
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player));
Vec3 hitPos;
Entity lookingEntity = TraceTool.findLookingEntity(player, 520);
Matrix4f transform = getBarrelTransform(1);
Vector4f worldPosition = transformPosition(transform, 0, 0.20106875f, 1.9117f);
Vec3 shootPos = new Vec3(worldPosition.x + 0.5 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z + 0.5 * this.getDeltaMovement().z);
if (lookingEntity != null) {
hitPos = TraceTool.playerFindLookingPos(player, lookingEntity, 512);
} else {
hitPos = result.getLocation();
}
if (hitPos != null) {
this.turretAutoAimFormVector(40, 40, -25, 50, shootPos.vectorTo(hitPos).normalize());
}
}
this.lowHealthWarning();
this.inertiaRotate(2);
this.terrainCompact(2f, 3f);
@ -159,7 +183,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
Matrix4f transform = getBarrelTransform(1);
float x = 0f;
float y = 0.00106875f;
float y = 0.20106875f;
float z = 1.9117f;
Vector4f worldPosition = transformPosition(transform, x, y, z);
@ -348,8 +372,8 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
}
}
float min = -40f - r * getXRot() - r2 * getRoll();
float max = 20f - r * getXRot() - r2 * getRoll();
float min = -50f - r * getXRot() - r2 * getRoll();
float max = 25f - r * getXRot() - r2 * getRoll();
float f = Mth.wrapDegrees(entity.getXRot());
float f1 = Mth.clamp(f, min, max);

View file

@ -816,8 +816,8 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
}
@Override
public Vec3 getBarrelVec(float ticks) {
Matrix4f transform = getGunnerBarrelTransform(ticks);
public Vec3 getGunnerVector(float pPartialTicks) {
Matrix4f transform = getGunnerBarrelTransform(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));

View file

@ -123,13 +123,13 @@ public class TraceTool {
return null;
}
public static Vec3 playerFindLookingPos(Player player, VehicleEntity vehicle, double entityReach) {
public static Vec3 playerFindLookingPos(Player player, Entity entity, double entityReach) {
double distance = entityReach * entityReach;
HitResult hitResult = player.pick(entityReach, 1.0f, false);
Vec3 viewVec = player.getViewVector(1);
Vec3 toVec = player.getEyePosition().add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
AABB aabb = vehicle.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
AABB aabb = entity.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, player.getEyePosition(), toVec, aabb, p -> true, distance);
if (entityhitresult != null) {
hitResult = entityhitresult;

View file

@ -10,7 +10,6 @@
}
},
"animation.speedboat.fire": {
"loop": "hold_on_last_frame",
"animation_length": 0.15,
"bones": {
"flare": {
@ -39,6 +38,18 @@
"0.0083": [0, 0, 0.85],
"0.0667": [0, 0, 0]
}
},
"bullet_chain": {
"rotation": {
"0.0": [0, 0, 9],
"0.1167": [0, 0, 0],
"0.15": [0, 0, 0]
},
"position": {
"0.0": [0.6, -0.3, 0],
"0.1167": [0, 0, 0],
"0.15": [0, 0, 0]
}
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB