diff --git a/src/main/java/assets/hbm/sounds.json b/src/main/java/assets/hbm/sounds.json index f2d04dea2..24225f83b 100644 --- a/src/main/java/assets/hbm/sounds.json +++ b/src/main/java/assets/hbm/sounds.json @@ -148,6 +148,10 @@ "weapon.reloadTurret": {"category": "player", "sounds": [{"name": "weapon/reloadTurret", "stream": false}]}, "weapon.switchmode1": {"category": "player", "sounds": [{"name": "weapon/switchmode1", "stream": false}]}, "weapon.switchmode2": {"category": "player", "sounds": [{"name": "weapon/switchmode2", "stream": false}]}, + + "turret.chekhov_fire": {"category": "block", "sounds": [{"name": "turret/chekhov_fire", "stream": false}]}, + "turret.jeremy_fire": {"category": "block", "sounds": ["turret/jeremy_fire1", "turret/jeremy_fire2", "turret/jeremy_fire3", "turret/jeremy_fire4", "turret/jeremy_fire5"]}, + "turret.jeremy_reload": {"category": "block", "sounds": [{"name": "turret/jeremy_reload", "stream": false}]}, "entity.chopperFlyingLoop": {"category": "hostile", "sounds": [{"name": "entity/chopperFlyingLoop", "stream": true}]}, "entity.chopperDrop": {"category": "hostile", "sounds": [{"name": "entity/chopperDrop", "stream": false}]}, diff --git a/src/main/java/assets/hbm/sounds/turret/chekhov_fire.ogg b/src/main/java/assets/hbm/sounds/turret/chekhov_fire.ogg new file mode 100644 index 000000000..0c84f2df6 Binary files /dev/null and b/src/main/java/assets/hbm/sounds/turret/chekhov_fire.ogg differ diff --git a/src/main/java/assets/hbm/sounds/turret/jeremy_fire1.ogg b/src/main/java/assets/hbm/sounds/turret/jeremy_fire1.ogg new file mode 100755 index 000000000..9ca24ac7e Binary files /dev/null and b/src/main/java/assets/hbm/sounds/turret/jeremy_fire1.ogg differ diff --git a/src/main/java/assets/hbm/sounds/turret/jeremy_fire2.ogg b/src/main/java/assets/hbm/sounds/turret/jeremy_fire2.ogg new file mode 100755 index 000000000..7aa0bd07e Binary files /dev/null and b/src/main/java/assets/hbm/sounds/turret/jeremy_fire2.ogg differ diff --git a/src/main/java/assets/hbm/sounds/turret/jeremy_fire3.ogg b/src/main/java/assets/hbm/sounds/turret/jeremy_fire3.ogg new file mode 100755 index 000000000..94c0fcdd5 Binary files /dev/null and b/src/main/java/assets/hbm/sounds/turret/jeremy_fire3.ogg differ diff --git a/src/main/java/assets/hbm/sounds/turret/jeremy_fire4.ogg b/src/main/java/assets/hbm/sounds/turret/jeremy_fire4.ogg new file mode 100755 index 000000000..7ab60ccfa Binary files /dev/null and b/src/main/java/assets/hbm/sounds/turret/jeremy_fire4.ogg differ diff --git a/src/main/java/assets/hbm/sounds/turret/jeremy_fire5.ogg b/src/main/java/assets/hbm/sounds/turret/jeremy_fire5.ogg new file mode 100755 index 000000000..6cab3d648 Binary files /dev/null and b/src/main/java/assets/hbm/sounds/turret/jeremy_fire5.ogg differ diff --git a/src/main/java/assets/hbm/sounds/turret/jeremy_reload.ogg b/src/main/java/assets/hbm/sounds/turret/jeremy_reload.ogg new file mode 100644 index 000000000..17ae5a888 Binary files /dev/null and b/src/main/java/assets/hbm/sounds/turret/jeremy_reload.ogg differ diff --git a/src/main/java/assets/hbm/textures/gui/weapon/gui_turret_base.png b/src/main/java/assets/hbm/textures/gui/weapon/gui_turret_base.png index 07fb3d08a..2369a2af5 100644 Binary files a/src/main/java/assets/hbm/textures/gui/weapon/gui_turret_base.png and b/src/main/java/assets/hbm/textures/gui/weapon/gui_turret_base.png differ diff --git a/src/main/java/com/hbm/inventory/gui/GUITurretChekhov.java b/src/main/java/com/hbm/inventory/gui/GUITurretChekhov.java index eedea9d10..a4071d70d 100644 --- a/src/main/java/com/hbm/inventory/gui/GUITurretChekhov.java +++ b/src/main/java/com/hbm/inventory/gui/GUITurretChekhov.java @@ -10,12 +10,11 @@ import com.hbm.tileentity.turret.TileEntityTurretChekhov; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; -public class GUITurretChekhov extends GuiContainer { +public class GUITurretChekhov extends GuiInfoContainer { private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/weapon/gui_turret_base.png"); private TileEntityTurretChekhov turret; @@ -27,6 +26,13 @@ public class GUITurretChekhov extends GuiContainer { this.xSize = 176; this.ySize = 222; } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + super.drawScreen(mouseX, mouseY, f); + + this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 45, 16, 52, turret.power, turret.getMaxPower()); + } protected void mouseClicked(int x, int y, int i) { super.mouseClicked(x, y, i); @@ -76,6 +82,9 @@ public class GUITurretChekhov extends GuiContainer { Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + int i = turret.getPowerScaled(53); + drawTexturedModalRect(guiLeft + 152, guiTop + 97 - i, 194, 52 - i, 16, i); + if(turret.isOn) drawTexturedModalRect(guiLeft + 115, guiTop + 26, 176, 40, 18, 18); diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index c80746aad..8d48ef492 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -871,6 +871,17 @@ public class ClientProxy extends ServerProxy { if("greendust".equals(data.getString("mode"))) { fx = new net.minecraft.client.particle.EntityReddustFX(world, x, y, z, 0.01F, 0.5F, 0.1F); } + + if("largeexplode".equals(data.getString("mode"))) { + fx = new net.minecraft.client.particle.EntityLargeExplodeFX(man, world, x, y, z, 1.5F, 0.0F, 0.0F); + float r = 1.0F - rand.nextFloat() * 0.2F; + fx.setRBGColorF(1F * r, 0.9F * r, 0.5F * r); + + net.minecraft.client.particle.EntityExplodeFX sec = new net.minecraft.client.particle.EntityExplodeFX(world, x, y, z, 0.0F, 0.0F, 0.0F); + float r2 = 1.0F - rand.nextFloat() * 0.5F; + sec.setRBGColorF(0.5F * r2, 0.5F * r2, 0.5F * r2); + Minecraft.getMinecraft().effectRenderer.addEffect(sec); + } if(fx != null) Minecraft.getMinecraft().effectRenderer.addEffect(fx); diff --git a/src/main/java/com/hbm/render/tileentity/RenderTurretChekhov.java b/src/main/java/com/hbm/render/tileentity/RenderTurretChekhov.java index aa6de8636..46ba75490 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderTurretChekhov.java +++ b/src/main/java/com/hbm/render/tileentity/RenderTurretChekhov.java @@ -40,8 +40,10 @@ public class RenderTurretChekhov extends RenderTurretBase { bindTexture(ResourceManager.turret_chekhov_tex); ResourceManager.turret_chekhov.renderPart("Body"); + float rot = turret.lastSpin + (turret.spin - turret.lastSpin) * interp; + GL11.glTranslated(0, 1.5, 0); - GL11.glRotated(System.currentTimeMillis() % 360, -1, 0, 0); + GL11.glRotated(rot, -1, 0, 0); GL11.glTranslated(0, -1.5, 0); bindTexture(ResourceManager.turret_chekhov_barrels_tex); ResourceManager.turret_chekhov.renderPart("Barrels"); diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java index efec0368e..10bd13b99 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java @@ -5,6 +5,8 @@ import java.util.List; import com.hbm.blocks.BlockDummyable; import com.hbm.entity.logic.EntityBomber; import com.hbm.entity.missile.EntityMissileBaseAdvanced; +import com.hbm.entity.projectile.EntityBulletBase; +import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; import com.hbm.interfaces.IConsumer; import com.hbm.lib.Library; @@ -17,6 +19,7 @@ import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; @@ -72,6 +75,32 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple super(11); } + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + this.power = nbt.getLong("power"); + this.isOn = nbt.getBoolean("isOn"); + this.targetPlayers = nbt.getBoolean("targetPlayers"); + this.targetAnimals = nbt.getBoolean("targetAnimals"); + this.targetMobs = nbt.getBoolean("targetMobs"); + this.targetMachines = nbt.getBoolean("targetMachines"); + this.stattrak = nbt.getInteger("stattrak"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setLong("power", this.power); + nbt.setBoolean("isOn", this.isOn); + nbt.setBoolean("targetPlayers", this.targetPlayers); + nbt.setBoolean("targetAnimals", this.targetAnimals); + nbt.setBoolean("targetMobs", this.targetMobs); + nbt.setBoolean("targetMachines", this.targetMachines); + nbt.setInteger("stattrak", this.stattrak); + } + @Override public void updateEntity() { @@ -88,7 +117,7 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple } } - if(this.isOn) { + if(this.isOn && hasPower()) { if(target != null) this.alignTurret(); @@ -99,9 +128,16 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple if(!worldObj.isRemote) { - if(this.isOn) { + if(this.target != null && !target.isEntityAlive()) { + this.target = null; + this.stattrak++; + } + + if(this.isOn && hasPower()) { searchTimer--; + this.setPower(this.getPower() - this.getConsumption()); + if(searchTimer <= 0) { searchTimer = this.getDecetorInterval(); this.seekNewTarget(); @@ -110,6 +146,12 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple searchTimer = 0; } + if(this.aligned) { + this.updateFiringTick(); + } + + this.power = Library.chargeTEFromItems(slots, 10, this.power, this.getMaxPower()); + NBTTagCompound data = new NBTTagCompound(); data.setInteger("target", this.target == null ? -1 : this.target.getEntityId()); data.setLong("power", this.power); @@ -118,11 +160,11 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple data.setBoolean("targetAnimals", this.targetAnimals); data.setBoolean("targetMobs", this.targetMobs); data.setBoolean("targetMachines", this.targetMachines); + data.setInteger("stattrak", this.stattrak); this.networkPack(data, 250); } else { - 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)); @@ -135,11 +177,6 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple else this.lastRotationYaw -= Math.PI * 2; } - - if(this.aligned) - worldObj.spawnParticle("flame", pos.xCoord + vec.xCoord, pos.yCoord + vec.yCoord, pos.zCoord + vec.zCoord, vec.xCoord, vec.yCoord, vec.zCoord); - if(this.target != null) - worldObj.spawnParticle("smoke", pos.xCoord + vec.xCoord, pos.yCoord + vec.yCoord, pos.zCoord + vec.zCoord, vec.xCoord, vec.yCoord, vec.zCoord); } } @@ -153,6 +190,7 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple this.targetAnimals = nbt.getBoolean("targetAnimals"); this.targetMobs = nbt.getBoolean("targetMobs"); this.targetMachines = nbt.getBoolean("targetMachines"); + this.stattrak = nbt.getInteger("stattrak"); if(t != -1) this.target = worldObj.getEntityByID(t); @@ -172,6 +210,60 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple } } + public abstract void updateFiringTick(); + + public BulletConfiguration getFirstConfigLoaded() { + + List list = getAmmoList(); + + if(list == null || list.isEmpty()) + return null; + + //doing it like this will fire slots in the right order, not in the order of the configs + //you know, the weird thing the IItemGunBase does + for(int i = 1; i < 10; i++) { + + if(slots[i] != null) { + + for(Integer c : list) { //we can afford all this extra iteration trash on the count that a turret has at most like 4 bullet configs + + BulletConfiguration conf = BulletConfigSyncingUtil.pullConfig(c); + + if(conf.ammo == slots[i].getItem()) + return conf; + } + } + } + + return null; + } + + 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)); + + EntityBulletBase proj = new EntityBulletBase(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, bullet.spread); + worldObj.spawnEntityInWorld(proj); + } + + public void conusmeAmmo(Item ammo) { + + for(int i = 1; i < 10; i++) { + + if(slots[i] != null && slots[i].getItem() == ammo) { + + this.decrStackSize(i, 1); + return; + } + } + } + /** * Reads the namelist from the AI chip in slot 0 * @return null if there is either no chip to be found or if the name list is empty, otherwise it just reads the strings from the chip's NBT @@ -290,6 +382,9 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple */ public boolean entityInLOS(Entity e) { + if(e.isDead || !e.isEntityAlive()) + return false; + Vec3 pos = this.getTurretPos(); Vec3 ent = this.getEntityPos(e); Vec3 delta = Vec3.createVectorHelper(ent.xCoord - pos.xCoord, ent.yCoord - pos.yCoord, ent.zCoord - pos.zCoord); @@ -467,16 +562,28 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple * Yes, new turrets fire BulletNTs. * @return */ - protected abstract List getAmmoList(); + protected abstract List getAmmoList(); + + public boolean hasPower() { + return this.getPower() >= this.getConsumption(); + } public void setPower(long i) { this.power = i; } - public long getPower() { + public long getPower() { return this.power; } + public int getPowerScaled(int scale) { + return (int)(power * scale / this.getMaxPower()); + } + + public long getConsumption() { + return 100; + } + @Override public AxisAlignedBB getRenderBoundingBox() { return TileEntity.INFINITE_EXTENT_AABB; diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretChekhov.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretChekhov.java index 1999e451b..108065f82 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretChekhov.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretChekhov.java @@ -3,23 +3,37 @@ package com.hbm.tileentity.turret; import java.util.ArrayList; import java.util.List; +import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; -import com.hbm.handler.guncfg.Gun75BoltFactory; +import com.hbm.packet.AuxParticlePacketNT; +import com.hbm.packet.PacketDispatcher; + +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Vec3; public class TileEntityTurretChekhov extends TileEntityTurretBaseNT { - static List configs = new ArrayList(); + static List configs = new ArrayList(); //because cramming it into the ArrayList's constructor with nested curly brackets and all that turned out to be not as pretty //also having a floaty `static` like this looks fun //idk if it's just me though static { - configs.add(Gun75BoltFactory.get75BoltConfig()); + configs.add(BulletConfigSyncingUtil.BMG50_NORMAL); + configs.add(BulletConfigSyncingUtil.BMG50_INCENDIARY); + configs.add(BulletConfigSyncingUtil.BMG50_EXPLOSIVE); + configs.add(BulletConfigSyncingUtil.BMG50_AP); + configs.add(BulletConfigSyncingUtil.BMG50_DU); + configs.add(BulletConfigSyncingUtil.BMG50_STAR); + configs.add(BulletConfigSyncingUtil.BMG50_PHOSPHORUS); + configs.add(BulletConfigSyncingUtil.BMG50_SLEEK); + configs.add(BulletConfigSyncingUtil.CHL_BMG50); } @Override - protected List getAmmoList() { - return null; + protected List getAmmoList() { + return configs; } @Override @@ -36,4 +50,68 @@ public class TileEntityTurretChekhov extends TileEntityTurretBaseNT { public long getMaxPower() { return 10000; } + + @Override + public double getBarrelLength() { + return 3.5D; + } + + int timer; + + @Override + public void updateFiringTick() { + + timer++; + + if(timer > 20 && timer % 2 == 0) { + + BulletConfiguration conf = this.getFirstConfigLoaded(); + + if(conf != null) { + this.spawnBullet(conf); + this.conusmeAmmo(conf.ammo); + this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:turret.chekhov_fire", 2.0F, 1.0F); + + 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 data = new NBTTagCompound(); + data.setString("type", "vanillaExt"); + data.setString("mode", "largeexplode"); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.xCoord + vec.xCoord, pos.yCoord + vec.yCoord, pos.zCoord + vec.zCoord), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50)); + } + } + } + + public float spin; + public float lastSpin; + private float accel; + + @Override + public void updateEntity() { + super.updateEntity(); + + if(worldObj.isRemote) { + + if(this.aligned) { + this.accel = Math.min(45F, this.accel += 2); + } else { + this.accel = Math.max(0F, this.accel -= 2); + } + + this.lastSpin = this.spin; + this.spin += this.accel; + + if(this.spin >= 360F) { + this.spin -= 360F; + this.lastSpin -= 360F; + } + } else { + + if(!this.aligned) + this.timer = 0; + } + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretJeremy.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretJeremy.java index 13f3b118e..f2240e904 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretJeremy.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretJeremy.java @@ -2,12 +2,10 @@ package com.hbm.tileentity.turret; import java.util.List; -import com.hbm.handler.BulletConfiguration; - public class TileEntityTurretJeremy extends TileEntityTurretBaseNT { @Override - protected List getAmmoList() { + protected List getAmmoList() { return null; } @@ -30,4 +28,9 @@ public class TileEntityTurretJeremy extends TileEntityTurretBaseNT { public long getMaxPower() { return 10000; } + + @Override + public void updateFiringTick() { + + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretTauon.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretTauon.java index 3fce781ba..571ac1575 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretTauon.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretTauon.java @@ -2,12 +2,10 @@ package com.hbm.tileentity.turret; import java.util.List; -import com.hbm.handler.BulletConfiguration; - public class TileEntityTurretTauon extends TileEntityTurretBaseNT { @Override - protected List getAmmoList() { + protected List getAmmoList() { return null; } @@ -45,4 +43,9 @@ public class TileEntityTurretTauon extends TileEntityTurretBaseNT { public long getMaxPower() { return 10000; } + + @Override + public void updateFiringTick() { + + } }