调整部分代码
This commit is contained in:
parent
adc202a288
commit
48439a2d6c
5 changed files with 38 additions and 99 deletions
|
@ -22,7 +22,6 @@ import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Explosion;
|
import net.minecraft.world.level.Explosion;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
import software.bernie.geckolib.animatable.GeoEntity;
|
import software.bernie.geckolib.animatable.GeoEntity;
|
||||||
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
||||||
import software.bernie.geckolib.core.animation.AnimatableManager;
|
import software.bernie.geckolib.core.animation.AnimatableManager;
|
||||||
|
@ -38,10 +37,8 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
protected static final EntityDataAccessor<Optional<UUID>> OWNER_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.OPTIONAL_UUID);
|
protected static final EntityDataAccessor<Optional<UUID>> OWNER_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.OPTIONAL_UUID);
|
||||||
protected static final EntityDataAccessor<String> LAST_ATTACKER_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.STRING);
|
protected static final EntityDataAccessor<String> LAST_ATTACKER_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.STRING);
|
||||||
protected static final EntityDataAccessor<Optional<UUID>> TARGET_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.OPTIONAL_UUID);
|
protected static final EntityDataAccessor<Optional<UUID>> TARGET_UUID = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.OPTIONAL_UUID);
|
||||||
protected static final EntityDataAccessor<Float> REL_X = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.FLOAT);
|
|
||||||
protected static final EntityDataAccessor<Float> REL_Y = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.FLOAT);
|
|
||||||
protected static final EntityDataAccessor<Float> REL_Z = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.FLOAT);
|
|
||||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(C4Entity.class, EntityDataSerializers.FLOAT);
|
||||||
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
public C4Entity(EntityType<C4Entity> type, Level world) {
|
public C4Entity(EntityType<C4Entity> type, Level world) {
|
||||||
|
@ -52,12 +49,6 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
public C4Entity(LivingEntity owner, Level level) {
|
public C4Entity(LivingEntity owner, Level level) {
|
||||||
super(ModEntities.C_4.get(), level);
|
super(ModEntities.C_4.get(), level);
|
||||||
this.setOwnerUUID(owner.getUUID());
|
this.setOwnerUUID(owner.getUUID());
|
||||||
ModUtils.queueServerWork(1, () -> {
|
|
||||||
if (this.level().isClientSide()) return;
|
|
||||||
CompoundTag compoundTag = owner.serializeNBT();
|
|
||||||
compoundTag.putUUID("C4UUID", this.getUUID());
|
|
||||||
this.getOwner().deserializeNBT(compoundTag);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,9 +57,6 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
this.entityData.define(LAST_ATTACKER_UUID, "undefined");
|
this.entityData.define(LAST_ATTACKER_UUID, "undefined");
|
||||||
this.entityData.define(HEALTH, 10f);
|
this.entityData.define(HEALTH, 10f);
|
||||||
this.entityData.define(TARGET_UUID, Optional.empty());
|
this.entityData.define(TARGET_UUID, Optional.empty());
|
||||||
this.entityData.define(REL_X, 0.0f);
|
|
||||||
this.entityData.define(REL_Y, 0.0f);
|
|
||||||
this.entityData.define(REL_Z, 0.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,9 +97,6 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID));
|
compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID));
|
||||||
if (this.getTargetUUID() != null) {
|
if (this.getTargetUUID() != null) {
|
||||||
compound.putUUID("Target", this.getTargetUUID());
|
compound.putUUID("Target", this.getTargetUUID());
|
||||||
compound.putFloat("RelativeX", this.entityData.get(REL_X));
|
|
||||||
compound.putFloat("RelativeY", this.entityData.get(REL_Y));
|
|
||||||
compound.putFloat("RelativeZ", this.entityData.get(REL_Z));
|
|
||||||
}
|
}
|
||||||
if (this.getOwnerUUID() != null) {
|
if (this.getOwnerUUID() != null) {
|
||||||
compound.putUUID("Owner", this.getOwnerUUID());
|
compound.putUUID("Owner", this.getOwnerUUID());
|
||||||
|
@ -141,12 +126,11 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
try {
|
try {
|
||||||
this.setOwnerUUID(uuid);
|
this.setOwnerUUID(uuid);
|
||||||
} catch (Throwable ignored){}
|
} catch (Throwable ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Target
|
||||||
* Target
|
|
||||||
**/
|
|
||||||
if (compound.hasUUID("Target")) {
|
if (compound.hasUUID("Target")) {
|
||||||
uuid = compound.getUUID("Target");
|
uuid = compound.getUUID("Target");
|
||||||
} else {
|
} else {
|
||||||
|
@ -159,11 +143,8 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
try {
|
try {
|
||||||
this.setTargetUUID(uuid);
|
this.setTargetUUID(uuid);
|
||||||
|
} catch (Throwable ignored) {
|
||||||
this.entityData.set(REL_X, compound.getFloat("RelativeX"));
|
}
|
||||||
this.entityData.set(REL_Y, compound.getFloat("RelativeY"));
|
|
||||||
this.entityData.set(REL_Z, compound.getFloat("RelativeZ"));
|
|
||||||
} catch (Throwable ignored){}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,14 +152,10 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
return this.onGround() || this.getTargetUUID() != null;
|
return this.onGround() || this.getTargetUUID() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
var level = this.level();
|
Level level = this.level();
|
||||||
var x = this.getX();
|
|
||||||
var y = this.getY();
|
|
||||||
var z = this.getZ();
|
|
||||||
|
|
||||||
if (this.tickCount >= ExplosionConfig.C4_EXPLOSION_COUNTDOWN.get()) {
|
if (this.tickCount >= ExplosionConfig.C4_EXPLOSION_COUNTDOWN.get()) {
|
||||||
this.explode();
|
this.explode();
|
||||||
|
@ -193,7 +170,7 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
if (this.getUUID() == target.getUUID() || this.getOwnerUUID() == target.getUUID() || !(target instanceof LivingEntity || target instanceof VehicleEntity)) {
|
if (this.getUUID() == target.getUUID() || this.getOwnerUUID() == target.getUUID() || !(target instanceof LivingEntity || target instanceof VehicleEntity)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this.setTargetUUID(target.getUUID());;
|
this.setTargetUUID(target.getUUID());
|
||||||
|
|
||||||
// var relpos = this.calcRelativePos(target);
|
// var relpos = this.calcRelativePos(target);
|
||||||
// this.setRelativePos(((float) relpos.x), ((float) relpos.y), ((float) relpos.z));
|
// this.setRelativePos(((float) relpos.x), ((float) relpos.y), ((float) relpos.z));
|
||||||
|
@ -206,26 +183,22 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ModUtils.queueServerWork(1, () -> {
|
if (level.isClientSide()) return;
|
||||||
if (level.isClientSide()) return;
|
if (this.getTargetUUID() == null) {
|
||||||
if (this.getTargetUUID() == null) {
|
this.destroy();
|
||||||
this.destroy();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
Entity target = EntityFindUtil.findEntity(this.level(), this.getTargetUUID().toString());
|
||||||
Entity target = EntityFindUtil.findEntity(this.level(), this.getTargetUUID().toString());
|
if (target == null) {
|
||||||
if (target == null) {
|
this.destroy();
|
||||||
this.destroy();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (!this.isInvisible()) {
|
||||||
if (!this.isInvisible()) {
|
this.setInvisible(true);
|
||||||
this.setInvisible(true);
|
}
|
||||||
}
|
this.setPos(target.position().x, target.position().y + target.getBoundingBox().getYsize(), target.position().z);
|
||||||
this.setPos(target.position().x, target.position().y + target.getBoundingBox().getYsize(), target.position().z);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,23 +216,6 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getRelativePos() {
|
|
||||||
if (this.isPlaced()) {
|
|
||||||
return new Vec3(this.entityData.get(REL_X), this.entityData.get(REL_Y), this.entityData.get(REL_Z));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vec3 calcRelativePos(Entity target) {
|
|
||||||
return this.position().subtract(target.position());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRelativePos(float x, float y, float z) {
|
|
||||||
this.entityData.set(REL_X, x);
|
|
||||||
this.entityData.set(REL_X, y);
|
|
||||||
this.entityData.set(REL_X, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (this.level() instanceof ServerLevel && this.tickCount < ExplosionConfig.C4_EXPLOSION_COUNTDOWN.get()) {
|
if (this.level() instanceof ServerLevel && this.tickCount < ExplosionConfig.C4_EXPLOSION_COUNTDOWN.get()) {
|
||||||
ItemEntity c4 = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), new ItemStack(ModItems.C4_BOMB.get()));
|
ItemEntity c4 = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), new ItemStack(ModItems.C4_BOMB.get()));
|
||||||
|
@ -275,7 +231,7 @@ public class C4Entity extends Entity implements GeoEntity, AnimatedEntity, Ownab
|
||||||
target.getX(), target.getY(), target.getZ(), ExplosionConfig.C4_EXPLOSION_RADIUS.get(), ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
target.getX(), target.getY(), target.getZ(), ExplosionConfig.C4_EXPLOSION_RADIUS.get(), ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(level(), explosion);
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(level(), explosion);
|
||||||
ParticleTool.spawnHugeExplosionParticles(level(),position());
|
ParticleTool.spawnHugeExplosionParticles(level(), position());
|
||||||
explosion.finalizeExplosion(false);
|
explosion.finalizeExplosion(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
|
||||||
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.FLOAT);
|
||||||
public static final EntityDataAccessor<Float> DELTA_X_ROT = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> DELTA_X_ROT = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.FLOAT);
|
||||||
public static final EntityDataAccessor<Float> PROPELLER_ROT = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> PROPELLER_ROT = SynchedEntityData.defineId(DroneEntity.class, EntityDataSerializers.FLOAT);
|
||||||
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
public static final float MAX_HEALTH = 5;
|
public static final float MAX_HEALTH = 5;
|
||||||
|
|
||||||
|
|
|
@ -63,13 +63,14 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
public static final float MAX_HEALTH = VehicleConfig.AH_6_HP.get();
|
public static final float MAX_HEALTH = VehicleConfig.AH_6_HP.get();
|
||||||
public static final int MAX_ENERGY = VehicleConfig.AH_6_MAX_ENERGY.get();
|
public static final int MAX_ENERGY = VehicleConfig.AH_6_MAX_ENERGY.get();
|
||||||
|
|
||||||
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.FLOAT);
|
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 static final EntityDataAccessor<Float> PROPELLER_ROT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.FLOAT);
|
||||||
public static final EntityDataAccessor<Integer> WEAPON_TYPE = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> WEAPON_TYPE = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT);
|
||||||
|
|
||||||
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Integer> DECOY_COUNT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> DECOY_COUNT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Integer> LOADED_ROCKET = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> LOADED_ROCKET = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT);
|
||||||
|
|
||||||
public boolean engineStart;
|
public boolean engineStart;
|
||||||
public boolean engineStartOver;
|
public boolean engineStartOver;
|
||||||
public float propellerRot;
|
public float propellerRot;
|
||||||
|
@ -106,16 +107,16 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
super.addAdditionalSaveData(compound);
|
super.addAdditionalSaveData(compound);
|
||||||
compound.putInt("LoadedRocket", this.entityData.get(LOADED_ROCKET));
|
compound.putInt("LoadedRocket", this.entityData.get(LOADED_ROCKET));
|
||||||
compound.putFloat("propellerRot", this.entityData.get(PROPELLER_ROT));
|
compound.putFloat("PropellerRot", this.entityData.get(PROPELLER_ROT));
|
||||||
compound.putInt("decoyCount", this.entityData.get(DECOY_COUNT));
|
compound.putInt("DecoyCount", this.entityData.get(DECOY_COUNT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readAdditionalSaveData(CompoundTag compound) {
|
public void readAdditionalSaveData(CompoundTag compound) {
|
||||||
super.readAdditionalSaveData(compound);
|
super.readAdditionalSaveData(compound);
|
||||||
this.entityData.set(LOADED_ROCKET, compound.getInt("LoadedRocket"));
|
this.entityData.set(LOADED_ROCKET, compound.getInt("LoadedRocket"));
|
||||||
this.entityData.set(PROPELLER_ROT, compound.getFloat("propellerRot"));
|
this.entityData.set(PROPELLER_ROT, compound.getFloat("PropellerRot"));
|
||||||
this.entityData.set(DECOY_COUNT, compound.getInt("decoyCount"));
|
this.entityData.set(DECOY_COUNT, compound.getInt("DecoyCount"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -227,7 +228,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
||||||
Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
Entity passenger = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
FlareDecoyEntity flareDecoyEntity = new FlareDecoyEntity((LivingEntity) passenger, this.level());
|
FlareDecoyEntity flareDecoyEntity = new FlareDecoyEntity((LivingEntity) passenger, this.level());
|
||||||
flareDecoyEntity.setPos(this.getX() + this.getDeltaMovement().x, this.getY() + 0.5 + this.getDeltaMovement().y, this.getZ()+ this.getDeltaMovement().z);
|
flareDecoyEntity.setPos(this.getX() + this.getDeltaMovement().x, this.getY() + 0.5 + this.getDeltaMovement().y, this.getZ() + this.getDeltaMovement().z);
|
||||||
flareDecoyEntity.decoyShoot(this, this.getViewVector(1).yRot((45 + 90 * i) * Mth.DEG_TO_RAD), 0.8f, 8);
|
flareDecoyEntity.decoyShoot(this, this.getViewVector(1).yRot((45 + 90 * i) * Mth.DEG_TO_RAD), 0.8f, 8);
|
||||||
this.level().addFreshEntity(flareDecoyEntity);
|
this.level().addFreshEntity(flareDecoyEntity);
|
||||||
}
|
}
|
||||||
|
@ -239,16 +240,11 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
||||||
}
|
}
|
||||||
decoyInputDown = false;
|
decoyInputDown = false;
|
||||||
}
|
}
|
||||||
if (this.entityData.get(DECOY_COUNT) < 6 && decoyReloadCoolDown == 0 && this.level() instanceof ServerLevel) {
|
if (this.entityData.get(DECOY_COUNT) < 6 && decoyReloadCoolDown == 0 && this.level() instanceof ServerLevel) {
|
||||||
this.entityData.set(DECOY_COUNT, this.entityData.get(DECOY_COUNT) + 1);
|
this.entityData.set(DECOY_COUNT, this.entityData.get(DECOY_COUNT) + 1);
|
||||||
this.level().playSound(null, this, ModSounds.DECOY_RELOAD.get(), this.getSoundSource(), 1, 1);
|
this.level().playSound(null, this, ModSounds.DECOY_RELOAD.get(), this.getSoundSource(), 1, 1);
|
||||||
decoyReloadCoolDown = 300;
|
decoyReloadCoolDown = 300;
|
||||||
}
|
}
|
||||||
// Player player = (Player) this.getFirstPassenger();
|
|
||||||
//
|
|
||||||
// if (player != null) {
|
|
||||||
// player.displayClientMessage(Component.literal( new DecimalFormat("##").format(this.getEntityData().get(DECOY_COUNT))), true);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -266,7 +262,6 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
||||||
this.setXRot(this.getXRot() * 0.8f);
|
this.setXRot(this.getXRot() * 0.8f);
|
||||||
this.entityData.set(POWER, this.entityData.get(POWER) * 0.98f);
|
this.entityData.set(POWER, this.entityData.get(POWER) * 0.98f);
|
||||||
} else if (passenger instanceof Player) {
|
} else if (passenger instanceof Player) {
|
||||||
|
|
||||||
diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(passenger.getYHeadRot() - this.getYRot()));
|
diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(passenger.getYHeadRot() - this.getYRot()));
|
||||||
diffX = Math.clamp(-60f, 60f, Mth.wrapDegrees(passenger.getXRot() - this.getXRot()));
|
diffX = Math.clamp(-60f, 60f, Mth.wrapDegrees(passenger.getXRot() - this.getXRot()));
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,6 @@ public class ContainerMobileEntity extends MobileVehicleEntity implements HasCus
|
||||||
if (player.getVehicle() == this) return InteractionResult.PASS;
|
if (player.getVehicle() == this) return InteractionResult.PASS;
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (stack.is(ModItems.C4_BOMB.get())) {
|
|
||||||
stack.use(player.level(), player, hand);
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
|
||||||
if (player.isShiftKeyDown() && stack.is(ModItems.CROWBAR.get())) {
|
if (player.isShiftKeyDown() && stack.is(ModItems.CROWBAR.get())) {
|
||||||
ItemStack container = ContainerBlockItem.createInstance(this);
|
ItemStack container = ContainerBlockItem.createInstance(this);
|
||||||
if (!player.addItem(container)) {
|
if (!player.addItem(container)) {
|
||||||
|
@ -132,13 +128,6 @@ public class ContainerMobileEntity extends MobileVehicleEntity implements HasCus
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// Player player = (Player) this.getFirstPassenger();
|
|
||||||
|
|
||||||
// if (player != null) {
|
|
||||||
// player.displayClientMessage(Component.literal( new DecimalFormat("##.#").format(this.getEnergy())), true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package com.atsuishio.superbwarfare.entity.vehicle;
|
package com.atsuishio.superbwarfare.entity.vehicle;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
|
||||||
import com.atsuishio.superbwarfare.entity.C4Entity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.DroneEntity;
|
import com.atsuishio.superbwarfare.entity.DroneEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
|
@ -56,6 +54,7 @@ public class VehicleEntity extends Entity {
|
||||||
public float prevRoll;
|
public float prevRoll;
|
||||||
public int lastHurtTick;
|
public int lastHurtTick;
|
||||||
public boolean crash;
|
public boolean crash;
|
||||||
|
|
||||||
public float getRoll() {
|
public float getRoll() {
|
||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
@ -224,8 +223,7 @@ public class VehicleEntity extends Entity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canAddPassenger(Entity pPassenger) {
|
protected boolean canAddPassenger(Entity pPassenger) {
|
||||||
ModUtils.LOGGER.info(pPassenger.getClass().toString());
|
return this.getPassengers().size() < this.getMaxPassengers();
|
||||||
return this.getPassengers().size() < this.getMaxPassengers() || pPassenger instanceof C4Entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxPassengers() {
|
public int getMaxPassengers() {
|
||||||
|
@ -236,9 +234,9 @@ public class VehicleEntity extends Entity {
|
||||||
public void baseTick() {
|
public void baseTick() {
|
||||||
super.baseTick();
|
super.baseTick();
|
||||||
|
|
||||||
lastHurtTick ++;
|
this.lastHurtTick++;
|
||||||
|
|
||||||
prevRoll = this.getRoll();
|
this.prevRoll = this.getRoll();
|
||||||
|
|
||||||
float delta = Math.abs(getYRot() - yRotO);
|
float delta = Math.abs(getYRot() - yRotO);
|
||||||
while (getYRot() > 180F) {
|
while (getYRot() > 180F) {
|
||||||
|
@ -312,9 +310,9 @@ public class VehicleEntity extends Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getHealth() < 0.1f * this.getMaxHealth() && tickCount %13 == 0) {
|
if (this.getHealth() < 0.1f * this.getMaxHealth() && tickCount % 13 == 0) {
|
||||||
this.level().playSound(null, this.getOnPos(), ModSounds.NO_HEALTH.get(), SoundSource.PLAYERS, 1, 1);
|
this.level().playSound(null, this.getOnPos(), ModSounds.NO_HEALTH.get(), SoundSource.PLAYERS, 1, 1);
|
||||||
} else if (this.getHealth() >= 0.1f && this.getHealth() < 0.4f * this.getMaxHealth() && tickCount %10 == 0) {
|
} else if (this.getHealth() >= 0.1f && this.getHealth() < 0.4f * this.getMaxHealth() && tickCount % 10 == 0) {
|
||||||
this.level().playSound(null, this.getOnPos(), ModSounds.LOW_HEALTH.get(), SoundSource.PLAYERS, 1, 1);
|
this.level().playSound(null, this.getOnPos(), ModSounds.LOW_HEALTH.get(), SoundSource.PLAYERS, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue