base turret completed (minus player whitelist)

This commit is contained in:
Bob 2021-03-02 23:34:51 +01:00
parent e2585760de
commit bc89c4a1e1
16 changed files with 241 additions and 24 deletions

View File

@ -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}]},

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -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);

View File

@ -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);

View File

@ -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");

View File

@ -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<Integer> 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<BulletConfiguration> getAmmoList();
protected abstract List<Integer> 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;

View File

@ -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<BulletConfiguration> configs = new ArrayList();
static List<Integer> 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<BulletConfiguration> getAmmoList() {
return null;
protected List<Integer> 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;
}
}
}

View File

@ -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<BulletConfiguration> getAmmoList() {
protected List<Integer> getAmmoList() {
return null;
}
@ -30,4 +28,9 @@ public class TileEntityTurretJeremy extends TileEntityTurretBaseNT {
public long getMaxPower() {
return 10000;
}
@Override
public void updateFiringTick() {
}
}

View File

@ -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<BulletConfiguration> getAmmoList() {
protected List<Integer> getAmmoList() {
return null;
}
@ -45,4 +43,9 @@ public class TileEntityTurretTauon extends TileEntityTurretBaseNT {
public long getMaxPower() {
return 10000;
}
@Override
public void updateFiringTick() {
}
}