添加载具碰撞受损

This commit is contained in:
Atsuihsio 2025-01-04 18:21:52 +08:00
parent da98bcfcde
commit 81a5cff304
18 changed files with 361 additions and 212 deletions

View file

@ -7,7 +7,6 @@ import com.atsuishio.superbwarfare.entity.MobileVehicleEntity;
import com.atsuishio.superbwarfare.entity.VehicleEntity;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.network.ModVariables;
import com.atsuishio.superbwarfare.tools.HudUtil;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
@ -58,7 +57,7 @@ public class HelicopterHudOverlay {
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit)
return;
if (player.getVehicle() instanceof IHelicopterEntity iHelicopterEntity && player.getVehicle() instanceof MobileVehicleEntity mobileVehicle && iHelicopterEntity.isDriver(player) && Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
if (player.getVehicle() instanceof IHelicopterEntity iHelicopterEntity && player.getVehicle() instanceof MobileVehicleEntity mobileVehicle && iHelicopterEntity.isDriver(player)) {
poseStack.pushPose();
RenderSystem.disableDepthTest();
@ -75,6 +74,8 @@ public class HelicopterHudOverlay {
float j = Mth.floor(f * f1);
float k = ((w - i) / 2);
float l = ((h - j) / 2);
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);
poseStack.pushPose();
@ -116,6 +117,7 @@ public class HelicopterHudOverlay {
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("TERRAIN TERRAIN"),
w / 2 - 42, h / 2 + 24, -65536, false);
}
}
Matrix4f transform = getVehicleTransform(mobileVehicle);
float x0 = 0f;
@ -133,11 +135,21 @@ public class HelicopterHudOverlay {
var cPos = cameraPos.add(lookAngle);
Vec3 p = RenderHelper.worldToScreen(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(event.getPartialTick()).scale(500)), ClientEventHandler.zoom ? cPos : cameraPos);
if (p != null) {
Vec3 p3 = RenderHelper.worldToScreen(new Vec3(worldPosition.x, worldPosition.y, worldPosition.z).add(mobileVehicle.getViewVector(event.getPartialTick()).scale(500)), cameraPos);
if (p != null && p3 != null) {
poseStack.pushPose();
int x = (int) p.x;
int y = (int) p.y;
HudUtil.blit(poseStack, ModUtils.loc("textures/screens/helicopter/crosshair_ind.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16, 0x66FF00);
float x = (float) p.x;
float y = (float) p.y;
float x3 = (float) p3.x;
float y3 = (float) p3.y;
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/helicopter/crosshair_ind.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16);
} else if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
preciseBlit(guiGraphics, ModUtils.loc("textures/screens/drone.png"), x3 - 8, y3 - 8, 0, 0, 16, 16, 16, 16);
}
poseStack.popPose();
}

View file

@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModParticleTypes;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
@ -13,6 +14,7 @@ import com.atsuishio.superbwarfare.tools.EntityFindUtil;
import com.atsuishio.superbwarfare.tools.ParticleTool;
import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
@ -52,10 +54,12 @@ import software.bernie.geckolib.util.GeckoLibUtil;
import java.util.ArrayList;
import java.util.Comparator;
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelicopterEntity, MultiWeaponVehicleEntity {
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public static final float MAX_HEALTH = 200;
public static final float MAX_HEALTH = 300;
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);
@ -65,6 +69,8 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
public float propellerRot;
public float propellerRotO;
public double velocity;
public int fireIndex;
public Ah6Entity(PlayMessages.SpawnEntity packet, Level world) {
@ -102,8 +108,24 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
@Override
public boolean hurt(DamageSource source, float amount) {
super.hurt(source, amount);
if (this.level() instanceof ServerLevel serverLevel) {
sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false);
}
if (source.is(ModDamageTypes.PROJECTILE_BOOM)) {
amount *= 2f;
}
if (source.is(ModDamageTypes.CANNON_FIRE)) {
amount *= 3f;
}
if (source.is(ModDamageTypes.GUN_FIRE)) {
amount *= 0.3f;
}
if (source.is(ModDamageTypes.GUN_FIRE_ABSOLUTE)) {
amount *= 0.7f;
}
this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
this.hurt(amount);
this.hurt(0.75f * Math.max(amount - 5, 0));
return true;
}
@ -115,14 +137,19 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.06, 0.0));
if (this.onGround()) {
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 0.95, 0.6));
this.setDeltaMovement(this.getDeltaMovement().multiply(0.8, 0.95, 0.8));
this.setZRot(this.roll * 0.9f);
this.setXRot(this.getXRot() * 0.9f);
} else {
float f = (float) Mth.clamp(0.945f + 0.02f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale((this.getXRot() < 0 ? -0.032 : 0.032) * this.getDeltaMovement().length())));
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale((this.getXRot() < 0 ? -0.032 : (this.getXRot() > 0 ? 0.032 : 0)) * this.getDeltaMovement().length())));
this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.95, f));
}
if (this.isInWater() && this.tickCount %4 == 0) {
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6, 0.6, 0.6));
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), 26 + (float) (60 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
}
this.refreshDimensions();
}
@ -237,16 +264,7 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
entity.setYBodyRot(this.getYRot());
float f2 = Mth.wrapDegrees(entity.getYRot() - this.getYRot());
int i = this.getPassengers().indexOf(entity);
float f3 = Mth.clamp(f2, -80.0F, 80.0F);
if (i == 2) {
f3 = Mth.clamp(f2, -160.0F, -20.0F);
}
if (i == 3) {
f3 = Mth.clamp(f2, 20.0F, 160.0F);
}
entity.yRotO += f3 - f2;
entity.setYRot(entity.getYRot() + f3 - f2);
entity.setYBodyRot(this.getYRot());
@ -271,47 +289,33 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
float z = 1f;
y += (float) passenger.getMyRidingOffset();
Vector4f worldPosition;
int i = this.getPassengers().indexOf(passenger);
if (i == 0) {
worldPosition = transformPosition(transform, x, y, z);
Vector4f worldPosition = transformPosition(transform, x, y, z);
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
} else if (i == 1) {
worldPosition = transformPosition(transform, -x, y, z);
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
} else if (i == 2) {
worldPosition = transformPosition(transform, x + 1.05f, y - 0.4f, z - 0.8f);
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
} else {
worldPosition = transformPosition(transform, -x - 1.05f, y - 0.4f, z - 0.8f);
Vector4f worldPosition = transformPosition(transform, -x, y, z);
passenger.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
}
if (passenger != this.getFirstPassenger()){
passenger.setYRot(passenger.getYRot() + (getYRot() - yRotO));
passenger.setYHeadRot(passenger.getYHeadRot() + (getYRot() - yRotO));
passenger.setXRot(passenger.getXRot() + (getXRot() - xRotO));
}
callback.accept(passenger, worldPosition.x, worldPosition.y, worldPosition.z);
copyEntityData(passenger);
}
public void copyEntityData(Entity entity) {
entity.setYBodyRot(getYRot());
float f = Mth.wrapDegrees(entity.getYRot() - getYRot());
float g = Mth.clamp(f, -105.0f, 105.0f);
entity.yRotO += g - f;
entity.setYRot(entity.getYRot() + g - f);
entity.setYHeadRot(entity.getYRot());
entity.setYBodyRot(getYRot());
}
@Override
@ -320,7 +324,7 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
}
public int getMaxPassengers() {
return 4;
return 2;
}
@Override
@ -328,12 +332,12 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
if (level() instanceof ServerLevel) {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
CustomExplosion explosion = new CustomExplosion(this.level(), attacker == null ? this : attacker,
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), attacker == null ? this : attacker, attacker == null ? this : attacker), 25.0f,
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), attacker == null ? this : attacker, attacker == null ? this : attacker), 300.0f,
this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
explosion.explode();
ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
ParticleTool.spawnHugeExplosionParticles(this.level(), this.position());
this.discard();
}
}
@ -388,6 +392,7 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y+ 0.03, this.getLookAngle().z, 20,
(float) 0.2);
this.level().addFreshEntity(projectileRight);
ParticleTool.sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionRight.x, worldPositionRight.y, worldPositionRight.z, 1, 0, 0, 0, 0, false);
ProjectileEntity projectileLeft = new ProjectileEntity(player.level())
.shooter(player)
@ -401,6 +406,7 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
projectileLeft.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.03, this.getLookAngle().z, 20,
(float) 0.2);
this.level().addFreshEntity(projectileLeft);
ParticleTool.sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z, 1, 0, 0, 0, 0, false);
if (!player.level().isClientSide) {
if (player instanceof ServerPlayer serverPlayer) {

View file

@ -184,9 +184,6 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
if (this.tickCount % 15 == 0) {
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
}
this.hurt(0.1f);
} else {
this.heal(0.05f);
}
}

View file

@ -237,7 +237,7 @@ public class DroneEntity extends LivingEntity implements GeoEntity {
}
if (this.isInWater()) {
this.hurt(new DamageSource(level().registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(DamageTypes.EXPLOSION), Objects.requireNonNullElse(controller, this)), 0.25f + (float) (2 * lastTickSpeed));
this.hurt(new DamageSource(level().registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(DamageTypes.EXPLOSION), controller), 0.25f + (float) (2 * lastTickSpeed));
}
if (this.fire) {

View file

@ -167,9 +167,6 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit
if (this.tickCount % 15 == 0) {
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
}
this.hurt(0.1f);
} else {
this.heal(0.05f);
}
this.refreshDimensions();

View file

@ -182,9 +182,6 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEn
if (this.tickCount % 15 == 0) {
this.level().playSound(null, this.getOnPos(), SoundEvents.FIRE_AMBIENT, SoundSource.PLAYERS, 1, 1);
}
this.hurt(0.1f);
} else {
this.heal(0.05f);
}
this.refreshDimensions();

View file

@ -4,6 +4,7 @@ import com.atsuishio.superbwarfare.entity.projectile.LaserEntity;
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModSounds;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
@ -20,6 +21,7 @@ import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.entity.EntityTypeTest;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.joml.Math;
import org.joml.Vector3f;
@ -33,6 +35,8 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
public boolean backInputDown;
public boolean upInputDown;
public boolean downInputDown;
public double lastTickSpeed;
public int collisionCoolDown;
public MobileVehicleEntity(EntityType<?> pEntityType, Level pLevel) {
super(pEntityType, pLevel);
@ -52,12 +56,58 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
@Override
public void baseTick() {
lastTickSpeed = new Vec3(this.getDeltaMovement().x, this.getDeltaMovement().y + 0.06, this.getDeltaMovement().z).length();
if (collisionCoolDown > 0) {
collisionCoolDown--;
}
super.baseTick();
crushEntities(this.getDeltaMovement());
this.move(MoverType.SELF, this.getDeltaMovement());
this.refreshDimensions();
}
@Override
public void move(@NotNull MoverType movementType, @NotNull Vec3 movement) {
super.move(movementType, movement);
if (lastTickSpeed < 0.4 || collisionCoolDown > 0) return;
if (horizontalCollision || verticalCollision) {
collisionCoolDown = 4;
}
if ((horizontalCollision)) {
this.bounceHorizontal(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (160 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
if (!this.level().isClientSide) {
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
}
}
if ((verticalCollision)) {
this.bounceVertical(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (100 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
if (!this.level().isClientSide) {
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
}
}
}
private void bounceHorizontal(Direction direction) {
switch (direction.getAxis()) {
case X:
this.setDeltaMovement(this.getDeltaMovement().multiply(-0.8, 0.99, 0.99));
break;
case Z:
this.setDeltaMovement(this.getDeltaMovement().multiply(0.99, 0.99, -0.8));
break;
}
}
private void bounceVertical(Direction direction) {
if (direction.getAxis() == Direction.Axis.Y) {
this.setDeltaMovement(this.getDeltaMovement().multiply(0.9, -0.8, 0.9));
}
}
/**
* 撞击实体并造成伤害
* @param velocity 动量
@ -80,7 +130,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
double f = Math.min(entitySize / thisSize, 2);
double f1 = Math.min(thisSize / entitySize, 4);
if (velocity.horizontalDistance() > 0.4) {
if (velocity.length() > 0.4) {
if (!this.level().isClientSide) {
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
}
@ -88,7 +138,10 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
this.push(-f * velAdd.x, -f * velAdd.y, -f * velAdd.z);
}
entity.push(f1 * velAdd.x, f1 * velAdd.y, f1 * velAdd.z);
entity.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (thisSize * 40 * (velocity.horizontalDistance() - 0.4)));
entity.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (thisSize * 10 * ((velocity.length() - 0.4) * (velocity.length() - 0.4))));
if (entities instanceof VehicleEntity) {
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), entity, entity.getFirstPassenger() == null ? entity : entity.getFirstPassenger()), (float) (entitySize * 10 * ((velocity.length() - 0.4) * (velocity.length() - 0.4))));
}
} else {
entity.push(0.2 * f1 * velAdd.x, 0.2 * f1 * velAdd.y, 0.2 * f1 * velAdd.z);
}

View file

@ -232,7 +232,6 @@ public class SpeedboatEntity extends MobileVehicleEntity implements GeoEntity, I
this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.85, f));
}
this.heal(0.05f);
if (this.level() instanceof ServerLevel serverLevel && this.isInWater() && this.getDeltaMovement().length() > 0.1) {
sendParticle(serverLevel, ParticleTypes.CLOUD, this.getX() + 0.5 * this.getDeltaMovement().x, this.getY() + getSubmergedHeight(this) - 0.2, this.getZ() + 0.5 * this.getDeltaMovement().z, (int) (2 + 4 * this.getDeltaMovement().length()), 0.65, 0, 0.65, 0, true);

View file

@ -1,5 +1,6 @@
package com.atsuishio.superbwarfare.entity;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
import com.google.common.collect.Lists;
@ -166,10 +167,12 @@ public class VehicleEntity extends Entity {
return false;
if (source.is(DamageTypes.IN_FIRE))
return false;
if (source.is(ModDamageTypes.VEHICLE_STRIKE))
amount-= 20;
if (source.getEntity() != null) {
this.entityData.set(LAST_ATTACKER_UUID, source.getEntity().getStringUUID());
}
return true;
return super.hurt(source, amount);
}
public void heal(float pHealAmount) {
@ -251,6 +254,13 @@ public class VehicleEntity extends Entity {
}
travel();
if (this.getHealth() <= 0.1 * this.getMaxHealth()) {
this.hurt(0.1f);
} else {
this.heal(0.05f);
}
this.refreshDimensions();
}

View file

@ -1,13 +1,12 @@
package com.atsuishio.superbwarfare.entity;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModEntities;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
import com.atsuishio.superbwarfare.tools.ParticleTool;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
@ -20,8 +19,9 @@ import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.animal.WaterAnimal;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.NetworkHooks;
@ -37,7 +37,7 @@ import java.util.List;
public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity {
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public static final float MAX_HEALTH = 50;
public static final float MAX_HEALTH = 30;
public static final int MAX_ENERGY = 24000;
public float leftWheelRot;
public float rightWheelRot;
@ -264,14 +264,16 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity {
@Override
public void destroy() {
if (level() instanceof ServerLevel) {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
CustomExplosion explosion = new CustomExplosion(this.level(), attacker == null ? this : attacker,
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), attacker == null ? this : attacker, attacker == null ? this : attacker), 25.0f,
this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
ParticleTool.sendParticle((ServerLevel) this.level(), ParticleTypes.EXPLOSION, this.getX(), this.getY() + 1, this.getZ(), 10, 0.5, 0.5, 0.5, 1, false);
this.level().playSound(null, BlockPos.containing(this.position()), SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 2.0F, (1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F) * 0.7F);
this.setHealth(this.getMaxHealth());
ItemStack container = ContainerBlockItem.createInstance(this);
if (this.level() instanceof ServerLevel level) {
ItemEntity itemEntity = new ItemEntity(level, this.getX(), this.getY(), this.getZ(), container);
itemEntity.setPickUpDelay(10);
level.addFreshEntity(itemEntity);
}
this.remove(RemovalReason.DISCARDED);
this.discard();
}
}

View file

@ -1213,12 +1213,12 @@ public class ClientEventHandler {
ItemStack stack = player.getMainHandItem();
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && zoom) {
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && zoom && mc.options.getCameraType() == CameraType.FIRST_PERSON) {
event.setFOV(event.getFOV() / 5);
return;
}
if (player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && zoom) {
if (player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player && zoom && mc.options.getCameraType() == CameraType.FIRST_PERSON) {
event.setFOV(event.getFOV() / 3);
return;
}

View file

@ -44,8 +44,8 @@ public class ClientSoundHandler {
SoundEvent engineSound = mobileVehicle.getEngineSound();
float distanceReduce;
if (e instanceof Ah6Entity ah6Entity) {
distanceReduce = (float) (1 - distance / 128);
player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 20 * (mobileVehicle.getEntityData().get(POWER) - 0.012f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1.0f), false);
distanceReduce = (float) (1 - distance / 64);
player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (mobileVehicle.getEntityData().get(POWER) - 0.012f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1.0f), false);
// player.displayClientMessage(Component.literal("Angle:" + engineSoundPos), true);
}
}

View file

@ -1052,7 +1052,7 @@
]
},
{
"name": "bone15",
"name": "bone14",
"parent": "huojiandan2",
"pivot": [-27.40359, 10.29818, -11.75905],
"cubes": [
@ -1451,7 +1451,7 @@
]
},
{
"name": "bone14",
"name": "bone15",
"parent": "qiluojia",
"pivot": [-15.17822, 4.39988, -12.35401],
"cubes": [
@ -3029,6 +3029,15 @@
"up": {"uv": [12, 43], "uv_size": [4, 12]}
}
},
{
"origin": [-3.705, 24.6729, 26.52101],
"size": [7.41, 1.95, 9.07437],
"pivot": [0, 25.6479, 31.0582],
"rotation": [-96, 0, 0],
"uv": {
"up": {"uv": [3.25, 89], "uv_size": [6, 6]}
}
},
{
"origin": [-0.78, 47.8535, 28.89815],
"size": [1.56, 9.75, 8.31187],
@ -3942,71 +3951,6 @@
"down": {"uv": [87, 85], "uv_size": [1, -1]}
}
},
{
"origin": [-16.21009, 36.08024, 23.82845],
"size": [29.29875, 7.3125, 7.3125],
"pivot": [-2.04822, 39.98024, 27.24095],
"rotation": [-45, 0, 0],
"uv": {
"north": {"uv": [32, 22], "uv_size": [15, 4]},
"south": {"uv": [40, 26], "uv_size": [15, 4]},
"west": {"uv": [44, 65], "uv_size": [4, 4]},
"up": {"uv": [40, 30], "uv_size": [15, 4]},
"down": {"uv": [41, 38], "uv_size": [15, -4]}
}
},
{
"origin": [13.08866, 37.05524, 24.80345],
"size": [19.5, 5.3625, 5.3625],
"pivot": [-2.04822, 39.98024, 27.24095],
"rotation": [-45, 0, 0],
"uv": {
"north": {"uv": [52, 45], "uv_size": [10, 3]},
"south": {"uv": [53, 21], "uv_size": [10, 3]},
"west": {"uv": [70, 73], "uv_size": [3, 3]},
"up": {"uv": [55, 2], "uv_size": [10, 3]},
"down": {"uv": [55, 8], "uv_size": [10, -3]}
}
},
{
"origin": [32.58866, 37.54274, 25.29095],
"size": [19.5, 4.3875, 4.3875],
"pivot": [-2.04822, 39.98024, 27.24095],
"rotation": [-45, 0, 0],
"uv": {
"north": {"uv": [61, 38], "uv_size": [10, 2]},
"south": {"uv": [61, 40], "uv_size": [10, 2]},
"west": {"uv": [81, 49], "uv_size": [2, 2]},
"up": {"uv": [61, 55], "uv_size": [10, 2]},
"down": {"uv": [61, 59], "uv_size": [10, -2]}
}
},
{
"origin": [52.08866, 38.03024, 25.77845],
"size": [16.575, 3.4125, 3.4125],
"pivot": [-2.04822, 39.98024, 27.24095],
"rotation": [-45, 0, 0],
"uv": {
"north": {"uv": [63, 21], "uv_size": [9, 2]},
"south": {"uv": [63, 63], "uv_size": [9, 2]},
"west": {"uv": [81, 51], "uv_size": [2, 2]},
"up": {"uv": [64, 13], "uv_size": [9, 2]},
"down": {"uv": [65, 4], "uv_size": [9, -2]}
}
},
{
"origin": [68.66366, 38.51774, 26.26595],
"size": [5.85, 2.4375, 2.4375],
"pivot": [-2.04822, 39.98024, 27.24095],
"rotation": [-45, 0, 0],
"uv": {
"north": {"uv": [83, 40], "uv_size": [3, 1]},
"south": {"uv": [83, 41], "uv_size": [3, 1]},
"west": {"uv": [7, 88], "uv_size": [1, 1]},
"up": {"uv": [42, 83], "uv_size": [3, 1]},
"down": {"uv": [45, 84], "uv_size": [3, -1]}
}
},
{
"origin": [68.0038, 38.83289, 22.85345],
"size": [4.7775, 1.95, 1.95],
@ -4171,52 +4115,184 @@
"pivot": [-0.65812, 26.09318, 27.24095],
"cubes": [
{
"origin": [4.56422, 21.70568, 25.42359],
"size": [2.58375, 8.775, 3.63472],
"pivot": [-0.65812, 26.09318, 27.24095],
"rotation": [-90, 0, 0],
"uv": {
"east": {"uv": [21, 72], "uv_size": [2, 5]},
"west": {"uv": [24, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 46], "uv_size": [1, 2]},
"down": {"uv": [47, 87], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 21.70568, 25.42359],
"size": [2.58375, 8.775, 3.63472],
"pivot": [-0.65812, 26.09318, 27.24095],
"rotation": [-135, 0, 0],
"uv": {
"east": {"uv": [9, 72], "uv_size": [2, 5]},
"west": {"uv": [11, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 44], "uv_size": [1, 2]},
"down": {"uv": [46, 87], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 21.70568, 25.42359],
"size": [2.58375, 8.775, 3.63472],
"pivot": [-0.65812, 26.09318, 27.24095],
"rotation": [-45, 0, 0],
"uv": {
"east": {"uv": [26, 72], "uv_size": [2, 5]},
"west": {"uv": [72, 28], "uv_size": [2, 5]},
"up": {"uv": [50, 85], "uv_size": [1, 2]},
"down": {"uv": [85, 55], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 21.70568, 25.42359],
"size": [2.58375, 8.775, 3.63472],
"pivot": [-0.65812, 26.09318, 27.24095],
"origin": [4.56422, 28.70568, 25.42359],
"size": [2.58375, 1.775, 3.63472],
"pivot": [5.85609, 26.60574, 25.49095],
"rotation": [0, 0, 0],
"uv": {
"east": {"uv": [32, 72], "uv_size": [2, 5]},
"west": {"uv": [34, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 57], "uv_size": [1, 2]},
"down": {"uv": [85, 61], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 27.61837, 24.54859],
"size": [2.58375, 1.775, 3.63472],
"pivot": [5.85609, 26.60574, 25.49095],
"rotation": [45, 0, 0],
"uv": {
"west": {"uv": [34, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 57], "uv_size": [1, 2]},
"down": {"uv": [85, 61], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 27.46824, 23.16103],
"size": [2.58375, 1.775, 3.63472],
"pivot": [5.85609, 26.60574, 25.49095],
"rotation": [90, 0, 0],
"uv": {
"west": {"uv": [34, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 57], "uv_size": [1, 2]},
"down": {"uv": [85, 61], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 28.34324, 22.07372],
"size": [2.58375, 1.775, 3.63472],
"pivot": [5.85609, 26.60574, 25.49095],
"rotation": [135, 0, 0],
"uv": {
"west": {"uv": [34, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 57], "uv_size": [1, 2]},
"down": {"uv": [85, 61], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 27.31811, 25.57372],
"size": [2.58375, 1.775, 3.63472],
"pivot": [5.85609, 25.58061, 28.99095],
"rotation": [-45, 0, 0],
"uv": {
"west": {"uv": [34, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 57], "uv_size": [1, 2]},
"down": {"uv": [85, 61], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 26.44311, 26.66103],
"size": [2.58375, 1.775, 3.63472],
"pivot": [5.85609, 25.58061, 28.99095],
"rotation": [-90, 0, 0],
"uv": {
"west": {"uv": [34, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 57], "uv_size": [1, 2]},
"down": {"uv": [85, 61], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 26.59324, 28.04859],
"size": [2.58375, 1.775, 3.63472],
"pivot": [5.85609, 25.58061, 28.99095],
"rotation": [-135, 0, 0],
"uv": {
"west": {"uv": [34, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 57], "uv_size": [1, 2]},
"down": {"uv": [85, 61], "uv_size": [1, -2]}
}
},
{
"origin": [4.56422, 27.68055, 28.92359],
"size": [2.58375, 1.775, 3.63472],
"pivot": [5.85609, 25.58061, 28.99095],
"rotation": [180, 0, 0],
"uv": {
"west": {"uv": [34, 72], "uv_size": [2, 5]},
"up": {"uv": [85, 57], "uv_size": [1, 2]},
"down": {"uv": [85, 61], "uv_size": [1, -2]}
}
}
]
},
{
"name": "bone1",
"parent": "tail",
"pivot": [30.11184, 39.63553, 27.24095],
"rotation": [0, 45, 90],
"cubes": [
{
"origin": [30.93726, -7.04099, 23.41554],
"size": [3, 93.15946, 3],
"inflate": -0.17146,
"pivot": [30.11184, -6.68641, 27.24095],
"rotation": [-1.43502, -0.01797, -1.43502],
"uv": {
"north": {"uv": [0, 89], "uv_size": [0.25, 6]},
"west": {"uv": [0.25, 89], "uv_size": [0.25, 6]},
"up": {"uv": [3, 89], "uv_size": [0.25, 0.25]}
}
},
{
"origin": [30.93726, -7.04099, 23.41554],
"size": [3, 93.15946, 3],
"inflate": -0.17146,
"pivot": [30.11184, -6.68641, 27.24095],
"rotation": [89.28238, -88.56487, -90.71762],
"uv": {
"north": {"uv": [0.5, 89], "uv_size": [0.25, 6]},
"west": {"uv": [0.75, 89], "uv_size": [0.25, 6]},
"up": {"uv": [3, 89.25], "uv_size": [0.25, 0.25]}
}
},
{
"origin": [30.93726, -7.04099, 23.41554],
"size": [3, 93.15946, 3],
"inflate": -0.17146,
"pivot": [30.11184, -6.68641, 27.24095],
"rotation": [178.56498, 0.01797, -178.56498],
"uv": {
"north": {"uv": [1, 89], "uv_size": [0.25, 6]},
"west": {"uv": [1.25, 89], "uv_size": [0.25, 6]},
"up": {"uv": [3, 89.5], "uv_size": [0.25, 0.25]}
}
},
{
"origin": [30.93726, -7.04099, 23.41554],
"size": [3, 93.15946, 3],
"inflate": -0.17146,
"pivot": [30.11184, -6.68641, 27.24095],
"rotation": [-90.71762, 88.56487, -89.28238],
"uv": {
"north": {"uv": [1.5, 89], "uv_size": [0.25, 6]},
"west": {"uv": [1.75, 89], "uv_size": [0.25, 6]},
"up": {"uv": [3, 89.75], "uv_size": [0.25, 0.25]}
}
},
{
"origin": [29.11184, -6.84451, 23.58668],
"size": [2, 92.84982, 1.002],
"pivot": [30.11184, -6.68641, 27.24095],
"rotation": [-1.43502, 0, 0],
"uv": {
"north": {"uv": [2, 89], "uv_size": [0.25, 5.75]}
}
},
{
"origin": [29.11184, -6.84451, 23.58668],
"size": [2, 92.84982, 1.002],
"pivot": [30.11184, -6.68641, 27.24095],
"rotation": [178.56498, 0, 180],
"uv": {
"north": {"uv": [2.25, 89], "uv_size": [0.25, 5.75]}
}
},
{
"origin": [29.11184, -6.84451, 23.58668],
"size": [2, 92.84982, 1.002],
"pivot": [30.11184, -6.68641, 27.24095],
"rotation": [-1.43502, 90, 0],
"uv": {
"north": {"uv": [2.5, 89], "uv_size": [0.25, 5.75]}
}
},
{
"origin": [29.11184, -6.84451, 23.58668],
"size": [2, 92.84982, 1.002],
"pivot": [30.11184, -6.68641, 27.24095],
"rotation": [-1.43502, -90, 0],
"uv": {
"north": {"uv": [2.75, 89], "uv_size": [0.25, 5.75]}
}
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 29 KiB