mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
80 lines
2.3 KiB
Java
80 lines
2.3 KiB
Java
package com.hbm.tileentity.turret;
|
|
|
|
import com.hbm.config.WeaponConfig;
|
|
import com.hbm.lib.ModDamageSource;
|
|
import com.hbm.packet.AuxParticlePacketNT;
|
|
import com.hbm.packet.PacketDispatcher;
|
|
import com.hbm.util.EntityDamageUtil;
|
|
|
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.util.Vec3;
|
|
|
|
public class TileEntityTurretHowardDamaged extends TileEntityTurretHoward {
|
|
|
|
@Override
|
|
public boolean hasPower() { //does not need power
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOn() { //is always on
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public double getTurretYawSpeed() {
|
|
return 3D;
|
|
}
|
|
|
|
@Override
|
|
public double getTurretPitchSpeed() {
|
|
return 2D;
|
|
}
|
|
|
|
@Override
|
|
public double getDecetorRange() {
|
|
return 64D;
|
|
}
|
|
|
|
@Override
|
|
public boolean entityAcceptableTarget(Entity e) { //will fire at any living entity
|
|
return e instanceof EntityLivingBase;
|
|
}
|
|
|
|
@Override
|
|
public void updateFiringTick() {
|
|
|
|
timer++;
|
|
|
|
if(this.tPos != null) {
|
|
|
|
this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, "hbm:turret.howard_fire", 4.0F, 0.9F + worldObj.rand.nextFloat() * 0.3F);
|
|
|
|
if(timer % 4 == 0) {
|
|
|
|
if(worldObj.rand.nextInt(100) + 1 <= WeaponConfig.ciwsHitrate * 0.5)
|
|
EntityDamageUtil.attackEntityFromIgnoreIFrame(this.target, ModDamageSource.shrapnel, 2F + worldObj.rand.nextInt(2));
|
|
|
|
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));
|
|
|
|
Vec3 hOff = Vec3.createVectorHelper(0, 0.25, 0);
|
|
hOff.rotateAroundZ((float) -this.rotationPitch);
|
|
hOff.rotateAroundY((float) -(this.rotationYaw + Math.PI * 0.5));
|
|
|
|
NBTTagCompound data = new NBTTagCompound();
|
|
data.setString("type", "vanillaExt");
|
|
data.setString("mode", "largeexplode");
|
|
data.setFloat("size", 1.5F);
|
|
data.setByte("count", (byte)1);
|
|
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.xCoord + vec.xCoord + hOff.xCoord, pos.yCoord + vec.yCoord + hOff.yCoord, pos.zCoord + vec.zCoord + hOff.zCoord), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50));
|
|
}
|
|
}
|
|
}
|
|
}
|