diff --git a/src/main/java/com/hbm/blocks/generic/BlockOutgas.java b/src/main/java/com/hbm/blocks/generic/BlockOutgas.java index ae6107817..9fe92c1b9 100644 --- a/src/main/java/com/hbm/blocks/generic/BlockOutgas.java +++ b/src/main/java/com/hbm/blocks/generic/BlockOutgas.java @@ -103,7 +103,7 @@ public class BlockOutgas extends BlockOre { @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - if(onNeighbour) { + if(onNeighbour && world.rand.nextInt(3) == 0) { for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { diff --git a/src/main/java/com/hbm/blocks/generic/DecoBlockAlt.java b/src/main/java/com/hbm/blocks/generic/DecoBlockAlt.java index 020a202f7..97bd5d391 100644 --- a/src/main/java/com/hbm/blocks/generic/DecoBlockAlt.java +++ b/src/main/java/com/hbm/blocks/generic/DecoBlockAlt.java @@ -1,7 +1,6 @@ package com.hbm.blocks.generic; import java.util.ArrayList; -import java.util.Random; import com.hbm.blocks.ModBlocks; import com.hbm.items.ModItems; diff --git a/src/main/java/com/hbm/entity/EntityMappings.java b/src/main/java/com/hbm/entity/EntityMappings.java index ca32a4fd0..352e85ca4 100644 --- a/src/main/java/com/hbm/entity/EntityMappings.java +++ b/src/main/java/com/hbm/entity/EntityMappings.java @@ -86,9 +86,7 @@ public class EntityMappings { addEntity(EntityGrenadeASchrab.class, "entity_grenade_aschrab", 500); addEntity(EntityFalloutRain.class, "entity_fallout", 1000); addEntity(EntityEMPBlast.class, "entity_emp_blast", 1000); - addEntity(EntityPlasmaBeam.class, "entity_immolator_beam", 1000); addEntity(EntityLN2.class, "entity_LN2", 1000); - addEntity(EntityNightmareBlast.class, "entity_ominous_bullet", 1000); addEntity(EntityGrenadePulse.class, "entity_grenade_pulse", 1000); addEntity(EntityLaserBeam.class, "entity_laser_beam", 1000); addEntity(EntityMinerBeam.class, "entity_miner_beam", 1000); @@ -150,6 +148,7 @@ public class EntityMappings { addEntity(EntityFallingNuke.class, "entity_falling_bomb", 1000); addEntity(EntityBulletBaseNT.class, "entity_bullet_mk3", 250, false); addEntity(EntityBulletBaseMK4.class, "entity_bullet_mk4", 250, false); + addEntity(EntityBulletBeamBase.class, "entity_beam_mk4", 250, false); addEntity(EntityMinerRocket.class, "entity_miner_lander", 1000); addEntity(EntityFogFX.class, "entity_nuclear_fog", 1000); addEntity(EntityDuchessGambit.class, "entity_duchessgambit", 1000); diff --git a/src/main/java/com/hbm/entity/projectile/EntityBulletBeamBase.java b/src/main/java/com/hbm/entity/projectile/EntityBulletBeamBase.java new file mode 100644 index 000000000..38931acf7 --- /dev/null +++ b/src/main/java/com/hbm/entity/projectile/EntityBulletBeamBase.java @@ -0,0 +1,193 @@ +package com.hbm.entity.projectile; + +import java.util.List; + +import com.hbm.items.weapon.sedna.BulletConfig; + +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class EntityBulletBeamBase extends Entity implements IEntityAdditionalSpawnData { + + protected EntityLivingBase thrower; + public BulletConfig config; + public float damage; + public double headingX; + public double headingY; + public double headingZ; + public double beamLength; + + public EntityBulletBeamBase(World world) { + super(world); + this.ignoreFrustumCheck = true; + this.renderDistanceWeight = 10.0D; + this.setSize(0.5F, 0.5F); + } + + public EntityBulletBeamBase(EntityLivingBase entity, BulletConfig config, float baseDamage, float angularInaccuracy, double sideOffset, double heightOffset, double frontOffset) { + this(entity.worldObj); + + this.thrower = entity; + this.setBulletConfig(config); + + this.damage = baseDamage * this.config.damageMult; + + this.setLocationAndAngles(thrower.posX, thrower.posY + thrower.getEyeHeight(), thrower.posZ, thrower.rotationYaw + (float) rand.nextGaussian() * angularInaccuracy, thrower.rotationPitch + (float) rand.nextGaussian() * angularInaccuracy); + + Vec3 offset = Vec3.createVectorHelper(sideOffset, heightOffset, frontOffset); + offset.rotateAroundX(-this.rotationPitch / 180F * (float) Math.PI); + offset.rotateAroundY(-this.rotationYaw / 180F * (float) Math.PI); + + this.posX += offset.xCoord; + this.posY += offset.yCoord; + this.posZ += offset.zCoord; + + this.setPosition(this.posX, this.posY, this.posZ); + + this.headingX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + this.headingZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); + this.headingY = (double) (-MathHelper.sin((this.rotationPitch) / 180.0F * (float) Math.PI)); + + double range = 150D; + this.headingX *= range; + this.headingY *= range; + this.headingZ *= range; + + performHitscan(); + } + + @Override + protected void entityInit() { + this.dataWatcher.addObject(3, Integer.valueOf(0)); + } + + public void setBulletConfig(BulletConfig config) { + this.config = config; + this.dataWatcher.updateObject(3, config.id); + } + + public BulletConfig getBulletConfig() { + int id = this.dataWatcher.getWatchableObjectInt(3); + if(id < 0 || id > BulletConfig.configs.size()) return null; + return BulletConfig.configs.get(id); + } + + @Override + public void onUpdate() { + + if(config == null) config = this.getBulletConfig(); + + if(config == null){ + this.setDead(); + return; + } + + super.onUpdate(); + + if(!worldObj.isRemote && this.ticksExisted > config.expires) this.setDead(); + } + + protected void performHitscan() { + + Vec3 pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 nextPos = Vec3.createVectorHelper(this.posX + this.headingX, this.posY + this.headingY, this.posZ + this.headingZ); + MovingObjectPosition mop = null; + if(!this.isSpectral()) mop = this.worldObj.func_147447_a(pos, nextPos, false, true, false); + pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + nextPos = Vec3.createVectorHelper(this.posX + this.headingX, this.posY + this.headingY, this.posZ + this.headingZ); + + if(mop != null) { + nextPos = Vec3.createVectorHelper(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord); + } + + if(!this.worldObj.isRemote && this.doesImpactEntities()) { + + Entity hitEntity = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.headingX, this.headingY, this.headingZ).expand(1.0D, 1.0D, 1.0D)); + double nearest = 0.0D; + MovingObjectPosition nonPenImpact = null; + + for(int j = 0; j < list.size(); ++j) { + Entity entity = (Entity) list.get(j); + + if(entity.canBeCollidedWith() && entity != thrower) { + double hitbox = 0.3F; + AxisAlignedBB aabb = entity.boundingBox.expand(hitbox, hitbox, hitbox); + MovingObjectPosition hitMop = aabb.calculateIntercept(pos, nextPos); + + if(hitMop != null) { + + // if penetration is enabled, run impact for all intersecting entities + if(this.doesPenetrate()) { + this.onImpact(new MovingObjectPosition(entity, hitMop.hitVec)); + } else { + + double dist = pos.distanceTo(hitMop.hitVec); + + if(dist < nearest || nearest == 0.0D) { + hitEntity = entity; + nearest = dist; + nonPenImpact = hitMop; + } + } + } + } + } + + // if not, only run it for the closest MOP + if(!this.doesPenetrate() && hitEntity != null) { + mop = new MovingObjectPosition(hitEntity, nonPenImpact.hitVec); + } + } + + if(mop != null) { + if(mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ) == Blocks.portal) { + this.setInPortal(); + } else { + this.onImpact(mop); + } + + Vec3 vec = Vec3.createVectorHelper(mop.hitVec.xCoord - posX, mop.hitVec.yCoord - posY, mop.hitVec.zCoord - posZ); + this.beamLength = vec.lengthVector(); + } else { + Vec3 vec = Vec3.createVectorHelper(nextPos.xCoord - posX, nextPos.yCoord - posY, nextPos.zCoord - posZ); + this.beamLength = vec.lengthVector(); + } + + } + + + protected void onImpact(MovingObjectPosition mop) { + if(!worldObj.isRemote) { + if(this.config.onImpactBeam != null) this.config.onImpactBeam.accept(this, mop); + } + } + + public boolean doesImpactEntities() { return this.config.impactsEntities; } + public boolean doesPenetrate() { return this.config.doesPenetrate; } + public boolean isSpectral() { return this.config.isSpectral; } + + @Override @SideOnly(Side.CLIENT) public float getShadowSize() { return 0.0F; } + + @Override protected void writeEntityToNBT(NBTTagCompound nbt) { } + @Override public boolean writeToNBTOptional(NBTTagCompound nbt) { return false; } + @Override public void readEntityFromNBT(NBTTagCompound nbt) { this.setDead(); } + + @Override public void writeSpawnData(ByteBuf buf) { + buf.writeDouble(beamLength); + } + @Override public void readSpawnData(ByteBuf buf) { + this.beamLength = buf.readDouble(); + } +} diff --git a/src/main/java/com/hbm/entity/projectile/EntityNightmareBlast.java b/src/main/java/com/hbm/entity/projectile/EntityNightmareBlast.java deleted file mode 100644 index 0ddbb2409..000000000 --- a/src/main/java/com/hbm/entity/projectile/EntityNightmareBlast.java +++ /dev/null @@ -1,530 +0,0 @@ -package com.hbm.entity.projectile; - -import java.util.List; - -import com.hbm.entity.grenade.EntityGrenadeZOMG; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.IProjectile; -import net.minecraft.entity.monster.EntityEnderman; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.play.server.S2BPacketChangeGameState; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraft.util.MathHelper; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; - -public class EntityNightmareBlast extends Entity implements IProjectile -{ - private int field_145791_d = -1; - private int field_145792_e = -1; - private int field_145789_f = -1; - public double gravity = 0.0D; - private Block field_145790_g; - private int inData; - private boolean inGround; - /** 1 if the player can pick up the arrow */ - public int canBePickedUp; - /** Seems to be some sort of timer for animating an arrow. */ - public int arrowShake; - /** The owner of this arrow. */ - public Entity shootingEntity; - private int ticksInGround; - private int ticksInAir; - private double damage = 2.0D; - /** The amount of knockback an arrow applies when it hits a mob. */ - private int knockbackStrength; - public EntityNightmareBlast(World p_i1753_1_) - { - super(p_i1753_1_); - this.renderDistanceWeight = 10.0D; - this.setSize(0.5F, 0.5F); - } - - public EntityNightmareBlast(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_) - { - super(p_i1754_1_); - this.renderDistanceWeight = 10.0D; - this.setSize(0.5F, 0.5F); - this.setPosition(p_i1754_2_, p_i1754_4_, p_i1754_6_); - this.yOffset = 0.0F; - } - - public EntityNightmareBlast(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) - { - super(p_i1755_1_); - this.renderDistanceWeight = 10.0D; - this.shootingEntity = p_i1755_2_; - - if (p_i1755_2_ instanceof EntityPlayer) - { - this.canBePickedUp = 1; - } - - this.posY = p_i1755_2_.posY + p_i1755_2_.getEyeHeight() - 0.10000000149011612D; - double d0 = p_i1755_3_.posX - p_i1755_2_.posX; - double d1 = p_i1755_3_.boundingBox.minY + p_i1755_3_.height / 3.0F - this.posY; - double d2 = p_i1755_3_.posZ - p_i1755_2_.posZ; - double d3 = MathHelper.sqrt_double(d0 * d0 + d2 * d2); - - if (d3 >= 1.0E-7D) - { - float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; - float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); - double d4 = d0 / d3; - double d5 = d2 / d3; - this.setLocationAndAngles(p_i1755_2_.posX + d4, this.posY, p_i1755_2_.posZ + d5, f2, f3); - this.yOffset = 0.0F; - float f4 = (float)d3 * 0.2F; - this.setThrowableHeading(d0, d1 + f4, d2, p_i1755_4_, p_i1755_5_); - } - } - - public EntityNightmareBlast(World p_i1756_1_, EntityLivingBase p_i1756_2_, float p_i1756_3_, int dmgMin, int dmgMax, EntityGrenadeZOMG grenade) { - super(p_i1756_1_); - this.renderDistanceWeight = 10.0D; - this.shootingEntity = p_i1756_2_; - - this.setSize(0.5F, 0.5F); - this.setLocationAndAngles(grenade.posX, grenade.posY + grenade.getEyeHeight(), grenade.posZ, - grenade.rotationYaw, grenade.rotationPitch); - this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - this.posY -= 0.10000000149011612D; - this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - this.setPosition(this.posX, this.posY, this.posZ); - this.yOffset = 0.0F; - this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI); - this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI); - this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI)); - this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F); - } - - public EntityNightmareBlast(World p_i1756_1_, EntityLivingBase p_i1756_2_, float p_i1756_3_) - { - super(p_i1756_1_); - this.renderDistanceWeight = 10.0D; - this.shootingEntity = p_i1756_2_; - - this.setSize(0.5F, 0.5F); - this.setLocationAndAngles(p_i1756_2_.posX, p_i1756_2_.posY + p_i1756_2_.getEyeHeight(), p_i1756_2_.posZ, p_i1756_2_.rotationYaw, p_i1756_2_.rotationPitch); - this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F; - this.posY -= 0.10000000149011612D; - this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F; - this.setPosition(this.posX, this.posY, this.posZ); - this.yOffset = 0.0F; - this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI); - this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI); - this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); - this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F); - } - - public EntityNightmareBlast(World world, int x, int y, int z, double mx, double my, double mz, double grav) { - super(world); - this.posX = x + 0.5F; - this.posY = y + 0.5F; - this.posZ = z + 0.5F; - - this.motionX = mx; - this.motionY = my; - this.motionZ = mz; - - this.gravity = grav; - } - - @Override - protected void entityInit() - { - this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); - } - - /** - * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. - */ - @Override - public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_) - { - float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_); - p_70186_1_ /= f2; - p_70186_3_ /= f2; - p_70186_5_ /= f2; - p_70186_1_ += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.054499999832361937D * p_70186_8_; - p_70186_3_ += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.054499999832361937D * p_70186_8_; - p_70186_5_ += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.054499999832361937D * p_70186_8_; - p_70186_1_ *= p_70186_7_; - p_70186_3_ *= p_70186_7_; - p_70186_5_ *= p_70186_7_; - this.motionX = p_70186_1_; - this.motionY = p_70186_3_; - this.motionZ = p_70186_5_; - float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70186_3_, f3) * 180.0D / Math.PI); - this.ticksInGround = 0; - } - - /** - * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, - * posY, posZ, yaw, pitch - */ - @Override - @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_) - { - this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_); - this.setRotation(p_70056_7_, p_70056_8_); - } - - /** - * Sets the velocity to the args. Args: x, y, z - */ - @Override - @SideOnly(Side.CLIENT) - public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) - { - this.motionX = p_70016_1_; - this.motionY = p_70016_3_; - this.motionZ = p_70016_5_; - - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) - { - float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, f) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch; - this.prevRotationYaw = this.rotationYaw; - this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); - this.ticksInGround = 0; - } - } - - /** - * Called to update the entity's position/logic. - */ - //@Override - @Override - public void onUpdate() - { - super.onUpdate(); - - if(this.ticksExisted > 100) - this.setDead(); - - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) - { - MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - //this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); - } - - Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f); - - if (block.getMaterial() != Material.air) - { - block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); - block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); - if(!worldObj.isRemote) { - this.worldObj.setBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f, Blocks.air); - this.setDead(); - } - } - - if (this.arrowShake > 0) - { - --this.arrowShake; - } - else - { - ++this.ticksInAir; - Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); - vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - - if (movingobjectposition != null) - { - vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); - } - - Entity entity = null; - List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - int i; - float f1; - - for (i = 0; i < list.size(); ++i) - { - Entity entity1 = (Entity)list.get(i); - - if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) - { - f1 = 0.3F; - AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); - MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); - - if (movingobjectposition1 != null) - { - double d1 = vec31.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) - { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) - { - movingobjectposition = new MovingObjectPosition(entity); - } - - if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) - { - EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit; - - if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer)) - { - movingobjectposition = null; - } - } - - float f2; - float f4; - - if (movingobjectposition != null) - { - if (movingobjectposition.entityHit != null) - { - f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - int k = MathHelper.ceiling_double_int(f2 * this.damage); - - if (this.getIsCritical()) - { - k += this.rand.nextInt(k / 2 + 2); - } - - DamageSource damagesource = null; - - if (this.shootingEntity == null) - { - damagesource = DamageSource.generic; - } - else - { - damagesource = DamageSource.generic; - } - - if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) - { - movingobjectposition.entityHit.setFire(5); - } - - if (movingobjectposition.entityHit.attackEntityFrom(damagesource, k)) - { - if (movingobjectposition.entityHit instanceof EntityLivingBase) - { - EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit; - - if (this.knockbackStrength > 0) - { - f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - - if (f4 > 0.0F) - { - movingobjectposition.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6000000238418579D / f4, 0.1D, this.motionZ * this.knockbackStrength * 0.6000000238418579D / f4); - } - } - - if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) - { - EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); - EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase); - } - - if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) - { - ((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); - } - } - - if (!(movingobjectposition.entityHit instanceof EntityEnderman)) - { - if (!this.worldObj.isRemote && movingobjectposition.entityHit instanceof EntityLivingBase) - { - movingobjectposition.entityHit.attackEntityFrom(damagesource, (float) this.damage); - if(!worldObj.isRemote) - this.worldObj.setBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f, Blocks.air); - this.setDead(); - } - } - } - } - else - { - this.field_145791_d = movingobjectposition.blockX; - this.field_145792_e = movingobjectposition.blockY; - this.field_145789_f = movingobjectposition.blockZ; - this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f); - this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f); - } - } - - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - - f1 = 0.05F; - - if (this.isInWater()) - { - for (int l = 0; l < 4; ++l) - { - f4 = 0.25F; - this.worldObj.spawnParticle("bubble", this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ); - } - } - - if (this.isWet()) - { - this.extinguish(); - } - - this.setPosition(this.posX, this.posY, this.posZ); - this.func_145775_I(); - } - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(NBTTagCompound p_70014_1_) - { - p_70014_1_.setShort("xTile", (short)this.field_145791_d); - p_70014_1_.setShort("yTile", (short)this.field_145792_e); - p_70014_1_.setShort("zTile", (short)this.field_145789_f); - p_70014_1_.setShort("life", (short)this.ticksInGround); - p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g)); - p_70014_1_.setByte("inData", (byte)this.inData); - p_70014_1_.setByte("shake", (byte)this.arrowShake); - p_70014_1_.setByte("inGround", (byte)(this.inGround ? 1 : 0)); - p_70014_1_.setByte("pickup", (byte)this.canBePickedUp); - p_70014_1_.setDouble("damage", this.damage); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(NBTTagCompound p_70037_1_) - { - this.field_145791_d = p_70037_1_.getShort("xTile"); - this.field_145792_e = p_70037_1_.getShort("yTile"); - this.field_145789_f = p_70037_1_.getShort("zTile"); - this.ticksInGround = p_70037_1_.getShort("life"); - this.field_145790_g = Block.getBlockById(p_70037_1_.getByte("inTile") & 255); - this.inData = p_70037_1_.getByte("inData") & 255; - this.arrowShake = p_70037_1_.getByte("shake") & 255; - this.inGround = p_70037_1_.getByte("inGround") == 1; - - if (p_70037_1_.hasKey("damage", 99)) - { - this.damage = p_70037_1_.getDouble("damage"); - } - - if (p_70037_1_.hasKey("pickup", 99)) - { - this.canBePickedUp = p_70037_1_.getByte("pickup"); - } - else if (p_70037_1_.hasKey("player", 99)) - { - this.canBePickedUp = p_70037_1_.getBoolean("player") ? 1 : 0; - } - } - - /** - * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to - * prevent them from trampling crops - */ - @Override - protected boolean canTriggerWalking() - { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() - { - return 0.0F; - } - - public void setDamage(double p_70239_1_) - { - this.damage = p_70239_1_; - } - - public double getDamage() - { - return this.damage; - } - - /** - * Sets the amount of knockback the arrow applies when it hits a mob. - */ - public void setKnockbackStrength(int p_70240_1_) - { - this.knockbackStrength = p_70240_1_; - } - - /** - * If returns false, the item will not inflict any damage against entities. - */ - @Override - public boolean canAttackWithItem() - { - return false; - } - - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public void setIsCritical(boolean p_70243_1_) - { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (p_70243_1_) - { - this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); - } - else - { - this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); - } - } - - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public boolean getIsCritical() - { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - return (b0 & 1) != 0; - } -} diff --git a/src/main/java/com/hbm/entity/projectile/EntityPlasmaBeam.java b/src/main/java/com/hbm/entity/projectile/EntityPlasmaBeam.java deleted file mode 100644 index 406d71d14..000000000 --- a/src/main/java/com/hbm/entity/projectile/EntityPlasmaBeam.java +++ /dev/null @@ -1,556 +0,0 @@ -package com.hbm.entity.projectile; - -import java.util.List; - -import com.hbm.entity.grenade.EntityGrenadeZOMG; -import com.hbm.explosion.ExplosionChaos; -import com.hbm.explosion.ExplosionThermo; -import com.hbm.items.ModItems; -import com.hbm.lib.ModDamageSource; -import com.hbm.main.MainRegistry; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.IProjectile; -import net.minecraft.entity.monster.EntityEnderman; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.play.server.S2BPacketChangeGameState; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraft.util.MathHelper; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; - -public class EntityPlasmaBeam extends Entity implements IProjectile -{ - private int field_145791_d = -1; - private int field_145792_e = -1; - private int field_145789_f = -1; - public double gravity = 0.0D; - private Block field_145790_g; - private int inData; - private boolean inGround; - /** 1 if the player can pick up the arrow */ - public int canBePickedUp; - /** Seems to be some sort of timer for animating an arrow. */ - public int arrowShake; - /** The owner of this arrow. */ - public Entity shootingEntity; - private int ticksInGround; - private int ticksInAir; - private double damage = 2.0D; - /** The amount of knockback an arrow applies when it hits a mob. */ - private int knockbackStrength; - public EntityPlasmaBeam(World p_i1753_1_) - { - super(p_i1753_1_); - this.renderDistanceWeight = 10.0D; - this.setSize(0.5F, 0.5F); - } - - public EntityPlasmaBeam(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_) - { - super(p_i1754_1_); - this.renderDistanceWeight = 10.0D; - this.setSize(0.5F, 0.5F); - this.setPosition(p_i1754_2_, p_i1754_4_, p_i1754_6_); - this.yOffset = 0.0F; - } - - public EntityPlasmaBeam(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) - { - super(p_i1755_1_); - this.renderDistanceWeight = 10.0D; - this.shootingEntity = p_i1755_2_; - - if (p_i1755_2_ instanceof EntityPlayer) - { - this.canBePickedUp = 1; - } - - this.posY = p_i1755_2_.posY + p_i1755_2_.getEyeHeight() - 0.10000000149011612D; - double d0 = p_i1755_3_.posX - p_i1755_2_.posX; - double d1 = p_i1755_3_.boundingBox.minY + p_i1755_3_.height / 3.0F - this.posY; - double d2 = p_i1755_3_.posZ - p_i1755_2_.posZ; - double d3 = MathHelper.sqrt_double(d0 * d0 + d2 * d2); - - if (d3 >= 1.0E-7D) - { - float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; - float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); - double d4 = d0 / d3; - double d5 = d2 / d3; - this.setLocationAndAngles(p_i1755_2_.posX + d4, this.posY, p_i1755_2_.posZ + d5, f2, f3); - this.yOffset = 0.0F; - float f4 = (float)d3 * 0.2F; - this.setThrowableHeading(d0, d1 + f4, d2, p_i1755_4_, p_i1755_5_); - } - } - - public EntityPlasmaBeam(World p_i1756_1_, EntityLivingBase p_i1756_2_, float p_i1756_3_, int dmgMin, int dmgMax, EntityGrenadeZOMG grenade) { - super(p_i1756_1_); - this.renderDistanceWeight = 10.0D; - this.shootingEntity = p_i1756_2_; - - this.setSize(0.5F, 0.5F); - this.setLocationAndAngles(grenade.posX, grenade.posY + grenade.getEyeHeight(), grenade.posZ, - grenade.rotationYaw, grenade.rotationPitch); - this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - this.posY -= 0.10000000149011612D; - this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F; - this.setPosition(this.posX, this.posY, this.posZ); - this.yOffset = 0.0F; - this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI); - this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) - * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI); - this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI)); - this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F); - } - - public EntityPlasmaBeam(World p_i1756_1_, EntityLivingBase p_i1756_2_, float p_i1756_3_) - { - super(p_i1756_1_); - this.renderDistanceWeight = 10.0D; - this.shootingEntity = p_i1756_2_; - - this.setSize(0.5F, 0.5F); - this.setLocationAndAngles(p_i1756_2_.posX, p_i1756_2_.posY + p_i1756_2_.getEyeHeight(), p_i1756_2_.posZ, p_i1756_2_.rotationYaw, p_i1756_2_.rotationPitch); - this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F; - this.posY -= 0.10000000149011612D; - this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F; - this.setPosition(this.posX, this.posY, this.posZ); - this.yOffset = 0.0F; - this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI); - this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI); - this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); - this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F); - } - - public EntityPlasmaBeam(World world, int x, int y, int z, double mx, double my, double mz, double grav) { - super(world); - this.posX = x + 0.5F; - this.posY = y + 0.5F; - this.posZ = z + 0.5F; - - this.motionX = mx; - this.motionY = my; - this.motionZ = mz; - - this.gravity = grav; - } - - @Override - protected void entityInit() - { - this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); - } - - /** - * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. - */ - @Override - public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_) - { - float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_); - p_70186_1_ /= f2; - p_70186_3_ /= f2; - p_70186_5_ /= f2; - p_70186_1_ += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.002499999832361937D * p_70186_8_; - p_70186_3_ += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.002499999832361937D * p_70186_8_; - p_70186_5_ += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.002499999832361937D * p_70186_8_; - p_70186_1_ *= p_70186_7_; - p_70186_3_ *= p_70186_7_; - p_70186_5_ *= p_70186_7_; - this.motionX = p_70186_1_; - this.motionY = p_70186_3_; - this.motionZ = p_70186_5_; - float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70186_3_, f3) * 180.0D / Math.PI); - this.ticksInGround = 0; - } - - /** - * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, - * posY, posZ, yaw, pitch - */ - @Override - @SideOnly(Side.CLIENT) - public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_) - { - this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_); - this.setRotation(p_70056_7_, p_70056_8_); - } - - /** - * Sets the velocity to the args. Args: x, y, z - */ - @Override - @SideOnly(Side.CLIENT) - public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) - { - this.motionX = p_70016_1_; - this.motionY = p_70016_3_; - this.motionZ = p_70016_5_; - - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) - { - float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, f) * 180.0D / Math.PI); - this.prevRotationPitch = this.rotationPitch; - this.prevRotationYaw = this.rotationYaw; - this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); - this.ticksInGround = 0; - } - } - - /** - * Called to update the entity's position/logic. - */ - //@Override - @Override - public void onUpdate() - { - super.onUpdate(); - - if(this.ticksExisted > 100) - this.setDead(); - - if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) - { - MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - //this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); - } - - Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f); - - if (block.getMaterial() != Material.air) - { - block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); - block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); - if(!worldObj.isRemote) { - ExplosionChaos.burn(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, 2); - ExplosionChaos.flameDeath(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, 5); - ExplosionThermo.scorchLight(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, 3); - } - this.setDead(); - } - - if (this.arrowShake > 0) - { - --this.arrowShake; - } - else - { - ++this.ticksInAir; - Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); - vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); - vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); - - if (movingobjectposition != null) - { - vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); - } - - Entity entity = null; - List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - int i; - float f1; - - for (i = 0; i < list.size(); ++i) - { - Entity entity1 = (Entity)list.get(i); - - if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) - { - f1 = 0.3F; - AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1); - MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); - - if (movingobjectposition1 != null) - { - double d1 = vec31.distanceTo(movingobjectposition1.hitVec); - - if (d1 < d0 || d0 == 0.0D) - { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) - { - movingobjectposition = new MovingObjectPosition(entity); - } - - if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) - { - EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit; - - if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer)) - { - movingobjectposition = null; - } - - if(this.ticksExisted > 5 && surviveImmolation(entityplayer)) - movingobjectposition = null; - } - - float f2; - float f4; - - if (movingobjectposition != null) - { - if (movingobjectposition.entityHit != null) - { - f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); - int k = MathHelper.ceiling_double_int(f2 * this.damage); - - if (this.getIsCritical()) - { - k += this.rand.nextInt(k / 2 + 2); - } - - DamageSource damagesource = null; - - if (this.shootingEntity == null) - { - damagesource = DamageSource.generic; - } - else - { - damagesource = ModDamageSource.causePlasmaDamage(this, this.shootingEntity); - } - - if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) - { - movingobjectposition.entityHit.setFire(5); - } - - if (movingobjectposition.entityHit.attackEntityFrom(damagesource, k)) - { - if (movingobjectposition.entityHit instanceof EntityLivingBase) - { - EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit; - - if (this.knockbackStrength > 0) - { - f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - - if (f4 > 0.0F) - { - movingobjectposition.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6000000238418579D / f4, 0.1D, this.motionZ * this.knockbackStrength * 0.6000000238418579D / f4); - } - } - - if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) - { - EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); - EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase); - } - - if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) - { - ((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); - } - } - - if (!(movingobjectposition.entityHit instanceof EntityEnderman)) - { - if (!this.worldObj.isRemote && movingobjectposition.entityHit instanceof EntityLivingBase) - { - movingobjectposition.entityHit.attackEntityFrom(damagesource, 25 + rand.nextInt(20)); - if(!worldObj.isRemote) { - ExplosionChaos.burn(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, 2); - ExplosionChaos.flameDeath(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, 5); - ExplosionThermo.scorchLight(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, 3); - } - this.setDead(); - } - } - } - } - else - { - this.field_145791_d = movingobjectposition.blockX; - this.field_145792_e = movingobjectposition.blockY; - this.field_145789_f = movingobjectposition.blockZ; - this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f); - this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f); - } - } - - this.posX += this.motionX; - this.posY += this.motionY; - this.posZ += this.motionZ; - f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); - - f1 = 0.05F; - - if (this.isInWater()) - { - this.setDead(); - if(!worldObj.isRemote) { - ExplosionChaos.burn(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, 2); - ExplosionChaos.flameDeath(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, 5); - ExplosionThermo.scorchLight(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, 3); - } - } - - if (this.isWet()) - { - this.extinguish(); - } - - this.setPosition(this.posX, this.posY, this.posZ); - this.func_145775_I(); - } - } - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - public void writeEntityToNBT(NBTTagCompound p_70014_1_) - { - p_70014_1_.setShort("xTile", (short)this.field_145791_d); - p_70014_1_.setShort("yTile", (short)this.field_145792_e); - p_70014_1_.setShort("zTile", (short)this.field_145789_f); - p_70014_1_.setShort("life", (short)this.ticksInGround); - p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g)); - p_70014_1_.setByte("inData", (byte)this.inData); - p_70014_1_.setByte("shake", (byte)this.arrowShake); - p_70014_1_.setByte("inGround", (byte)(this.inGround ? 1 : 0)); - p_70014_1_.setByte("pickup", (byte)this.canBePickedUp); - p_70014_1_.setDouble("damage", this.damage); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - public void readEntityFromNBT(NBTTagCompound p_70037_1_) - { - this.field_145791_d = p_70037_1_.getShort("xTile"); - this.field_145792_e = p_70037_1_.getShort("yTile"); - this.field_145789_f = p_70037_1_.getShort("zTile"); - this.ticksInGround = p_70037_1_.getShort("life"); - this.field_145790_g = Block.getBlockById(p_70037_1_.getByte("inTile") & 255); - this.inData = p_70037_1_.getByte("inData") & 255; - this.arrowShake = p_70037_1_.getByte("shake") & 255; - this.inGround = p_70037_1_.getByte("inGround") == 1; - - if (p_70037_1_.hasKey("damage", 99)) - { - this.damage = p_70037_1_.getDouble("damage"); - } - - if (p_70037_1_.hasKey("pickup", 99)) - { - this.canBePickedUp = p_70037_1_.getByte("pickup"); - } - else if (p_70037_1_.hasKey("player", 99)) - { - this.canBePickedUp = p_70037_1_.getBoolean("player") ? 1 : 0; - } - } - - /** - * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to - * prevent them from trampling crops - */ - @Override - protected boolean canTriggerWalking() - { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public float getShadowSize() - { - return 0.0F; - } - - public void setDamage(double p_70239_1_) - { - this.damage = p_70239_1_; - } - - public double getDamage() - { - return this.damage; - } - - /** - * Sets the amount of knockback the arrow applies when it hits a mob. - */ - public void setKnockbackStrength(int p_70240_1_) - { - this.knockbackStrength = p_70240_1_; - } - - /** - * If returns false, the item will not inflict any damage against entities. - */ - @Override - public boolean canAttackWithItem() - { - return false; - } - - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public void setIsCritical(boolean p_70243_1_) - { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - - if (p_70243_1_) - { - this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); - } - else - { - this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); - } - } - - /** - * Whether the arrow has a stream of critical hit particles flying behind it. - */ - public boolean getIsCritical() - { - byte b0 = this.dataWatcher.getWatchableObjectByte(16); - return (b0 & 1) != 0; - } - - private boolean surviveImmolation(EntityPlayer player) { - if(player.inventory.hasItem(ModItems.gun_revolver_pip) && player.inventory.hasItem(ModItems.bottle_sparkle) && player.inventory.hasItem(ModItems.geiger_counter)) { - player.triggerAchievement(MainRegistry.achSacrifice); - player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 3 * 20, 6)); - return true; - } else { - return false; - } - } -} diff --git a/src/main/java/com/hbm/items/weapon/GunHP.java b/src/main/java/com/hbm/items/weapon/GunHP.java index 8d3d0f31b..5899bb44a 100644 --- a/src/main/java/com/hbm/items/weapon/GunHP.java +++ b/src/main/java/com/hbm/items/weapon/GunHP.java @@ -4,10 +4,6 @@ import java.util.List; import java.util.Random; import com.google.common.collect.Multimap; -import com.hbm.entity.projectile.EntityPlasmaBeam; -import com.hbm.items.ModItems; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; @@ -17,6 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.ArrowNockEvent; +@Deprecated public class GunHP extends Item { Random rand = new Random(); @@ -46,52 +43,7 @@ public class GunHP extends Item { } @Override - public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { - World world = player.worldObj; - - boolean flag = player.capabilities.isCreativeMode - || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0; - if ((player.capabilities.isCreativeMode || player.inventory.hasItem(ModItems.gun_hp_ammo))) { - - EntityPlasmaBeam plasma = new EntityPlasmaBeam(world, player, 1F); - EntityPlasmaBeam plasma1 = new EntityPlasmaBeam(world, player, 1F); - EntityPlasmaBeam plasma2 = new EntityPlasmaBeam(world, player, 1F); - EntityPlasmaBeam plasma3 = new EntityPlasmaBeam(world, player, 1F); - EntityPlasmaBeam plasma4 = new EntityPlasmaBeam(world, player, 1F); - plasma1.motionX *= (0.75 + (rand.nextDouble() * 0.5)); - plasma1.motionY *= (0.75 + (rand.nextDouble() * 0.5)); - plasma1.motionZ *= (0.75 + (rand.nextDouble() * 0.5)); - plasma2.motionX *= (0.75 + (rand.nextDouble() * 0.5)); - plasma2.motionY *= (0.75 + (rand.nextDouble() * 0.5)); - plasma2.motionZ *= (0.75 + (rand.nextDouble() * 0.5)); - plasma3.motionX *= (0.75 + (rand.nextDouble() * 0.5)); - plasma3.motionY *= (0.75 + (rand.nextDouble() * 0.5)); - plasma3.motionZ *= (0.75 + (rand.nextDouble() * 0.5)); - plasma4.motionX *= (0.75 + (rand.nextDouble() * 0.5)); - plasma4.motionY *= (0.75 + (rand.nextDouble() * 0.5)); - plasma4.motionZ *= (0.75 + (rand.nextDouble() * 0.5)); - - if (flag) { - plasma.canBePickedUp = 2; - } else { - if (count % 20 == 0) - player.inventory.consumeInventoryItem(ModItems.gun_hp_ammo); - } - - if (count == this.getMaxItemUseDuration(stack)) - world.playSoundAtEntity(player, "hbm:weapon.immolatorIgnite", 1.0F, 1F); - if (count % 10 == 0) - world.playSoundAtEntity(player, "hbm:weapon.immolatorShoot", 1.0F, 1F); - - if (!world.isRemote) { - world.spawnEntityInWorld(plasma); - world.spawnEntityInWorld(plasma1); - world.spawnEntityInWorld(plasma2); - world.spawnEntityInWorld(plasma3); - world.spawnEntityInWorld(plasma4); - } - } - } + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { } @Override public int getItemEnchantability() { diff --git a/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java b/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java index 77a08d1fd..da182ef88 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java +++ b/src/main/java/com/hbm/items/weapon/sedna/BulletConfig.java @@ -6,6 +6,8 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; import com.hbm.entity.projectile.EntityBulletBaseMK4; +import com.hbm.entity.projectile.EntityBulletBeamBase; +import com.hbm.interfaces.NotableComments; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo; @@ -25,6 +27,7 @@ import net.minecraft.util.Vec3; import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.ForgeDirection; +@NotableComments public class BulletConfig implements Cloneable { public static List configs = new ArrayList(); @@ -55,8 +58,9 @@ public class BulletConfig implements Cloneable { /** Whether damage dealt to an entity is subtracted from the projectile's damage on penetration */ public boolean damageFalloffByPen = true; - public Consumer onUpdate; + public Consumer onUpdate; public BiConsumer onImpact; + public BiConsumer onImpactBeam; //fuck fuck fuck fuck i should have used a better base class here god dammit public BiConsumer onRicochet = LAMBDA_STANDARD_RICOCHET; public BiConsumer onEntityHit = LAMBDA_STANDARD_ENTITY_HIT; @@ -71,6 +75,7 @@ public class BulletConfig implements Cloneable { public boolean renderRotations = true; public SpentCasing casing; public BiConsumer renderer; + public BiConsumer rendererBeam; public BulletConfig() { this.id = configs.size(); @@ -108,18 +113,21 @@ public class BulletConfig implements Cloneable { public BulletConfig setSelfDamageDelay(int delay) { this.selfDamageDelay = delay; return this; } public BulletConfig setRenderRotations(boolean rot) { this.renderRotations = rot; return this; } public BulletConfig setCasing(SpentCasing casing) { this.casing = casing; return this; } - public BulletConfig setRenderer(BiConsumer renderer) { this.renderer = renderer; return this; } - - public BulletConfig setOnUpdate(Consumer lambda) { this.onUpdate = lambda; return this; } - public BulletConfig setOnRicochet(BiConsumer lambda) { this.onRicochet = lambda; return this; } - public BulletConfig setOnImpact(BiConsumer lambda) { this.onImpact = lambda; return this; } - public BulletConfig setOnEntityHit(BiConsumer lambda) { this.onEntityHit = lambda; return this; } - public DamageSource getDamage(EntityBulletBaseMK4 bullet, EntityLivingBase shooter, boolean bypass) { + public BulletConfig setRenderer(BiConsumer renderer) { this.renderer = renderer; return this; } + public BulletConfig setRendererBeam(BiConsumer renderer) { this.rendererBeam = renderer; return this; } + + public BulletConfig setOnUpdate(Consumer lambda) { this.onUpdate = lambda; return this; } + public BulletConfig setOnRicochet(BiConsumer lambda) { this.onRicochet = lambda; return this; } + public BulletConfig setOnImpact(BiConsumer lambda) { this.onImpact = lambda; return this; } + public BulletConfig setOnBeamImpact(BiConsumer lambda) { this.onImpactBeam = lambda; return this; } + public BulletConfig setOnEntityHit(BiConsumer lambda) { this.onEntityHit = lambda; return this; } + + public DamageSource getDamage(Entity projectile, EntityLivingBase shooter, boolean bypass) { DamageSource dmg; - if(shooter != null) dmg = new EntityDamageSourceIndirect(damageType, bullet, shooter); + if(shooter != null) dmg = new EntityDamageSourceIndirect(damageType, projectile, shooter); else dmg = new DamageSource(damageType); if(this.dmgProj) dmg.setProjectile(); diff --git a/src/main/java/com/hbm/items/weapon/sedna/Receiver.java b/src/main/java/com/hbm/items/weapon/sedna/Receiver.java index 36f97488a..66c5469fd 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/Receiver.java +++ b/src/main/java/com/hbm/items/weapon/sedna/Receiver.java @@ -143,6 +143,12 @@ public class Receiver { .fire(Lego.LAMBDA_STANDARD_FIRE); } + public Receiver setupBeamFire() { + return this + .canFire(Lego.LAMBDA_STANDARD_CAN_FIRE) + .fire(Lego.LAMBDA_BEAM_FIRE); + } + public Receiver setupLockonFire() { return this .canFire(Lego.LAMBDA_LOCKON_CAN_FIRE) diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java index a0eb311e0..f96cb449a 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java @@ -78,6 +78,7 @@ public class GunFactory { G40_HE, G40_HEAT, G40_DEMO, G40_INC, G40_PHOSPHORUS, ROCKET_HE, ROCKET_HEAT, ROCKET_DEMO, ROCKET_INC, ROCKET_PHOSPHORUS, FLAME_DIESEL, FLAME_GAS, FLAME_NAPALM, FLAME_BALEFIRE, + CAPACITOR, CAPACITOR_OVERCHARGE, CAPACITOR_BLACKLIGHTNING, M44_EQUESTRIAN, G12_EQUESTRIAN, BMG50_EQUESTRIAN } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java index 8ac90fb2f..d51c03c30 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java @@ -11,11 +11,13 @@ import static com.hbm.items.weapon.sedna.factory.XFactory556mm.*; import static com.hbm.items.weapon.sedna.factory.XFactory762mm.*; import static com.hbm.items.weapon.sedna.factory.XFactory9mm.*; import static com.hbm.items.weapon.sedna.factory.XFactoryBlackPowder.*; +import static com.hbm.items.weapon.sedna.factory.XFactoryEnergy.*; import static com.hbm.items.weapon.sedna.factory.XFactoryRocket.*; import java.util.function.BiConsumer; import com.hbm.entity.projectile.EntityBulletBaseMK4; +import com.hbm.entity.projectile.EntityBulletBeamBase; import com.hbm.items.ModItems; import com.hbm.items.weapon.sedna.BulletConfig; import com.hbm.items.weapon.sedna.ItemGunBaseNT; @@ -127,6 +129,8 @@ public class GunFactoryClient { setRendererBulk(LegoClient.RENDER_RPZB, rocket_rpzb); setRendererBulk(LegoClient.RENDER_QD, rocket_qd); setRendererBulk(LegoClient.RENDER_ML, rocket_ml); + + setRendererBulkBeam(LegoClient.RENDER_LIGHTNING, energy_tesla, energy_tesla_overcharge); //HUDS ((ItemGunBaseNT) ModItems.gun_debug) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); ((ItemGunBaseNT) ModItems.gun_pepperbox) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); @@ -164,7 +168,6 @@ public class GunFactoryClient { ((ItemGunBaseNT) ModItems.gun_maresleg_akimbo) .getConfig(null, 1).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); } - public static void setRendererBulk(BiConsumer renderer, BulletConfig... configs) { - for(BulletConfig config : configs) config.setRenderer(renderer); - } + public static void setRendererBulk(BiConsumer renderer, BulletConfig... configs) { for(BulletConfig config : configs) config.setRenderer(renderer); } + public static void setRendererBulkBeam(BiConsumer renderer, BulletConfig... configs) { for(BulletConfig config : configs) config.setRendererBeam(renderer); } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java index 5c8a28cd7..c9c569641 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java @@ -6,10 +6,12 @@ import java.util.function.BiConsumer; import java.util.function.BiFunction; import com.hbm.entity.projectile.EntityBulletBaseMK4; +import com.hbm.entity.projectile.EntityBulletBeamBase; import com.hbm.explosion.vanillant.ExplosionVNT; import com.hbm.explosion.vanillant.standard.EntityProcessorCrossSmooth; import com.hbm.explosion.vanillant.standard.ExplosionEffectWeapon; import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard; +import com.hbm.interfaces.NotableComments; import com.hbm.items.weapon.sedna.BulletConfig; import com.hbm.items.weapon.sedna.GunConfig; import com.hbm.items.weapon.sedna.ItemGunBaseNT; @@ -31,8 +33,11 @@ import net.minecraft.util.Vec3; /** * "LEGO" - i.e. standardized building blocks which can be used to set up gun configs easily. * + * small update, 24/11/03: this turned into fucking spaghetti. fuuuuuuuck. + * * @author hbm */ +@NotableComments public class Lego { public static final Random ANIM_RAND = new Random(); @@ -182,6 +187,9 @@ public class Lego { doStandardFire(stack, ctx, AnimType.CYCLE, true); ItemGunBaseNT.setIsLockedOn(stack, false); }; + public static BiConsumer LAMBDA_BEAM_FIRE = (stack, ctx) -> { + doBeamFire(stack, ctx, AnimType.CYCLE, true); + }; public static void doStandardFire(ItemStack stack, LambdaContext ctx, AnimType anim, boolean calcWear) { EntityLivingBase entity = ctx.entity; @@ -194,23 +202,58 @@ public class Lego { IMagazine mag = primary.getMagazine(stack); BulletConfig config = (BulletConfig) mag.getType(stack, ctx.inventory); + Vec3 offset = primary.getProjectileOffset(stack); + double forwardOffset = offset.xCoord; + double heightOffset = offset.yCoord; + double sideOffset = ItemGunBaseNT.getIsAiming(stack) ? 0 : offset.zCoord; //TODO: make this configurable + + /*forwardOffset = 0.75; + heightOffset = -0.125; + sideOffset = -0.25D;*/ + + int projectiles = config.projectilesMin; + if(config.projectilesMax > config.projectilesMin) projectiles += entity.getRNG().nextInt(config.projectilesMax - config.projectilesMin + 1); + + for(int i = 0; i < projectiles; i++) { + float damage = calcDamage(ctx, stack, primary, calcWear, index); + float spread = calcSpread(ctx, stack, primary, calcWear, index, aim); + EntityBulletBaseMK4 mk4 = new EntityBulletBaseMK4(entity, config, damage, spread, sideOffset, heightOffset, forwardOffset); + if(ItemGunBaseNT.getIsLockedOn(stack)) mk4.lockonTarget = entity.worldObj.getEntityByID(ItemGunBaseNT.getLockonTarget(stack)); + entity.worldObj.spawnEntityInWorld(mk4); + } + + mag.useUpAmmo(stack, ctx.inventory, 1); + if(calcWear) ItemGunBaseNT.setWear(stack, index, Math.min(ItemGunBaseNT.getWear(stack, index) + config.wear, ctx.config.getDurability(stack))); + } + + //shittily copy pasted because god damn this sucks ass why do projectiles need this much fucking setup jesus christ have mercy + public static void doBeamFire(ItemStack stack, LambdaContext ctx, AnimType anim, boolean calcWear) { + EntityLivingBase entity = ctx.entity; + EntityPlayer player = ctx.getPlayer(); + int index = ctx.configIndex; + if(anim != null) ItemGunBaseNT.playAnimation(player, stack, anim, ctx.configIndex); + + float aim = ItemGunBaseNT.getIsAiming(stack) ? 0.25F : 1F; + Receiver primary = ctx.config.getReceivers(stack)[0]; + IMagazine mag = primary.getMagazine(stack); + BulletConfig config = (BulletConfig) mag.getType(stack, ctx.inventory); + Vec3 offset = primary.getProjectileOffset(stack); double forwardOffset = offset.xCoord; double heightOffset = offset.yCoord; double sideOffset = ItemGunBaseNT.getIsAiming(stack) ? 0 : offset.zCoord; /*forwardOffset = 0.75; - heightOffset = -0.125; - sideOffset = -0.25D;*/ + heightOffset = 0; + sideOffset = -0.375D;*/ int projectiles = config.projectilesMin; if(config.projectilesMax > config.projectilesMin) projectiles += entity.getRNG().nextInt(config.projectilesMax - config.projectilesMin + 1); for(int i = 0; i < projectiles; i++) { - float damage = primary.getBaseDamage(stack) * (calcWear ? getStandardWearDamage(stack, ctx.config, index) : 1); - float spread = primary.getGunSpread(stack) * aim + (calcWear ? getStandardWearSpread(stack, ctx.config, index) * 0.125F : 0F); - EntityBulletBaseMK4 mk4 = new EntityBulletBaseMK4(entity, config, damage, spread, sideOffset, heightOffset, forwardOffset); - if(ItemGunBaseNT.getIsLockedOn(stack)) mk4.lockonTarget = entity.worldObj.getEntityByID(ItemGunBaseNT.getLockonTarget(stack)); + float damage = calcDamage(ctx, stack, primary, calcWear, index); + float spread = calcSpread(ctx, stack, primary, calcWear, index, aim); + EntityBulletBeamBase mk4 = new EntityBulletBeamBase(entity, config, damage, spread, sideOffset, heightOffset, forwardOffset); entity.worldObj.spawnEntityInWorld(mk4); } @@ -224,11 +267,27 @@ public class Lego { return (percent - 0.5F) * 2F; } + /** Returns the standard multiplier for damage based on wear */ public static float getStandardWearDamage(ItemStack stack, GunConfig config, int index) { float percent = (float) ItemGunBaseNT.getWear(stack, index) / config.getDurability(stack); if(percent < 0.75F) return 1F; return 1F - (percent - 0.75F) * 2F; } + + /** Returns the full calculated damage based on guncfg and wear */ + public static float calcDamage(LambdaContext ctx, ItemStack stack, Receiver primary, boolean calcWear, int index) { + return primary.getBaseDamage(stack) * (calcWear ? getStandardWearDamage(stack, ctx.config, index) : 1); + } + + public static float calcSpread(LambdaContext ctx, ItemStack stack, Receiver primary, boolean calcWear, int index, float aim) { + return primary.getGunSpread(stack) * aim + (calcWear ? getStandardWearSpread(stack, ctx.config, index) * 0.125F : 0F); //TODO: redo all this spread shit + /* + * spread should have multiple additive parts: + * - hipfire penalty (mitigated by aiming) + * - innate gun inaccuracy (usually 0, increases with wear) + * - bullet inaccuray (usually 0, higher with buckshot) + */ + } public static void standardExplode(EntityBulletBaseMK4 bullet, MovingObjectPosition mop, float range) { standardExplode(bullet, mop, range, 1F); } public static void standardExplode(EntityBulletBaseMK4 bullet, MovingObjectPosition mop, float range, float damageMod) { diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/LegoClient.java b/src/main/java/com/hbm/items/weapon/sedna/factory/LegoClient.java index c13fb1f6a..76a4bea17 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/LegoClient.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/LegoClient.java @@ -5,16 +5,22 @@ import java.util.function.BiConsumer; import org.lwjgl.opengl.GL11; import com.hbm.entity.projectile.EntityBulletBaseMK4; +import com.hbm.entity.projectile.EntityBulletBeamBase; import com.hbm.items.weapon.sedna.hud.HUDComponentAmmoCounter; import com.hbm.items.weapon.sedna.hud.HUDComponentDurabilityBar; import com.hbm.lib.RefStrings; import com.hbm.main.ResourceManager; +import com.hbm.render.util.BeamPronter; +import com.hbm.render.util.BeamPronter.EnumBeamType; +import com.hbm.render.util.BeamPronter.EnumWaveType; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; public class LegoClient { @@ -219,4 +225,21 @@ public class LegoClient { double length = bullet.prevVelocity + (bullet.velocity - bullet.prevVelocity) * interp; if(length > 0) renderBulletStandard(Tessellator.instance, 0x808080, 0xFFF2A7, length * 2, true); }; + + public static BiConsumer RENDER_LIGHTNING = (bullet, interp) -> { + + GL11.glPushMatrix(); + GL11.glRotatef(180 - bullet.rotationYaw, 0, 1F, 0); + GL11.glRotatef(-bullet.rotationPitch - 90, 1F, 0, 0); + Vec3 delta = Vec3.createVectorHelper(0, bullet.beamLength, 0); + double age = MathHelper.clamp_double(1D - ((double) bullet.ticksExisted - 2 + interp) / (double) bullet.getBulletConfig().expires, 0, 1); + GL11.glScaled(age / 2 + 0.5, 1, age / 2 + 0.5); + double scale = 0.075D; + int colorInner = ((int)(0x20 * age) << 16) | ((int)(0x20 * age) << 8) | (int) (0x40 * age); + int colorOuter = ((int)(0x40 * age) << 16) | ((int)(0x40 * age) << 8) | (int) (0x80 * age); + BeamPronter.prontBeam(delta, EnumWaveType.RANDOM, EnumBeamType.SOLID, colorInner, colorInner, bullet.ticksExisted / 3, (int)(bullet.beamLength / 2 + 1), (float)scale * 1F, 4, 0.25F); + BeamPronter.prontBeam(delta, EnumWaveType.RANDOM, EnumBeamType.SOLID, colorOuter, colorOuter, bullet.ticksExisted, (int)(bullet.beamLength / 2 + 1), (float)scale * 7F, 2, 0.0625F); + BeamPronter.prontBeam(delta, EnumWaveType.RANDOM, EnumBeamType.SOLID, colorOuter, colorOuter, bullet.ticksExisted / 2, (int)(bullet.beamLength / 2 + 1), (float)scale * 7F, 2, 0.0625F); + GL11.glPopMatrix(); + }; } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java index 692a9bf69..f42bd576a 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java @@ -859,19 +859,14 @@ public class Orchestras { int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); if(type == AnimType.CYCLE) { - if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.fire.shredderCycle", 0.25F, 1.5F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.fire.shredderCycle", 0.25F, 1.25F); } if(type == AnimType.CYCLE_DRY) { if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.fire.shredderCycle", 0.25F, 1.5F); - } - if(type == AnimType.RELOAD) { - if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 32) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.fire.shredderCycle", 0.25F, 1.25F); } if(type == AnimType.INSPECT) { - if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 28) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 12) entity.worldObj.playSoundAtEntity(entity, "hbm:block.squeakyToy", 0.25F, 1F); } }; } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java index 08cfef072..e99b23dca 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryEnergy.java @@ -1,7 +1,12 @@ package com.hbm.items.weapon.sedna.factory; +import java.util.function.BiConsumer; import java.util.function.BiFunction; +import com.hbm.entity.projectile.EntityBulletBeamBase; +import com.hbm.explosion.vanillant.ExplosionVNT; +import com.hbm.explosion.vanillant.standard.EntityProcessorCrossSmooth; +import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard; import com.hbm.items.ModItems; import com.hbm.items.weapon.sedna.BulletConfig; import com.hbm.items.weapon.sedna.Crosshair; @@ -11,54 +16,92 @@ import com.hbm.items.weapon.sedna.Receiver; import com.hbm.items.weapon.sedna.ItemGunBaseNT.WeaponQuality; import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo; import com.hbm.items.weapon.sedna.mags.MagazineBelt; +import com.hbm.main.MainRegistry; +import com.hbm.packet.PacketDispatcher; +import com.hbm.packet.toclient.AuxParticlePacketNT; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.BusAnimationKeyframe.IType; import com.hbm.render.anim.HbmAnimations.AnimType; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MovingObjectPosition; +import net.minecraftforge.common.util.ForgeDirection; public class XFactoryEnergy { public static BulletConfig energy_tesla; + public static BulletConfig energy_tesla_overcharge; + public static BulletConfig energy_tesla_blacklightning; + + public static BiConsumer LAMBDA_LIGHTNING_HIT = (beam, mop) -> { + + if(mop.typeOfHit == mop.typeOfHit.BLOCK) { + ForgeDirection dir = ForgeDirection.getOrientation(mop.sideHit); + mop.hitVec.xCoord += dir.offsetX * 0.5; + mop.hitVec.yCoord += dir.offsetY * 0.5; + mop.hitVec.zCoord += dir.offsetZ * 0.5; + } + + ExplosionVNT vnt = new ExplosionVNT(beam.worldObj, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 2F); + vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, beam.damage)); + vnt.setPlayerProcessor(new PlayerProcessorStandard()); + vnt.explode(); + beam.worldObj.playSoundEffect(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, "hbm:entity.ufoBlast", 5.0F, 0.9F + beam.worldObj.rand.nextFloat() * 0.2F); + beam.worldObj.playSoundEffect(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, "fireworks.blast", 5.0F, 0.5F); + + float yaw = beam.worldObj.rand.nextFloat() * 180F; + for(int i = 0; i < 3; i++) { + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "plasmablast"); + data.setFloat("r", 0.5F); + data.setFloat("g", 0.5F); + data.setFloat("b", 1.0F); + data.setFloat("pitch", -60F + 60F * i); + data.setFloat("yaw", yaw); + data.setFloat("scale", 2F); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord), + new TargetPoint(beam.worldObj.provider.dimensionId, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord, 100)); + } + }; public static void init() { - - energy_tesla = new BulletConfig().setItem(EnumAmmo.P9_SP).setSpread(0.01F); + + energy_tesla = new BulletConfig().setItem(EnumAmmo.CAPACITOR).setSpread(0.0F).setLife(5).setRenderRotations(false).setDoesPenetrate(true) + .setOnBeamImpact(LAMBDA_LIGHTNING_HIT); + energy_tesla_overcharge = new BulletConfig().setItem(EnumAmmo.CAPACITOR_OVERCHARGE).setSpread(0.0F).setLife(5).setRenderRotations(false).setDoesPenetrate(true) + .setDamage(1.5F).setOnBeamImpact(LAMBDA_LIGHTNING_HIT); + energy_tesla_blacklightning = new BulletConfig().setItem(EnumAmmo.CAPACITOR_BLACKLIGHTNING).setSpread(0.0F).setLife(5).setRenderRotations(false).setDoesPenetrate(true) + .setDamage(5F).setOnBeamImpact(LAMBDA_LIGHTNING_HIT); ModItems.gun_tesla_cannon = new ItemGunBaseNT(WeaponQuality.A_SIDE, new GunConfig() - .dura(2_000).draw(10).inspect(33).reloadSequential(true).crosshair(Crosshair.L_CIRCLE).smoke(Lego.LAMBDA_STANDARD_SMOKE) + .dura(2_000).draw(10).inspect(33).reloadSequential(true).crosshair(Crosshair.CIRCLE).smoke(Lego.LAMBDA_STANDARD_SMOKE) .rec(new Receiver(0) - .dmg(15F).delay(10).reload(44).jam(19).sound("hbm:weapon.fire.blackPowder", 1.0F, 1.0F) - .mag(new MagazineBelt().addConfigs(energy_tesla)) - .offset(0.75, -0.125, -0.25) - .setupStandardFire().recoil(Lego.LAMBDA_STANDARD_RECOIL)) + .dmg(15F).delay(20).reload(44).jam(19).sound("hbm:weapon.fire.blackPowder", 1.0F, 1.0F) + .mag(new MagazineBelt().addConfigs(energy_tesla, energy_tesla_overcharge, energy_tesla_blacklightning)) + .offset(0.75, 0, -0.375) + .setupBeamFire().recoil(Lego.LAMBDA_STANDARD_RECOIL)) .setupStandardConfiguration() .anim(LAMBDA_TESLA_ANIMS).orchestra(Orchestras.ORCHESTRA_TESLA) ).setUnlocalizedName("gun_tesla_cannon"); } @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_TESLA_ANIMS = (stack, type) -> { + int amount = ((ItemGunBaseNT) stack.getItem()).getConfig(stack, 0).getReceivers(stack)[0].getMagazine(stack).getAmount(stack, MainRegistry.proxy.me().inventory); switch(type) { case EQUIP: return new BusAnimation() .addBus("EQUIP", new BusAnimationSequence().addPos(60, 0, 0, 0).addPos(0, 0, 0, 1000, IType.SIN_DOWN)); case CYCLE: return new BusAnimation() - .addBus("RECOIL", new BusAnimationSequence().addPos(0, 0, -1, 50, IType.SIN_DOWN).addPos(0, 0, 0, 150, IType.SIN_FULL)) - .addBus("CYCLE", new BusAnimationSequence().addPos(0, 0, 0, 150).addPos(0, 0, 18, 100)); + .addBus("RECOIL", new BusAnimationSequence().addPos(0, 0, ItemGunBaseNT.getIsAiming(stack) ? -0.5 : -1, 100, IType.SIN_DOWN).addPos(0, 0, 0, 250, IType.SIN_FULL)) + .addBus("CYCLE", new BusAnimationSequence().addPos(0, 0, 0, 150).addPos(0, 0, 22.5, 350)) + .addBus("COUNT", new BusAnimationSequence().addPos(amount, 0, 0, 0)); case CYCLE_DRY: return new BusAnimation() - .addBus("CYCLE", new BusAnimationSequence().addPos(0, 0, 0, 150).addPos(0, 0, 18, 100)); - case RELOAD: return new BusAnimation() - .addBus("MAG", new BusAnimationSequence().addPos(0, -8, 0, 250, IType.SIN_UP).addPos(0, -8, 0, 1000).addPos(0, 0, 0, 300)) - .addBus("LIFT", new BusAnimationSequence().addPos(0, 0, 0, 750).addPos(-25, 0, 0, 300, IType.SIN_FULL).addPos(-25, 0, 0, 500).addPos(-27, 0, 0, 100, IType.SIN_DOWN).addPos(-25, 0, 0, 100, IType.SIN_FULL).addPos(-25, 0, 0, 150).addPos(0, 0, 0, 300, IType.SIN_FULL)); - case JAMMED: return new BusAnimation() - .addBus("MAG", new BusAnimationSequence().addPos(0, 0, 0, 500).addPos(0, -2, 0, 150, IType.SIN_UP).addPos(0, 0, 0, 100)) - .addBus("LIFT", new BusAnimationSequence().addPos(0, 0, 0, 750).addPos(-2, 0, 0, 100, IType.SIN_DOWN).addPos(0, 0, 0, 100, IType.SIN_FULL)); + .addBus("CYCLE", new BusAnimationSequence().addPos(0, 0, 0, 150).addPos(0, 0, 22.5, 350)); case INSPECT: return new BusAnimation() - .addBus("MAG", new BusAnimationSequence() - .addPos(0, -1, 0, 150).addPos(6, -1, 0, 150).addPos(6, 12, 0, 350, IType.SIN_DOWN).addPos(6, -2, 0, 350, IType.SIN_UP).addPos(6, -1, 0, 50) - .addPos(6, -1, 0, 100).addPos(0, -1, 0, 150, IType.SIN_FULL).addPos(0, 0, 0, 150, IType.SIN_UP)) - .addBus("SPEEN", new BusAnimationSequence().addPos(0, 0, 0, 300).addPos(360, 0, 0, 700)) - .addBus("LIFT", new BusAnimationSequence().addPos(0, 0, 0, 1450).addPos(-2, 0, 0, 100, IType.SIN_DOWN).addPos(0, 0, 0, 100, IType.SIN_FULL)); + .addBus("YOMI", new BusAnimationSequence().addPos(8, -4, 0, 0).addPos(4, -1, 0, 500, IType.SIN_DOWN).addPos(4, -1, 0, 1000).addPos(6, -6, 0, 500, IType.SIN_UP)) + .addBus("SQUEEZE", new BusAnimationSequence().addPos(1, 1, 1, 0).addPos(1, 1, 1, 750).addPos(1, 1, 0.5, 125).addPos(1, 1, 1, 125)); } return null; diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryFlamer.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryFlamer.java index 24b55823a..818c28f0d 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryFlamer.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryFlamer.java @@ -28,6 +28,7 @@ import com.hbm.render.anim.BusAnimationKeyframe.IType; import com.hbm.render.anim.HbmAnimations.AnimType; import net.minecraft.block.Block; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -44,10 +45,10 @@ public class XFactoryFlamer { public static BulletConfig flame_balefire; public static BulletConfig flame_digamma; - public static Consumer LAMBDA_FIRE = (bullet) -> { + public static Consumer LAMBDA_FIRE = (bullet) -> { if(bullet.worldObj.isRemote && MainRegistry.proxy.me().getDistanceToEntity(bullet) < 100) FlameCreator.composeEffectClient(bullet.worldObj, bullet.posX, bullet.posY - 0.125, bullet.posZ, FlameCreator.META_FIRE); }; - public static Consumer LAMBDA_BALEFIRE = (bullet) -> { + public static Consumer LAMBDA_BALEFIRE = (bullet) -> { if(bullet.worldObj.isRemote && MainRegistry.proxy.me().getDistanceToEntity(bullet) < 100) FlameCreator.composeEffectClient(bullet.worldObj, bullet.posX, bullet.posY - 0.125, bullet.posZ, FlameCreator.META_BALEFIRE); }; public static BiConsumer LAMBDA_IGNITE_FIRE = (bullet, mop) -> { diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryRocket.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryRocket.java index c6d4eb2d7..cbf9b835e 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryRocket.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryRocket.java @@ -31,6 +31,7 @@ import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.BusAnimationKeyframe.IType; import com.hbm.render.anim.HbmAnimations.AnimType; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -48,10 +49,12 @@ public class XFactoryRocket { public static BulletConfig[] rocket_ml; // FLYING - public static Consumer LAMBDA_STANDARD_ACCELERATE = (bullet) -> { + public static Consumer LAMBDA_STANDARD_ACCELERATE = (entity) -> { + EntityBulletBaseMK4 bullet = (EntityBulletBaseMK4) entity; if(bullet.accel < 7) bullet.accel += 0.4D; }; - public static Consumer LAMBDA_STEERING_ACCELERATE = (bullet) -> { + public static Consumer LAMBDA_STEERING_ACCELERATE = (entity) -> { + EntityBulletBaseMK4 bullet = (EntityBulletBaseMK4) entity; if(bullet.accel < 4) bullet.accel += 0.4D; if(bullet.getThrower() == null || !(bullet.getThrower() instanceof EntityPlayer)) return; diff --git a/src/main/java/com/hbm/lib/ModDamageSource.java b/src/main/java/com/hbm/lib/ModDamageSource.java index 691de5b8f..287385c20 100644 --- a/src/main/java/com/hbm/lib/ModDamageSource.java +++ b/src/main/java/com/hbm/lib/ModDamageSource.java @@ -95,10 +95,6 @@ public class ModDamageSource extends DamageSource { return (new EntityDamageSourceIndirect(s_euthanized, ent, hit)).setDamageBypassesArmor(); } - public static DamageSource causePlasmaDamage(EntityPlasmaBeam ent, Entity hit) { - return (new EntityDamageSourceIndirect(s_immolator, ent, hit)).setDamageBypassesArmor(); - } - public static DamageSource causeIceDamage(EntityLN2 ent, Entity hit) { return (new EntityDamageSourceIndirect(s_cryolator, ent, hit)).setDamageBypassesArmor(); } diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 43c1764f8..7fd22abdc 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -624,9 +624,8 @@ public class ClientProxy extends ServerProxy { RenderingRegistry.registerEntityRenderingHandler(EntityBullet.class, new RenderRocket()); RenderingRegistry.registerEntityRenderingHandler(EntityBulletBaseNT.class, new RenderBullet()); RenderingRegistry.registerEntityRenderingHandler(EntityBulletBaseMK4.class, new RenderBulletMK4()); + RenderingRegistry.registerEntityRenderingHandler(EntityBulletBeamBase.class, new RenderBeam()); RenderingRegistry.registerEntityRenderingHandler(EntityRainbow.class, new RenderRainbow()); - RenderingRegistry.registerEntityRenderingHandler(EntityNightmareBlast.class, new RenderOminousBullet()); - RenderingRegistry.registerEntityRenderingHandler(EntityPlasmaBeam.class, new RenderBeam()); RenderingRegistry.registerEntityRenderingHandler(EntityLaserBeam.class, new RenderBeam2()); RenderingRegistry.registerEntityRenderingHandler(EntityMinerBeam.class, new RenderBeam3()); RenderingRegistry.registerEntityRenderingHandler(EntitySparkBeam.class, new RenderBeam4()); diff --git a/src/main/java/com/hbm/render/entity/projectile/RenderBeam.java b/src/main/java/com/hbm/render/entity/projectile/RenderBeam.java index 6a0e4a6fe..10db6d628 100644 --- a/src/main/java/com/hbm/render/entity/projectile/RenderBeam.java +++ b/src/main/java/com/hbm/render/entity/projectile/RenderBeam.java @@ -1,80 +1,36 @@ package com.hbm.render.entity.projectile; -import java.util.Random; - import org.lwjgl.opengl.GL11; -import com.hbm.lib.RefStrings; -import net.minecraft.client.renderer.Tessellator; +import com.hbm.entity.projectile.EntityBulletBeamBase; +import com.hbm.main.ResourceManager; + import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class RenderBeam extends Render { - - Random rand = new Random(); @Override - public void doRender(Entity rocket, double x, double y, double z, float p_76986_8_, float p_76986_9_) { - float radius = 0.12F; - //float radius = 0.06F; - int distance = 4; - Tessellator tessellator = Tessellator.instance; - + public void doRender(Entity entity, double x, double y, double z, float f0, float interp) { + EntityBulletBeamBase bullet = (EntityBulletBeamBase) entity; + if(bullet.config == null) bullet.config = bullet.getBulletConfig(); + if(bullet.config == null) return; + GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glTranslatef((float) x, (float) y, (float) z); - - GL11.glRotatef(rocket.rotationYaw, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-rocket.rotationPitch, 1.0F, 0.0F, 0.0F); - - boolean red = false; - boolean green = true; - boolean blue = false; - - for (float o = 0; o <= radius; o += radius / 8) { - float color = 1f - (o * 8.333f); - if (color < 0) - color = 0; - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(red ? 1 : color, green ? 1 : color, blue ? 1 : color, 1f); - tessellator.addVertex(0 + o, 0 - o, 0); - tessellator.addVertex(0 + o, 0 + o, 0); - tessellator.addVertex(0 + o, 0 + o, 0 + distance); - tessellator.addVertex(0 + o, 0 - o, 0 + distance); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(red ? 1 : color, green ? 1 : color, blue ? 1 : color, 1f); - tessellator.addVertex(0 - o, 0 - o, 0); - tessellator.addVertex(0 + o, 0 - o, 0); - tessellator.addVertex(0 + o, 0 - o, 0 + distance); - tessellator.addVertex(0 - o, 0 - o, 0 + distance); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(red ? 1 : color, green ? 1 : color, blue ? 1 : color, 1f); - tessellator.addVertex(0 - o, 0 + o, 0); - tessellator.addVertex(0 - o, 0 - o, 0); - tessellator.addVertex(0 - o, 0 - o, 0 + distance); - tessellator.addVertex(0 - o, 0 + o, 0 + distance); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(red ? 1 : color, green ? 1 : color, blue ? 1 : color, 1f); - tessellator.addVertex(0 + o, 0 + o, 0); - tessellator.addVertex(0 - o, 0 + o, 0); - tessellator.addVertex(0 - o, 0 + o, 0 + distance); - tessellator.addVertex(0 + o, 0 + o, 0 + distance); - tessellator.draw(); + + if(bullet.config.renderRotations) { + GL11.glRotatef(bullet.prevRotationYaw + (bullet.rotationYaw - bullet.prevRotationYaw) * interp - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(bullet.prevRotationPitch + (bullet.rotationPitch - bullet.prevRotationPitch) * interp + 180, 0.0F, 0.0F, 1.0F); } - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); + + if(bullet.config.rendererBeam != null) { + bullet.config.rendererBeam.accept(bullet, interp); + } + GL11.glPopMatrix(); } - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return new ResourceLocation(RefStrings.MODID + ":textures/models/PlasmaBeam.png"); - } + @Override protected ResourceLocation getEntityTexture(Entity entity) { return ResourceManager.universal; } } diff --git a/src/main/java/com/hbm/render/entity/projectile/RenderOminousBullet.java b/src/main/java/com/hbm/render/entity/projectile/RenderOminousBullet.java deleted file mode 100644 index 09bec73a2..000000000 --- a/src/main/java/com/hbm/render/entity/projectile/RenderOminousBullet.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.hbm.render.entity.projectile; - -import java.util.Random; - -import org.lwjgl.opengl.GL11; - -import com.hbm.lib.RefStrings; - -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; - -public class RenderOminousBullet extends Render { - - Random rand = new Random(); - - @Override - public void doRender(Entity rocket, double x, double y, double z, float p_76986_8_, float p_76986_9_) { - float radius = 0.12F; - int distance = 4; - - radius = 0.03F; - - Tessellator tessellator = Tessellator.instance; - - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - GL11.glTranslatef((float) x, (float) y, (float) z); - - GL11.glRotatef(rocket.rotationYaw, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-rocket.rotationPitch, 1.0F, 0.0F, 0.0F); - - boolean red = false; - boolean green = false; - boolean blue = false; - - green = true; - red = true; - - //for (float o = 0; o <= radius; o += radius / 8) { - for (float o = 0; o <= radius; o += radius / 1) { - float color = 1f - (o * 8.333f); - if (color < 0) - color = 0; - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(red ? 1 : color, green ? 1 : color, blue ? 1 : color, 1f); - tessellator.addVertex(0 + o, 0 - o, 0); - tessellator.addVertex(0 + o, 0 + o, 0); - tessellator.addVertex(0 + o, 0 + o, 0 + distance); - tessellator.addVertex(0 + o, 0 - o, 0 + distance); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(red ? 1 : color, green ? 1 : color, blue ? 1 : color, 1f); - tessellator.addVertex(0 - o, 0 - o, 0); - tessellator.addVertex(0 + o, 0 - o, 0); - tessellator.addVertex(0 + o, 0 - o, 0 + distance); - tessellator.addVertex(0 - o, 0 - o, 0 + distance); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(red ? 1 : color, green ? 1 : color, blue ? 1 : color, 1f); - tessellator.addVertex(0 - o, 0 + o, 0); - tessellator.addVertex(0 - o, 0 - o, 0); - tessellator.addVertex(0 - o, 0 - o, 0 + distance); - tessellator.addVertex(0 - o, 0 + o, 0 + distance); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(red ? 1 : color, green ? 1 : color, blue ? 1 : color, 1f); - tessellator.addVertex(0 + o, 0 + o, 0); - tessellator.addVertex(0 - o, 0 + o, 0); - tessellator.addVertex(0 - o, 0 + o, 0 + distance); - tessellator.addVertex(0 + o, 0 + o, 0 + distance); - tessellator.draw(); - } - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glPopMatrix(); - } - - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return new ResourceLocation(RefStrings.MODID + ":textures/models/Rainbow.png"); - } -} diff --git a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderTeslaCannon.java b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderTeslaCannon.java index 6a9b4f26d..d3192e3f0 100644 --- a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderTeslaCannon.java +++ b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderTeslaCannon.java @@ -6,6 +6,7 @@ import com.hbm.items.weapon.sedna.ItemGunBaseNT; import com.hbm.main.MainRegistry; import com.hbm.main.ResourceManager; import com.hbm.render.anim.HbmAnimations; +import com.hbm.render.tileentity.RenderPlushie; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; @@ -36,26 +37,41 @@ public class ItemRenderTeslaCannon extends ItemRenderWeaponBase { GL11.glScaled(scale, scale, scale); double[] equip = HbmAnimations.getRelevantTransformation("EQUIP"); + double[] recoil = HbmAnimations.getRelevantTransformation("RECOIL"); + double[] cycle = HbmAnimations.getRelevantTransformation("CYCLE"); + double[] count = HbmAnimations.getRelevantTransformation("COUNT"); + double[] yomi = HbmAnimations.getRelevantTransformation("YOMI"); + double[] squeeze = HbmAnimations.getRelevantTransformation("SQUEEZE"); GL11.glTranslated(0, -2, -2); GL11.glRotated(equip[0], 1, 0, 0); GL11.glTranslated(0, 2, 2); + + GL11.glTranslated(0, 0, recoil[2]); + GL11.glRotated(recoil[2] * 2, 1, 0, 0); GL11.glShadeModel(GL11.GL_SMOOTH); - int amount = gun.getConfig(stack, 0).getReceivers(stack)[0].getMagazine(stack).getAmount(stack, MainRegistry.proxy.me().inventory); + int amount = Math.max((int) count[0], gun.getConfig(stack, 0).getReceivers(stack)[0].getMagazine(stack).getAmount(stack, MainRegistry.proxy.me().inventory)); ResourceManager.tesla_cannon.renderPart("Gun"); ResourceManager.tesla_cannon.renderPart("Extension"); + double cogAngle = cycle[2]; + GL11.glPushMatrix(); - GL11.glTranslated(0, -1.875, 0); - GL11.glRotated(-22.5, 0, 0, 1); - GL11.glTranslated(0, 1.875, 0); + GL11.glTranslated(0, -1.625, 0); + GL11.glRotated(cogAngle, 0, 0, 1); + GL11.glTranslated(0, 1.625, 0); ResourceManager.tesla_cannon.renderPart("Cog"); GL11.glPopMatrix(); GL11.glPushMatrix(); + + GL11.glTranslated(0, -1.625, 0); + GL11.glRotated(cogAngle, 0, 0, 1); + GL11.glTranslated(0, 1.625, 0); + for(int i = 0; i < Math.min(amount, 8); i++) { ResourceManager.tesla_cannon.renderPart("Capacitor"); @@ -64,12 +80,26 @@ public class ItemRenderTeslaCannon extends ItemRenderWeaponBase { GL11.glRotated(-22.5, 0, 0, 1); GL11.glTranslated(0, 1.625, 0); } else { + if(i == 4) { + GL11.glTranslated(0, -1.625, 0); + GL11.glRotated(-cogAngle, 0, 0, 1); + GL11.glTranslated(0, 1.625, 0); + GL11.glTranslated(-cogAngle * 0.5 / 22.5, 0, 0); + } GL11.glTranslated(0.5, 0, 0); } } GL11.glPopMatrix(); GL11.glShadeModel(GL11.GL_FLAT); + + GL11.glPushMatrix(); + GL11.glTranslated(yomi[0], yomi[1], yomi[2]); + GL11.glRotated(135, 0, 1, 0); + GL11.glScaled(squeeze[0], squeeze[1], squeeze[2]); + Minecraft.getMinecraft().renderEngine.bindTexture(RenderPlushie.yomiTex); + RenderPlushie.yomiModel.renderAll(); + GL11.glPopMatrix(); } @Override diff --git a/src/main/resources/assets/hbm/textures/items/ammo.png b/src/main/resources/assets/hbm/textures/items/ammo.png index b899cb0fe..59ddc335f 100644 Binary files a/src/main/resources/assets/hbm/textures/items/ammo.png and b/src/main/resources/assets/hbm/textures/items/ammo.png differ diff --git a/src/main/resources/assets/hbm/textures/items/ammo_standard.capacitor.png b/src/main/resources/assets/hbm/textures/items/ammo_standard.capacitor.png new file mode 100644 index 000000000..15184342e Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/ammo_standard.capacitor.png differ diff --git a/src/main/resources/assets/hbm/textures/items/ammo_standard.capacitor_blacklightning.png b/src/main/resources/assets/hbm/textures/items/ammo_standard.capacitor_blacklightning.png new file mode 100644 index 000000000..00b4e57ae Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/ammo_standard.capacitor_blacklightning.png differ diff --git a/src/main/resources/assets/hbm/textures/items/ammo_standard.capacitor_overcharge.png b/src/main/resources/assets/hbm/textures/items/ammo_standard.capacitor_overcharge.png new file mode 100644 index 000000000..378f2cd82 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/ammo_standard.capacitor_overcharge.png differ