use of icbm.classic.content.entity.EntityExplosion in project ICBM-Classic by BuiltBrokenModding.
the class RenderExplosion method doRender.
@Override
public void doRender(Entity entity, double x, double y, double z, float par8, float par9) {
EntityExplosion entityExplosion = (EntityExplosion) entity;
if (entityExplosion.getBlast() != null) {
// RedM atter Render
if (entityExplosion.getBlast() instanceof BlastRedmatter) {
Tessellator tessellator = Tessellator.instance;
/** Draw Sphere */
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y + entityExplosion.yOffset, (float) z);
RenderUtility.enableBlending();
RenderUtility.disableLighting();
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.9f);
bindTexture(SharedAssets.GREY_TEXTURE);
Sphere sphere = new Sphere();
float radius = Math.max((BlastRedmatter.ENTITY_DESTROY_RADIUS * (entityExplosion.getBlast().getRadius() / BlastRedmatter.NORMAL_RADIUS)), 6);
sphere.draw(radius, 32, 32);
// Enable Lighting/Glow Off
RenderUtility.enableLighting();
// Disable Blending
RenderUtility.disableBlending();
GL11.glPopMatrix();
/** Draw Vortex
*
* GL11.glPushMatrix(); GL11.glDepthMask(false);
*
* CalclaviaRenderHelper.enableBlending(); CalclaviaRenderHelper.disableLighting();
*
* GL11.glTranslated(x, y, z); GL11.glRotatef(-entity.ticksExisted, 0, 1, 0);
*
* float size = 10; float f10 = 1.0F;
*
* int textureSize = 50; float size4 = size * 5; float float_sizeMinus0_01 =
* textureSize - 0.01F;
*
* float x0 = (textureSize + 0.0F) / size4; float x1 = (textureSize +
* float_sizeMinus0_01) / size4; float x2 = (textureSize + 0.0F) / size4; float x3 =
* (textureSize + float_sizeMinus0_01) / size4;
*
* float renderX = (float) x; float renderY = (float) y; float renderZ = (float) z;
*
* this.bindTexture(TEXTURE_FILE); tessellator.startDrawingQuads();
* tessellator.setBrightness(240); tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1F);
* tessellator.addVertexWithUV(-size, 0, -size, x1, x3);
* tessellator.addVertexWithUV(-size, 0, +size, x1, x2);
* tessellator.addVertexWithUV(+size, 0, +size, x0, x2);
* tessellator.addVertexWithUV(+size, 0, -size, x0, x3); tessellator.draw();
*
* // Enable Lighting/Glow Off CalclaviaRenderHelper.enableLighting();
*
* // Disable Blending CalclaviaRenderHelper.disableBlending();
*
* GL11.glDepthMask(true); GL11.glPopMatrix(); */
/** Enderdragon Light */
float par2 = (entity.ticksExisted);
while (par2 > 200) par2 -= 100;
RenderHelper.disableStandardItemLighting();
float var41 = (5 + par2) / 200.0F;
float var51 = 0.0F;
if (var41 > 0.8F) {
var51 = (var41 - 0.8F) / 0.2F;
}
Random rand = new Random(432L);
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, -1.0F, -2.0F);
for (int i1 = 0; i1 < (var41 + var41 * var41) / 2.0F * 60.0F; ++i1) {
GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F + var41 * 90.0F, 0.0F, 0.0F, 1.0F);
tessellator.startDrawing(6);
float var81 = rand.nextFloat() * 20.0F + 5.0F + var51 * 10.0F;
float var91 = rand.nextFloat() * 2.0F + 1.0F + var51 * 2.0F;
tessellator.setColorRGBA_I(16777215, (int) (255.0F * (1.0F - var51)));
tessellator.addVertex(0.0D, 0.0D, 0.0D);
tessellator.setColorRGBA_I(0, 0);
tessellator.addVertex(-0.866D * var91, var81, -0.5F * var91);
tessellator.addVertex(0.866D * var91, var81, -0.5F * var91);
tessellator.addVertex(0.0D, var81, 1.0F * var91);
tessellator.addVertex(-0.866D * var91, var81, -0.5F * var91);
tessellator.draw();
}
GL11.glPopMatrix();
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_ALPHA_TEST);
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
} else {
if (entityExplosion.getBlast().getRenderModel() != null && entityExplosion.getBlast().getRenderResource() != null) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y + 1F, (float) z);
GL11.glRotatef(entityExplosion.rotationPitch, 0.0F, 0.0F, 1.0F);
this.bindTexture(entityExplosion.getBlast().getRenderResource());
entityExplosion.getBlast().getRenderModel().render(entityExplosion, (float) x, (float) y, (float) z, par8, par9, 0.0625F);
GL11.glPopMatrix();
}
}
}
}
use of icbm.classic.content.entity.EntityExplosion in project ICBM-Classic by BuiltBrokenModding.
the class CommandICBM method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) {
try {
EntityPlayer entityPlayer = (EntityPlayer) sender;
int dimension = entityPlayer.worldObj.provider.dimensionId;
if (args == null || args.length == 0 || args[0].equalsIgnoreCase("help")) {
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc help"));
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc lag <radius>"));
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc remove <All/Missile/Explosion> <radius>"));
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc emp <radius>"));
return;
} else if (args.length >= 2 && args[0].equalsIgnoreCase("lag")) {
int radius = parseInt(sender, args[1]);
if (radius > 0) {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(entityPlayer.posX - radius, entityPlayer.posY - radius, entityPlayer.posZ - radius, entityPlayer.posX + radius, entityPlayer.posY + radius, entityPlayer.posZ + radius);
List<Entity> entitiesNearby = entityPlayer.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : entitiesNearby) {
if (entity instanceof EntityFlyingBlock) {
((EntityFlyingBlock) entity).setBlock();
} else if (entity instanceof EntityMissile) {
entity.setDead();
} else if (entity instanceof EntityExplosion) {
entity.setDead();
}
}
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM lag sources within " + radius + " radius."));
return;
} else {
throw new WrongUsageException("Radius needs to be higher than zero");
}
} else if (args.length >= 3 && args[0].equalsIgnoreCase("remove")) {
int radius = parseInt(sender, args[2]);
boolean all = args[1].equalsIgnoreCase("all");
boolean missile = args[1].equalsIgnoreCase("missiles");
boolean explosion = args[1].equalsIgnoreCase("explosion");
String str = "entities";
if (missile) {
str = "missiles";
}
if (explosion) {
str = "explosions";
}
if (radius > 0) {
EntityPlayer player = (EntityPlayer) sender;
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(player.posX - radius, player.posY - radius, player.posZ - radius, player.posX + radius, player.posY + radius, player.posZ + radius);
List<Entity> entitiesNearby = player.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : entitiesNearby) {
if ((all || explosion) && entity instanceof EntityFlyingBlock) {
((EntityFlyingBlock) entity).setBlock();
} else if ((all || missile) && entity instanceof EntityMissile) {
entity.setDead();
} else if ((all || explosion) && entity instanceof EntityExplosion) {
entity.setDead();
}
}
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM " + str + " within " + radius + " radius."));
return;
} else {
throw new WrongUsageException("Radius needs to be higher than zero");
}
} else if (args.length >= 2 && args[0].equalsIgnoreCase("emp")) {
int radius = parseInt(sender, args[1]);
if (radius > 0) {
new BlastEMP(entityPlayer.worldObj, null, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, radius).setEffectBlocks().setEffectEntities().doExplode();
switch(entityPlayer.worldObj.rand.nextInt(20)) {
case 0:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Did you pay the power bill?"));
return;
case 1:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("See them power their toys now!"));
return;
case 2:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Hey who turned the lights out."));
return;
case 3:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Ha! I run on steam power!"));
return;
case 4:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("The power of lighting at my finger tips!"));
return;
default:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Zap!"));
return;
}
} else {
throw new WrongUsageException("Radius needs to be higher than zero");
}
}
} catch (Exception e) {
}
throw new WrongUsageException(this.getCommandUsage(sender));
}
use of icbm.classic.content.entity.EntityExplosion in project ICBM-Classic by BuiltBrokenModding.
the class BlastRedmatter method affectEntity.
/**
* Makes an entity get affected by Red Matter.
*
* @Return True if explosion happened
*/
public boolean affectEntity(float radius, Entity entity, boolean doExplosion) {
//Ignore players that are in creative mode or can't be harmed
if (entity instanceof EntityPlayer && (((EntityPlayer) entity).capabilities.isCreativeMode || ((EntityPlayer) entity).capabilities.disableDamage)) {
return false;
}
//Ignore self
if (entity == this.controller) {
return false;
}
//Ignore entities that mark themselves are ignorable
if (entity instanceof IExplosiveIgnore) {
if (((IExplosiveIgnore) entity).canIgnore(this)) {
return false;
}
}
//Calculate different from center
double xDifference = entity.posX - position.xi() + 0.5;
double yDifference = entity.posY - position.yi() + 0.5;
double zDifference = entity.posZ - position.zi() + 0.5;
/** The percentage of the closeness of the entity. */
double xPercentage = 1 - (xDifference / radius);
double yPercentage = 1 - (yDifference / radius);
double zPercentage = 1 - (zDifference / radius);
double distancePercentage = this.position.distance(entity) / radius;
Pos entityPosition = new Pos(entity);
Pos centeredPosition = entityPosition.subtract(this.position);
centeredPosition = (Pos) centeredPosition.transform(new EulerAngle(1.5 * distancePercentage * Math.random(), 1.5 * distancePercentage * Math.random(), 1.5 * distancePercentage * Math.random()));
Location newPosition = this.position.add(centeredPosition);
// Orbit Velocity
entity.addVelocity(newPosition.x() - entityPosition.x(), 0, newPosition.z() - entityPosition.z());
// Gravity Velocity (0.015 is barely enough to overcome y gravity so do not lower)
entity.addVelocity(-xDifference * 0.015 * xPercentage, -yDifference * 0.015 * yPercentage, -zDifference * 0.015 * zPercentage);
boolean explosionCreated = false;
if (new Pos(entity.posX, entity.posY, entity.posZ).distance(position) < (ENTITY_DESTROY_RADIUS * (getRadius() / NORMAL_RADIUS))) {
if (entity instanceof EntityExplosion) {
if (((EntityExplosion) entity).getBlast() instanceof BlastAntimatter) {
if (doAudio) {
this.world().playSoundEffect(position.x(), position.y(), position.z(), ICBMClassic.PREFIX + "explosion", 7.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
}
if (this.world().rand.nextFloat() > 0.85 && !this.world().isRemote) {
entity.setDead();
return explosionCreated;
}
} else if (((EntityExplosion) entity).getBlast() instanceof BlastRedmatter) {
//https://www.wolframalpha.com/input/?i=(4%2F3)pi+*+r%5E3+%3D+(4%2F3)pi+*+a%5E3+%2B+(4%2F3)pi+*+b%5E3
//We are going to merge both blasts together
double sizeA = this.getRadius();
sizeA = sizeA * sizeA * sizeA;
double sizeB = ((EntityExplosion) entity).getBlast().getRadius();
sizeB = sizeB * sizeB * sizeB;
float radiusNew = (float) Math.cbrt(sizeA + sizeB);
//Average out timer
this.callCount = (callCount + ((EntityExplosion) entity).getBlast().callCount) / 2;
//Destroy current instance
this.isAlive = false;
this.controller.setDead();
//Create new to avoid doing packet syncing
new BlastRedmatter(world(), entity, position.x(), position.y(), position.z(), radiusNew).explode();
}
//Kill explosion entity
((EntityExplosion) entity).getBlast().isAlive = false;
//Kill entity in the center of the ball
entity.setDead();
} else if (entity instanceof EntityExplosive) {
((EntityExplosive) entity).explode();
} else if (entity instanceof EntityLiving) {
((EntityLiving) entity).attackEntityFrom(DamageSource.outOfWorld, 99999999);
} else {
//Kill entity in the center of the ball
entity.setDead();
}
}
return explosionCreated;
}
use of icbm.classic.content.entity.EntityExplosion in project ICBM-Classic by BuiltBrokenModding.
the class BlastRedmatter method attackEntity.
private void attackEntity(Entity entity, double distance) {
// Handle eating logic
if (// TODO make config driven, break section out into its own method
distance < (ConfigBlast.REDMATTER.ENTITY_DESTROY_RADIUS * getScaleFactor())) {
if (entity instanceof EntityExplosion) {
final IBlast blast = ((EntityExplosion) entity).getBlast();
if (// TODO move to capability
blast instanceof BlastAntimatter) {
if (ConfigBlast.REDMATTER.ENABLE_AUDIO) {
ICBMSounds.EXPLOSION.play(world, location.x(), location.y(), location.z(), 7.0F, CalculationHelpers.randFloatRange(world().rand, -0.6F, 0.9F), true);
}
if (this.world().rand.nextFloat() > 0.85 && !this.world().isRemote) {
// Destroy self
clearBlast();
}
} else if (// TODO move to capability, also why isAlive checks?
blast instanceof BlastRedmatter && ((BlastRedmatter) blast).isAlive && this.isAlive) {
// https://www.wolframalpha.com/input/?i=(4%2F3)pi+*+r%5E3+%3D+(4%2F3)pi+*+a%5E3+%2B+(4%2F3)pi+*+b%5E3
// We are going to merge both blasts together
final double selfRad = Math.pow(this.getBlastRadius(), 3);
final double targetRad = Math.pow(((EntityExplosion) entity).getBlast().getBlastRadius(), 3);
// TODO why cube?
final float newRad = (float) Math.cbrt(selfRad + targetRad);
// Average out timer
this.callCount = (callCount + ((BlastRedmatter) blast).callCount) / 2;
this.size = newRad;
// TODO combine the vectors
this.controller.setVelocity(0, 0, 0);
// TODO fire an event when combined (non-cancelable to allow acting on combined result)
}
// Kill the blast
blast.clearBlast();
} else if (// TODO move to capability
entity instanceof EntityMissile) {
// TODO should trigger the explosive capability
((EntityMissile) entity).doExplosion();
} else if (// TODO move to capability
entity instanceof EntityExplosive) {
// TODO should trigger the explosive capability
((EntityExplosive) entity).explode();
} else if (entity instanceof EntityLiving || entity instanceof EntityPlayer) {
entity.attackEntityFrom(new DamageSourceRedmatter(this), 2000);
} else {
// Kill entity in the center of the ball
entity.setDead();
if (entity instanceof EntityFlyingBlock) {
if (this.size < 120) {
this.size += 0.05;
}
}
}
}
}
use of icbm.classic.content.entity.EntityExplosion in project ICBM-Classic by BuiltBrokenModding.
the class Blast method explode.
/** All outside classes should call this. */
@Override
public void explode() {
ExplosionConstructionEvent evt = new ExplosionConstructionEvent(this.world(), this);
MinecraftForge.EVENT_BUS.post(evt);
if (!evt.isCanceled()) {
if (this.proceduralInterval() > 0) {
if (!this.world().isRemote) {
this.world().spawnEntityInWorld(new EntityExplosion(this));
}
} else {
this.doPreExplode();
this.doExplode();
this.doPostExplode();
}
}
}
Aggregations