mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Holy SHIT! i think i fixed it
This commit is contained in:
parent
4d489bc938
commit
ccebbbca24
@ -272,6 +272,7 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
|
||||
@Override
|
||||
public void deserialize(ByteBuf buf) {
|
||||
super.deserialize(buf);
|
||||
this.turnProgress = 2;
|
||||
this.tPos = BufferUtil.readVec3(buf);
|
||||
this.rotationPitch = buf.readDouble();
|
||||
this.rotationYaw = buf.readDouble();
|
||||
|
||||
@ -262,19 +262,30 @@ public class TileEntityTurretMaxwell extends TileEntityTurretBaseNT implements I
|
||||
|
||||
this.power -= demand;
|
||||
|
||||
this.shot = true;
|
||||
this.networkPackNT(250);
|
||||
this.shot = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shot = false;
|
||||
|
||||
@Override
|
||||
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) {
|
||||
if(buf.readBoolean())
|
||||
this.beam = 5;
|
||||
else
|
||||
this.beam = 0;
|
||||
super.deserialize(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -24,7 +24,7 @@ import net.minecraft.world.World;
|
||||
public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
|
||||
|
||||
static List<Integer> configs = new ArrayList();
|
||||
|
||||
|
||||
static {
|
||||
configs.add(BulletConfigSyncingUtil.ROCKET_NORMAL);
|
||||
configs.add(BulletConfigSyncingUtil.ROCKET_HE);
|
||||
@ -39,7 +39,7 @@ public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
|
||||
configs.add(BulletConfigSyncingUtil.ROCKET_PHOSPHORUS);
|
||||
configs.add(BulletConfigSyncingUtil.ROCKET_CANISTER);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<Integer> getAmmoList() {
|
||||
return configs;
|
||||
@ -69,7 +69,7 @@ public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
|
||||
public long getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getDecetorGrace() {
|
||||
return 8D;
|
||||
@ -79,69 +79,81 @@ public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
|
||||
public double getDecetorRange() {
|
||||
return 64D;
|
||||
}
|
||||
|
||||
|
||||
int timer;
|
||||
public int loaded;
|
||||
int reload;
|
||||
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
|
||||
if(reload > 0) {
|
||||
reload--;
|
||||
|
||||
|
||||
if(reload == 0)
|
||||
this.loaded = 17;
|
||||
}
|
||||
|
||||
|
||||
if(loaded <= 0 && reload <= 0 && this.getFirstConfigLoaded() != null) {
|
||||
reload = 100;
|
||||
}
|
||||
|
||||
|
||||
if(this.getFirstConfigLoaded() == null) {
|
||||
this.loaded = 0;
|
||||
}
|
||||
|
||||
this.isTurretPacket = true;
|
||||
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
|
||||
public void deserialize(ByteBuf buf) {
|
||||
super.deserialize(buf);
|
||||
this.loaded = buf.readInt();
|
||||
if(buf.readBoolean()) {
|
||||
this.loaded = buf.readInt();
|
||||
} else
|
||||
super.deserialize(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFiringTick() {
|
||||
|
||||
|
||||
if(reload > 0)
|
||||
return;
|
||||
|
||||
|
||||
timer++;
|
||||
|
||||
|
||||
if(timer > 0 && timer % 10 == 0) {
|
||||
|
||||
|
||||
BulletConfiguration conf = this.getFirstConfigLoaded();
|
||||
|
||||
|
||||
if(conf != null) {
|
||||
this.spawnBullet(conf);
|
||||
this.conusmeAmmo(conf.ammo);
|
||||
this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:turret.richard_fire", 2.0F, 1.0F);
|
||||
this.loaded--;
|
||||
|
||||
|
||||
if(conf.ammo.equals(new ComparableStack(ModItems.ammo_rocket.stackFromEnum(AmmoRocket.NUCLEAR))))
|
||||
timer = -50;
|
||||
|
||||
|
||||
} else {
|
||||
this.loaded = 0;
|
||||
}
|
||||
@ -150,25 +162,25 @@ public class TileEntityTurretRichard extends TileEntityTurretBaseNT {
|
||||
|
||||
@Override
|
||||
public void spawnBullet(BulletConfiguration bullet) {
|
||||
|
||||
|
||||
Vec3 pos = this.getTurretPos();
|
||||
Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0);
|
||||
vec.rotateAroundZ((float) -this.rotationPitch);
|
||||
vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5));
|
||||
|
||||
|
||||
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.setThrowableHeading(vec.xCoord, vec.yCoord, vec.zCoord, bullet.velocity * 0.75F, bullet.spread);
|
||||
worldObj.spawnEntityInWorld(proj);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.loaded = nbt.getInteger("loaded");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
@ -22,11 +22,11 @@ import net.minecraft.world.World;
|
||||
public class TileEntityTurretTauon extends TileEntityTurretBaseNT {
|
||||
|
||||
static List<Integer> configs = new ArrayList();
|
||||
|
||||
|
||||
static {
|
||||
configs.add(BulletConfigSyncingUtil.SPECIAL_GAUSS);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<Integer> getAmmoList() {
|
||||
return configs;
|
||||
@ -81,63 +81,65 @@ public class TileEntityTurretTauon extends TileEntityTurretBaseNT {
|
||||
public long getConsumption() {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
|
||||
int timer;
|
||||
public int beam;
|
||||
public float spin;
|
||||
public float lastSpin;
|
||||
public double lastDist;
|
||||
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
|
||||
if(worldObj.isRemote) {
|
||||
|
||||
|
||||
if(this.tPos != null) {
|
||||
Vec3 pos = this.getTurretPos();
|
||||
double length = Vec3.createVectorHelper(tPos.xCoord - pos.xCoord, tPos.yCoord - pos.yCoord, tPos.zCoord - pos.zCoord).lengthVector();
|
||||
this.lastDist = length;
|
||||
}
|
||||
|
||||
|
||||
if(beam > 0)
|
||||
beam--;
|
||||
|
||||
|
||||
this.lastSpin = this.spin;
|
||||
|
||||
|
||||
if(this.tPos != null) {
|
||||
this.spin += 45;
|
||||
}
|
||||
|
||||
|
||||
if(this.spin >= 360F) {
|
||||
this.spin -= 360F;
|
||||
this.lastSpin -= 360F;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFiringTick() {
|
||||
|
||||
|
||||
timer++;
|
||||
|
||||
|
||||
if(timer % 5 == 0) {
|
||||
|
||||
|
||||
BulletConfiguration conf = this.getFirstConfigLoaded();
|
||||
|
||||
|
||||
if(conf != null && this.target != null) {
|
||||
this.target.attackEntityFrom(ModDamageSource.electricity, 30F + worldObj.rand.nextInt(11));
|
||||
this.conusmeAmmo(conf.ammo);
|
||||
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.shot = false;
|
||||
|
||||
Vec3 pos = this.getTurretPos();
|
||||
Vec3 vec = Vec3.createVectorHelper(this.getBarrelLength(), 0, 0);
|
||||
vec.rotateAroundZ((float) -this.rotationPitch);
|
||||
vec.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5));
|
||||
|
||||
|
||||
NBTTagCompound dPart = new NBTTagCompound();
|
||||
dPart.setString("type", "tau");
|
||||
dPart.setByte("count", (byte)5);
|
||||
@ -146,16 +148,24 @@ public class TileEntityTurretTauon extends TileEntityTurretBaseNT {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shot = false;
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf buf) {
|
||||
super.serialize(buf);
|
||||
buf.writeBoolean(true);
|
||||
if (this.shot)
|
||||
buf.writeBoolean(true);
|
||||
else {
|
||||
buf.writeBoolean(false);
|
||||
super.serialize(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuf buf) {
|
||||
super.deserialize(buf);
|
||||
this.beam = buf.readBoolean() ? 3 : 0;
|
||||
if(buf.readBoolean())
|
||||
this.beam = 3;
|
||||
else
|
||||
super.deserialize(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user