use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class BlockExplosive method onBlockPlacedBy.
/** Called when the block is placed in the world. */
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityExplosive) {
Explosives ex = Explosives.get(itemStack.getItemDamage());
((TileEntityExplosive) tile).explosive = ex;
if (!world.isRemote) {
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, x, y, z, ExplosiveType.BLOCK, ex.handler);
MinecraftForge.EVENT_BUS.post(evt);
if (evt.isCanceled()) {
this.dropBlockAsItem(world, x, y, z, ex.ordinal(), 0);
world.setBlock(x, y, z, Blocks.air, 0, 2);
return;
}
}
world.setBlockMetadataWithNotify(x, y, z, VectorHelper.getOrientationFromSide(ForgeDirection.getOrientation(determineOrientation(world, x, y, z, entityLiving)), ForgeDirection.NORTH).ordinal(), 2);
if (world.isBlockIndirectlyGettingPowered(x, y, z)) {
BlockExplosive.triggerExplosive(world, x, y, z, ex, 0);
}
// If so, then detonate.
for (byte i = 0; i < 6; i++) {
Pos position = new Pos(x, y, z).add(ForgeDirection.getOrientation(i));
Block blockId = position.getBlock(world);
if (blockId == Blocks.fire || blockId == Blocks.flowing_lava || blockId == Blocks.lava) {
BlockExplosive.triggerExplosive(world, x, y, z, ex, 2);
break;
}
}
if (entityLiving != null) {
FMLLog.fine(entityLiving.getCommandSenderName() + " placed " + ex.handler.getExplosiveName() + " in: " + x + ", " + y + ", " + z + ".");
}
}
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class BlockExplosive method triggerExplosive.
/*
* Called to detonate the TNT. Args: world, x, y, z, metaData, CauseOfExplosion (0, intentional,
* 1, exploded, 2 burned)
*/
public static void triggerExplosive(World world, int x, int y, int z, Explosives explosiveID, int causeOfExplosion) {
if (!world.isRemote) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
if (tileEntity instanceof TileEntityExplosive) {
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, x, y, z, ExplosiveType.BLOCK, ((TileEntityExplosive) tileEntity).explosive.handler);
MinecraftForge.EVENT_BUS.post(evt);
if (!evt.isCanceled()) {
((TileEntityExplosive) tileEntity).exploding = true;
EntityExplosive eZhaDan = new EntityExplosive(world, new Pos(x, y, z).add(0.5), ((TileEntityExplosive) tileEntity).explosive, (byte) world.getBlockMetadata(x, y, z), ((TileEntityExplosive) tileEntity).nbtData);
switch(causeOfExplosion) {
case 2:
eZhaDan.setFire(100);
break;
}
world.spawnEntityInWorld(eZhaDan);
world.setBlockToAir(x, y, z);
}
}
}
}
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class ExEnder method doCreateExplosion.
@SuppressWarnings("deprecation")
@Override
public void doCreateExplosion(World world, double x, double y, double z, Entity entity) {
Pos teleportTarget = null;
if (entity instanceof IExplosiveContainer) {
if (((IExplosiveContainer) entity).getTagCompound().hasKey("x") && ((IExplosiveContainer) entity).getTagCompound().hasKey("y") && ((IExplosiveContainer) entity).getTagCompound().hasKey("z")) {
teleportTarget = new Pos(((IExplosiveContainer) entity).getTagCompound());
}
}
new BlastEnderman(world, entity, x, y, z, 30, teleportTarget).explode();
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class MissileCluster method update.
@Override
public void update(EntityMissile missileObj) {
if (missileObj.motionY < -0.5) {
if (missileObj.missileCount < MAX_CLUSTER) {
if (!missileObj.worldObj.isRemote) {
Pos position = missileObj.toPos();
EntityMissile missile = new EntityMissile(missileObj.worldObj);
//TODO spread to avoid collision
missile.setPosition(position.x(), position.y(), position.z());
missile.launcherPos = position;
missile.explosiveID = Explosives.CONDENSED;
double radius = spread;
double theta = 0;
double x = 0;
double y = 0;
double z = 0;
if (missileObj.missileCount > 0) {
theta = (missileObj.missileCount / 12.0) * Math.PI * 2;
x = radius * Math.cos(theta);
missile.posX += Math.cos(theta) * 5;
z = radius * Math.sin(theta);
missile.posZ += Math.sin(theta) * 5;
}
missile.missileType = MissileType.CruiseMissile;
missile.protectionTime = 20 + missileObj.targetHeight - 1;
missile.launch(missileObj.targetVector.add(new Pos(x, y, z)));
missileObj.worldObj.spawnEntityInWorld(missile);
}
missileObj.protectionTime = 20;
missileObj.missileCount++;
} else {
missileObj.setDead();
}
}
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class MissileHoming method onInteract.
@Override
public boolean onInteract(EntityMissile missileObj, EntityPlayer entityPlayer) {
if (!missileObj.worldObj.isRemote && missileObj.getTicksInAir() <= 0) {
if (entityPlayer.getCurrentEquippedItem() != null) {
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemTracker) {
Entity trackingEntity = ((ItemTracker) entityPlayer.getCurrentEquippedItem().getItem()).getTrackingEntity(missileObj.worldObj, entityPlayer.getCurrentEquippedItem());
if (trackingEntity != null) {
if (missileObj.trackingVar != trackingEntity.getEntityId()) {
missileObj.trackingVar = trackingEntity.getEntityId();
entityPlayer.addChatMessage(new ChatComponentText("Missile target locked to: " + trackingEntity.getCommandSenderName()));
if (missileObj.getLauncher() != null && missileObj.getLauncher().getController() != null) {
Pos newTarget = new Pos(trackingEntity.posX, 0, trackingEntity.posZ);
missileObj.getLauncher().getController().setTarget(newTarget);
}
return true;
}
}
}
}
}
return false;
}
Aggregations