Holy SHIT! i think i fixed it

This commit is contained in:
BallOfEnergy 2024-10-12 22:14:08 -05:00
parent 4d489bc938
commit ccebbbca24
4 changed files with 87 additions and 53 deletions

View File

@ -272,6 +272,7 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
@Override @Override
public void deserialize(ByteBuf buf) { public void deserialize(ByteBuf buf) {
super.deserialize(buf); super.deserialize(buf);
this.turnProgress = 2;
this.tPos = BufferUtil.readVec3(buf); this.tPos = BufferUtil.readVec3(buf);
this.rotationPitch = buf.readDouble(); this.rotationPitch = buf.readDouble();
this.rotationYaw = buf.readDouble(); this.rotationYaw = buf.readDouble();

View File

@ -262,19 +262,30 @@ public class TileEntityTurretMaxwell extends TileEntityTurretBaseNT implements I
this.power -= demand; this.power -= demand;
this.shot = true;
this.networkPackNT(250); this.networkPackNT(250);
this.shot = false;
} }
} }
private boolean shot = false;
@Override
public void serialize(ByteBuf buf) { public void serialize(ByteBuf buf) {
buf.writeBoolean(true); if (this.shot)
buf.writeBoolean(true);
else {
buf.writeBoolean(false);
super.serialize(buf);
}
} }
@Override
public void deserialize(ByteBuf buf) { public void deserialize(ByteBuf buf) {
if(buf.readBoolean()) if(buf.readBoolean())
this.beam = 5; this.beam = 5;
else else
this.beam = 0; super.deserialize(buf);
} }
@Override @Override

View File

@ -24,7 +24,7 @@ import net.minecraft.world.World;
public class TileEntityTurretRichard extends TileEntityTurretBaseNT { public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
static List<Integer> configs = new ArrayList(); static List<Integer> configs = new ArrayList();
static { static {
configs.add(BulletConfigSyncingUtil.ROCKET_NORMAL); configs.add(BulletConfigSyncingUtil.ROCKET_NORMAL);
configs.add(BulletConfigSyncingUtil.ROCKET_HE); configs.add(BulletConfigSyncingUtil.ROCKET_HE);
@ -39,7 +39,7 @@ public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
configs.add(BulletConfigSyncingUtil.ROCKET_PHOSPHORUS); configs.add(BulletConfigSyncingUtil.ROCKET_PHOSPHORUS);
configs.add(BulletConfigSyncingUtil.ROCKET_CANISTER); configs.add(BulletConfigSyncingUtil.ROCKET_CANISTER);
} }
@Override @Override
protected List<Integer> getAmmoList() { protected List<Integer> getAmmoList() {
return configs; return configs;
@ -69,7 +69,7 @@ public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
public long getMaxPower() { public long getMaxPower() {
return 10000; return 10000;
} }
@Override @Override
public double getDecetorGrace() { public double getDecetorGrace() {
return 8D; return 8D;
@ -79,69 +79,81 @@ public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
public double getDecetorRange() { public double getDecetorRange() {
return 64D; return 64D;
} }
int timer; int timer;
public int loaded; public int loaded;
int reload; int reload;
@Override @Override
public void updateEntity() { public void updateEntity() {
super.updateEntity(); super.updateEntity();
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
if(reload > 0) { if(reload > 0) {
reload--; reload--;
if(reload == 0) if(reload == 0)
this.loaded = 17; this.loaded = 17;
} }
if(loaded <= 0 && reload <= 0 && this.getFirstConfigLoaded() != null) { if(loaded <= 0 && reload <= 0 && this.getFirstConfigLoaded() != null) {
reload = 100; reload = 100;
} }
if(this.getFirstConfigLoaded() == null) { if(this.getFirstConfigLoaded() == null) {
this.loaded = 0; this.loaded = 0;
} }
this.isTurretPacket = true;
this.networkPackNT(250); this.networkPackNT(250);
this.isTurretPacket = false;
}
}
// wow so descriptive, i dont wanna hear it; it solves the problem
private boolean isTurretPacket = false;
@Override
public void serialize(ByteBuf buf) {
if (this.isTurretPacket) {
buf.writeBoolean(true);
buf.writeInt(this.loaded);
} else {
buf.writeBoolean(false);
super.serialize(buf);
} }
} }
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
buf.writeInt(this.loaded);
}
@Override @Override
public void deserialize(ByteBuf buf) { public void deserialize(ByteBuf buf) {
super.deserialize(buf); if(buf.readBoolean()) {
this.loaded = buf.readInt(); this.loaded = buf.readInt();
} else
super.deserialize(buf);
} }
@Override @Override
public void updateFiringTick() { public void updateFiringTick() {
if(reload > 0) if(reload > 0)
return; return;
timer++; timer++;
if(timer > 0 && timer % 10 == 0) { if(timer > 0 && timer % 10 == 0) {
BulletConfiguration conf = this.getFirstConfigLoaded(); BulletConfiguration conf = this.getFirstConfigLoaded();
if(conf != null) { if(conf != null) {
this.spawnBullet(conf); this.spawnBullet(conf);
this.conusmeAmmo(conf.ammo); this.conusmeAmmo(conf.ammo);
this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:turret.richard_fire", 2.0F, 1.0F); this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:turret.richard_fire", 2.0F, 1.0F);
this.loaded--; this.loaded--;
if(conf.ammo.equals(new ComparableStack(ModItems.ammo_rocket.stackFromEnum(AmmoRocket.NUCLEAR)))) if(conf.ammo.equals(new ComparableStack(ModItems.ammo_rocket.stackFromEnum(AmmoRocket.NUCLEAR))))
timer = -50; timer = -50;
} else { } else {
this.loaded = 0; this.loaded = 0;
} }
@ -150,25 +162,25 @@ public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
@Override @Override
public void spawnBullet(BulletConfiguration bullet) { public void spawnBullet(BulletConfiguration bullet) {
Vec3 pos = this.getTurretPos(); Vec3 pos = this.getTurretPos();
Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0); Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0);
vec.rotateAroundZ((float) -this.rotationPitch); vec.rotateAroundZ((float) -this.rotationPitch);
vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5)); vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5));
EntityBulletBaseNT proj = new EntityBulletBaseNT(worldObj, BulletConfigSyncingUtil.getKey(bullet)); EntityBulletBaseNT proj = new EntityBulletBaseNT(worldObj, BulletConfigSyncingUtil.getKey(bullet));
proj.setPositionAndRotation(pos.xCoord + vec.xCoord, pos.yCoord + vec.yCoord, pos.zCoord + vec.zCoord, 0.0F, 0.0F); proj.setPositionAndRotation(pos.xCoord + vec.xCoord, pos.yCoord + vec.yCoord, pos.zCoord + vec.zCoord, 0.0F, 0.0F);
proj.setThrowableHeading(vec.xCoord, vec.yCoord, vec.zCoord, bullet.velocity * 0.75F, bullet.spread); proj.setThrowableHeading(vec.xCoord, vec.yCoord, vec.zCoord, bullet.velocity * 0.75F, bullet.spread);
worldObj.spawnEntityInWorld(proj); worldObj.spawnEntityInWorld(proj);
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
this.loaded = nbt.getInteger("loaded"); this.loaded = nbt.getInteger("loaded");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);

View File

@ -22,11 +22,11 @@ import net.minecraft.world.World;
public class TileEntityTurretTauon extends TileEntityTurretBaseNT { public class TileEntityTurretTauon extends TileEntityTurretBaseNT {
static List<Integer> configs = new ArrayList(); static List<Integer> configs = new ArrayList();
static { static {
configs.add(BulletConfigSyncingUtil.SPECIAL_GAUSS); configs.add(BulletConfigSyncingUtil.SPECIAL_GAUSS);
} }
@Override @Override
protected List<Integer> getAmmoList() { protected List<Integer> getAmmoList() {
return configs; return configs;
@ -81,63 +81,65 @@ public class TileEntityTurretTauon extends TileEntityTurretBaseNT {
public long getConsumption() { public long getConsumption() {
return 1000; return 1000;
} }
int timer; int timer;
public int beam; public int beam;
public float spin; public float spin;
public float lastSpin; public float lastSpin;
public double lastDist; public double lastDist;
@Override @Override
public void updateEntity() { public void updateEntity() {
if(worldObj.isRemote) { if(worldObj.isRemote) {
if(this.tPos != null) { if(this.tPos != null) {
Vec3 pos = this.getTurretPos(); Vec3 pos = this.getTurretPos();
double length = Vec3.createVectorHelper(tPos.xCoord - pos.xCoord, tPos.yCoord - pos.yCoord, tPos.zCoord - pos.zCoord).lengthVector(); double length = Vec3.createVectorHelper(tPos.xCoord - pos.xCoord, tPos.yCoord - pos.yCoord, tPos.zCoord - pos.zCoord).lengthVector();
this.lastDist = length; this.lastDist = length;
} }
if(beam > 0) if(beam > 0)
beam--; beam--;
this.lastSpin = this.spin; this.lastSpin = this.spin;
if(this.tPos != null) { if(this.tPos != null) {
this.spin += 45; this.spin += 45;
} }
if(this.spin >= 360F) { if(this.spin >= 360F) {
this.spin -= 360F; this.spin -= 360F;
this.lastSpin -= 360F; this.lastSpin -= 360F;
} }
} }
super.updateEntity(); super.updateEntity();
} }
@Override @Override
public void updateFiringTick() { public void updateFiringTick() {
timer++; timer++;
if(timer % 5 == 0) { if(timer % 5 == 0) {
BulletConfiguration conf = this.getFirstConfigLoaded(); BulletConfiguration conf = this.getFirstConfigLoaded();
if(conf != null && this.target != null) { if(conf != null && this.target != null) {
this.target.attackEntityFrom(ModDamageSource.electricity, 30F + worldObj.rand.nextInt(11)); this.target.attackEntityFrom(ModDamageSource.electricity, 30F + worldObj.rand.nextInt(11));
this.conusmeAmmo(conf.ammo); this.conusmeAmmo(conf.ammo);
this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:weapon.tauShoot", 4.0F, 0.9F + worldObj.rand.nextFloat() * 0.3F); this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:weapon.tauShoot", 4.0F, 0.9F + worldObj.rand.nextFloat() * 0.3F);
this.shot = true;
this.networkPackNT(250); this.networkPackNT(250);
this.shot = false;
Vec3 pos = this.getTurretPos(); Vec3 pos = this.getTurretPos();
Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0); Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0);
vec.rotateAroundZ((float) -this.rotationPitch); vec.rotateAroundZ((float) -this.rotationPitch);
vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5)); vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5));
NBTTagCompound dPart = new NBTTagCompound(); NBTTagCompound dPart = new NBTTagCompound();
dPart.setString("type", "tau"); dPart.setString("type", "tau");
dPart.setByte("count", (byte)5); dPart.setByte("count", (byte)5);
@ -146,16 +148,24 @@ public class TileEntityTurretTauon extends TileEntityTurretBaseNT {
} }
} }
private boolean shot = false;
@Override @Override
public void serialize(ByteBuf buf) { public void serialize(ByteBuf buf) {
super.serialize(buf); if (this.shot)
buf.writeBoolean(true); buf.writeBoolean(true);
else {
buf.writeBoolean(false);
super.serialize(buf);
}
} }
@Override @Override
public void deserialize(ByteBuf buf) { public void deserialize(ByteBuf buf) {
super.deserialize(buf); if(buf.readBoolean())
this.beam = buf.readBoolean() ? 3 : 0; this.beam = 3;
else
super.deserialize(buf);
} }
@Override @Override