mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
arty sync fix
This commit is contained in:
parent
e5f2ae6860
commit
8878b3f9de
@ -45,4 +45,5 @@
|
||||
* Fixed normal drones loading chunks
|
||||
* Fixed chunk-loading drones not loading chunks
|
||||
* Fixed several chemistry templates missing names
|
||||
* Fixed rampant mode random scout spawns being able to appear inside blocks
|
||||
* Fixed rampant mode random scout spawns being able to appear inside blocks
|
||||
* Fixed turret rotation sometimes desyncing when out of range, this is especially noticeable with slow-moving arty
|
||||
@ -238,24 +238,20 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen
|
||||
this.barrelPos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.mode == this.MODE_MANUAL) {
|
||||
if(!this.targetQueue.isEmpty()) {
|
||||
this.tPos = this.targetQueue.get(0);
|
||||
}
|
||||
} else {
|
||||
this.targetQueue.clear();
|
||||
}
|
||||
|
||||
if(worldObj.isRemote) {
|
||||
this.lastRotationPitch = this.rotationPitch;
|
||||
this.lastRotationYaw = this.rotationYaw;
|
||||
}
|
||||
|
||||
this.aligned = false;
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
if(this.mode == this.MODE_MANUAL) {
|
||||
if(!this.targetQueue.isEmpty()) {
|
||||
this.tPos = this.targetQueue.get(0);
|
||||
}
|
||||
} else {
|
||||
this.targetQueue.clear();
|
||||
}
|
||||
|
||||
this.aligned = false;
|
||||
|
||||
this.updateConnections();
|
||||
|
||||
@ -263,15 +259,12 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen
|
||||
this.target = null;
|
||||
this.stattrak++;
|
||||
}
|
||||
}
|
||||
|
||||
if(target != null && this.mode != this.MODE_MANUAL) {
|
||||
if(!this.entityInLOS(this.target)) {
|
||||
this.target = null;
|
||||
if(target != null && this.mode != this.MODE_MANUAL) {
|
||||
if(!this.entityInLOS(this.target)) {
|
||||
this.target = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(target != null) {
|
||||
this.tPos = this.getEntityPos(target);
|
||||
@ -280,18 +273,15 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen
|
||||
this.tPos = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isOn() && hasPower()) {
|
||||
|
||||
if(tPos != null)
|
||||
this.alignTurret();
|
||||
} else {
|
||||
this.target = null;
|
||||
this.tPos = null;
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
if(isOn() && hasPower()) {
|
||||
|
||||
if(tPos != null)
|
||||
this.alignTurret();
|
||||
} else {
|
||||
this.target = null;
|
||||
this.tPos = null;
|
||||
}
|
||||
|
||||
if(!isOn()) this.targetQueue.clear();
|
||||
|
||||
@ -335,10 +325,6 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen
|
||||
|
||||
} else {
|
||||
|
||||
Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0);
|
||||
vec.rotateAroundZ((float) -this.rotationPitch);
|
||||
vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5));
|
||||
|
||||
//this will fix the interpolation error when the turret crosses the 360° point
|
||||
if(Math.abs(this.lastRotationYaw - this.rotationYaw) > Math.PI) {
|
||||
|
||||
|
||||
@ -84,6 +84,10 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
|
||||
//only used by clients for interpolation
|
||||
public double lastRotationYaw;
|
||||
public double lastRotationPitch;
|
||||
//only used by clients for approach
|
||||
public double syncRotationYaw;
|
||||
public double syncRotationPitch;
|
||||
protected int turnProgress;
|
||||
//is the turret on?
|
||||
public boolean isOn = false;
|
||||
//is the turret aimed at the target?
|
||||
@ -156,46 +160,41 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
|
||||
if(worldObj.isRemote) {
|
||||
this.lastRotationPitch = this.rotationPitch;
|
||||
this.lastRotationYaw = this.rotationYaw;
|
||||
this.rotationPitch = this.syncRotationPitch;
|
||||
this.rotationYaw = this.syncRotationYaw;
|
||||
}
|
||||
|
||||
this.aligned = false;
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
|
||||
this.aligned = false;
|
||||
this.updateConnections();
|
||||
|
||||
if(this.target != null && !target.isEntityAlive()) {
|
||||
this.target = null;
|
||||
this.stattrak++;
|
||||
}
|
||||
}
|
||||
|
||||
if(target != null) {
|
||||
if(!this.entityInLOS(this.target)) {
|
||||
this.target = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(target != null) {
|
||||
if(!this.entityInLOS(this.target)) {
|
||||
this.target = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(target != null) {
|
||||
this.tPos = this.getEntityPos(target);
|
||||
} else {
|
||||
this.tPos = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(isOn() && hasPower()) {
|
||||
|
||||
if(tPos != null)
|
||||
this.alignTurret();
|
||||
} else {
|
||||
|
||||
this.target = null;
|
||||
this.tPos = null;
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
if(isOn() && hasPower()) {
|
||||
|
||||
if(tPos != null)
|
||||
this.alignTurret();
|
||||
} else {
|
||||
|
||||
this.target = null;
|
||||
this.tPos = null;
|
||||
}
|
||||
|
||||
if(this.target != null && !target.isEntityAlive()) {
|
||||
this.target = null;
|
||||
@ -237,10 +236,6 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
|
||||
|
||||
} else {
|
||||
|
||||
Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0);
|
||||
vec.rotateAroundZ((float) -this.rotationPitch);
|
||||
vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5));
|
||||
|
||||
//this will fix the interpolation error when the turret crosses the 360° point
|
||||
if(Math.abs(this.lastRotationYaw - this.rotationYaw) > Math.PI) {
|
||||
|
||||
@ -260,6 +255,8 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
|
||||
data.setDouble("tY", this.tPos.yCoord);
|
||||
data.setDouble("tZ", this.tPos.zCoord);
|
||||
}
|
||||
data.setDouble("pitch", this.rotationPitch);
|
||||
data.setDouble("yaw", this.rotationYaw);
|
||||
data.setLong("power", this.power);
|
||||
data.setBoolean("isOn", this.isOn);
|
||||
data.setBoolean("targetPlayers", this.targetPlayers);
|
||||
@ -292,7 +289,10 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
super.networkUnpack(nbt);
|
||||
|
||||
|
||||
this.turnProgress = 2;
|
||||
this.syncRotationPitch = nbt.getDouble("pitch");
|
||||
this.syncRotationYaw = nbt.getDouble("yaw");
|
||||
this.power = nbt.getLong("power");
|
||||
this.isOn = nbt.getBoolean("isOn");
|
||||
this.targetPlayers = nbt.getBoolean("targetPlayers");
|
||||
|
||||
@ -135,40 +135,36 @@ public class TileEntityTurretHIMARS extends TileEntityTurretBaseArtillery implem
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
this.lastCrane = this.crane;
|
||||
|
||||
if(this.mode == this.MODE_MANUAL) {
|
||||
if(!this.targetQueue.isEmpty()) {
|
||||
this.tPos = this.targetQueue.get(0);
|
||||
}
|
||||
} else {
|
||||
this.targetQueue.clear();
|
||||
}
|
||||
|
||||
if(worldObj.isRemote) {
|
||||
this.lastRotationPitch = this.rotationPitch;
|
||||
this.lastRotationYaw = this.rotationYaw;
|
||||
this.lastCrane = this.crane;
|
||||
}
|
||||
|
||||
this.aligned = false;
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(this.mode == this.MODE_MANUAL) {
|
||||
if(!this.targetQueue.isEmpty()) {
|
||||
this.tPos = this.targetQueue.get(0);
|
||||
}
|
||||
} else {
|
||||
this.targetQueue.clear();
|
||||
}
|
||||
|
||||
this.aligned = false;
|
||||
|
||||
this.updateConnections();
|
||||
|
||||
if(this.target != null && !target.isEntityAlive()) {
|
||||
this.target = null;
|
||||
this.stattrak++;
|
||||
}
|
||||
}
|
||||
|
||||
if(target != null && this.mode != this.MODE_MANUAL) {
|
||||
if(!this.entityInLOS(this.target)) {
|
||||
this.target = null;
|
||||
if(target != null && this.mode != this.MODE_MANUAL) {
|
||||
if(!this.entityInLOS(this.target)) {
|
||||
this.target = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(target != null) {
|
||||
this.tPos = this.getEntityPos(target);
|
||||
@ -177,51 +173,48 @@ public class TileEntityTurretHIMARS extends TileEntityTurretBaseArtillery implem
|
||||
this.tPos = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isOn() && hasPower()) {
|
||||
|
||||
if(!this.hasAmmo() || this.crane > 0) {
|
||||
if(isOn() && hasPower()) {
|
||||
|
||||
this.turnTowardsAngle(0, this.rotationYaw);
|
||||
|
||||
if(this.aligned) {
|
||||
if(!this.hasAmmo() || this.crane > 0) {
|
||||
|
||||
if(this.hasAmmo()) {
|
||||
this.crane -= 0.0125F;
|
||||
} else {
|
||||
this.crane += 0.0125F;
|
||||
this.turnTowardsAngle(0, this.rotationYaw);
|
||||
|
||||
if(this.aligned) {
|
||||
|
||||
if(this.crane >= 1F && !worldObj.isRemote) {
|
||||
int available = this.getSpareRocket();
|
||||
if(this.hasAmmo()) {
|
||||
this.crane -= 0.0125F;
|
||||
} else {
|
||||
this.crane += 0.0125F;
|
||||
|
||||
if(available != -1) {
|
||||
HIMARSRocket type = ItemAmmoHIMARS.itemTypes[available];
|
||||
this.typeLoaded = available;
|
||||
this.ammo = type.amount;
|
||||
this.conusmeAmmo(new ComparableStack(ModItems.ammo_himars, 1, available));
|
||||
if(this.crane >= 1F) {
|
||||
int available = this.getSpareRocket();
|
||||
|
||||
if(available != -1) {
|
||||
HIMARSRocket type = ItemAmmoHIMARS.itemTypes[available];
|
||||
this.typeLoaded = available;
|
||||
this.ammo = type.amount;
|
||||
this.conusmeAmmo(new ComparableStack(ModItems.ammo_himars, 1, available));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.crane = MathHelper.clamp_float(this.crane, 0F, 1F);
|
||||
|
||||
} else {
|
||||
|
||||
if(tPos != null) {
|
||||
this.alignTurret();
|
||||
}
|
||||
}
|
||||
|
||||
this.crane = MathHelper.clamp_float(this.crane, 0F, 1F);
|
||||
|
||||
} else {
|
||||
|
||||
if(tPos != null) {
|
||||
this.alignTurret();
|
||||
}
|
||||
|
||||
this.target = null;
|
||||
this.tPos = null;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
this.target = null;
|
||||
this.tPos = null;
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(!isOn()) this.targetQueue.clear();
|
||||
|
||||
if(this.target != null && !target.isEntityAlive()) {
|
||||
@ -256,10 +249,6 @@ public class TileEntityTurretHIMARS extends TileEntityTurretBaseArtillery implem
|
||||
|
||||
} else {
|
||||
|
||||
Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0);
|
||||
vec.rotateAroundZ((float) -this.rotationPitch);
|
||||
vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5));
|
||||
|
||||
//this will fix the interpolation error when the turret crosses the 360° point
|
||||
if(Math.abs(this.lastRotationYaw - this.rotationYaw) > Math.PI) {
|
||||
|
||||
@ -277,6 +266,7 @@ public class TileEntityTurretHIMARS extends TileEntityTurretBaseArtillery implem
|
||||
data.setShort("mode", this.mode);
|
||||
data.setInteger("type", this.typeLoaded);
|
||||
data.setInteger("ammo", this.ammo);
|
||||
data.setFloat("crane", crane);
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -286,6 +276,7 @@ public class TileEntityTurretHIMARS extends TileEntityTurretBaseArtillery implem
|
||||
this.mode = nbt.getShort("mode");
|
||||
this.typeLoaded = nbt.getShort("type");
|
||||
this.ammo = nbt.getInteger("ammo");
|
||||
this.crane = nbt.getFloat("crane");
|
||||
}
|
||||
|
||||
public boolean hasAmmo() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user