use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class MissileHoming method launch.
@Override
public void launch(EntityMissile missileObj) {
if (!missileObj.worldObj.isRemote) {
WorldServer worldServer = (WorldServer) missileObj.worldObj;
Entity trackingEntity = worldServer.getEntityByID(missileObj.trackingVar);
if (trackingEntity != null) {
if (trackingEntity == missileObj) {
missileObj.setExplode();
}
missileObj.targetVector = new Pos(trackingEntity);
}
}
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class MissileNuclearCluster 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 clusterMissile = new EntityMissile(missileObj.worldObj);
//TODO randomize spread to prevent collisions
clusterMissile.setPosition(position.x(), position.y(), position.z());
clusterMissile.explosiveID = Explosives.NUCLEAR;
missileObj.worldObj.spawnEntityInWorld(clusterMissile);
clusterMissile.missileType = MissileType.CruiseMissile;
clusterMissile.protectionTime = 20;
clusterMissile.launch(missileObj.targetVector.add(new Pos((missileObj.missileCount - MAX_CLUSTER / 2) * random() * 30, (missileObj.missileCount - MAX_CLUSTER / 2) * random() * 30, (missileObj.missileCount - MAX_CLUSTER / 2) * random() * 30)));
}
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 ICBMClassic method init.
@EventHandler
public void init(FMLInitializationEvent event) {
super.init(event);
Settings.setModMetadata(ICBMClassic.DOMAIN, "ICBM-Classic", metadata);
OreDictionary.registerOre("dustSulfur", new ItemStack(itemSulfurDust, 1, 0));
OreDictionary.registerOre("dustSaltpeter", new ItemStack(itemSulfurDust, 1, 1));
/** Check for existence of radioactive block. If it does not exist, then create it. */
if (OreDictionary.getOres("blockRadioactive").size() > 0) {
ArrayList<ItemStack> stacks = OreDictionary.getOres("blockRadioactive");
for (ItemStack stack : stacks) {
if (stack != null && stack.getItem() instanceof ItemBlock) {
//TODO add code to handle this from the ItemStack or test if this block is valid
// As assuming the metadata is valid may not be a good idea, and the block may not be valid as well
//TODO add config to force block that is used
//TODO add error checking
blockRadioactive = ((ItemBlock) stack.getItem()).field_150939_a;
blockRadioactiveMeta = ((ItemBlock) stack.getItem()).getMetadata(stack.getItemDamage());
logger().info("Detected radioative block from another mod.");
logger().info("Radioactive explosives will use: " + blockRadioactive);
}
}
}
if (blockRadioactive == null) {
blockRadioactive = Blocks.mycelium;
}
/** Potion Effects */
PoisonToxin.INSTANCE = new PoisonToxin(true, 5149489, "toxin");
PoisonContagion.INSTANCE = new PoisonContagion(false, 5149489, "virus");
PoisonFrostBite.INSTANCE = new PoisonFrostBite(false, 5149489, "frostBite");
/** Dispenser Handler */
BlockDispenser.dispenseBehaviorRegistry.putObject(itemGrenade, new IBehaviorDispenseItem() {
@Override
public ItemStack dispense(IBlockSource blockSource, ItemStack itemStack) {
World world = blockSource.getWorld();
if (!world.isRemote) {
int x = blockSource.getXInt();
int y = blockSource.getYInt();
int z = blockSource.getZInt();
EnumFacing enumFacing = EnumFacing.getFront(blockSource.getBlockMetadata());
EntityGrenade entity = new EntityGrenade(world, new Pos(x, y, z), Explosives.get(itemStack.getItemDamage()));
entity.setThrowableHeading(enumFacing.getFrontOffsetX(), 0.10000000149011612D, enumFacing.getFrontOffsetZ(), 0.5F, 1.0F);
world.spawnEntityInWorld(entity);
}
itemStack.stackSize--;
return itemStack;
}
});
BlockDispenser.dispenseBehaviorRegistry.putObject(itemBombCart, new IBehaviorDispenseItem() {
private final BehaviorDefaultDispenseItem defaultItemDispenseBehavior = new BehaviorDefaultDispenseItem();
@Override
public ItemStack dispense(IBlockSource blockSource, ItemStack itemStack) {
World world = blockSource.getWorld();
if (!world.isRemote) {
int x = blockSource.getXInt();
int y = blockSource.getYInt();
int z = blockSource.getZInt();
EnumFacing var3 = EnumFacing.getFront(blockSource.getBlockMetadata());
World var4 = blockSource.getWorld();
double var5 = blockSource.getX() + var3.getFrontOffsetX() * 1.125F;
double var7 = blockSource.getY();
double var9 = blockSource.getZ() + var3.getFrontOffsetZ() * 1.125F;
int var11 = blockSource.getXInt() + var3.getFrontOffsetX();
int var12 = blockSource.getYInt();
int var13 = blockSource.getZInt() + var3.getFrontOffsetZ();
Block var14 = var4.getBlock(var11, var12, var13);
double var15;
if (BlockRailBase.func_150051_a(var14)) {
var15 = 0.0D;
} else {
if (var14 == Blocks.air || !BlockRailBase.func_150051_a(var4.getBlock(var11, var12 - 1, var13))) {
return this.defaultItemDispenseBehavior.dispense(blockSource, itemStack);
}
var15 = -1.0D;
}
EntityBombCart var22 = new EntityBombCart(world, var5, var7 + var15, var9, Explosives.get(itemStack.getItemDamage()));
world.spawnEntityInWorld(var22);
world.playAuxSFX(1000, x, y, z, 0);
}
itemStack.stackSize--;
return itemStack;
}
});
proxy.init();
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class RenderEntityBlock method doRenderGravityBlock.
/** The actual render method that is used in doRender */
public void doRenderGravityBlock(EntityFlyingBlock entity, double x, double y, double z, float par8, float par9) {
Block block = entity.block;
if (block == null || block.getMaterial() == Material.air) {
block = Blocks.stone;
}
GL11.glPushMatrix();
try {
GL11.glTranslatef((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f);
RenderUtility.setTerrainTexture();
EulerAngle rotation = new EulerAngle(entity.rotationYaw, entity.rotationPitch);
Pos translation = rotation.toPos();
GL11.glTranslated(translation.x(), translation.y(), translation.z());
//GL11.glDisable(GL11.GL_LIGHTING);
GL11.glRotatef(entity.rotationPitch, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(entity.rotationYaw, 0.0F, 1.0F, 0.0F);
if (block.getRenderType() != 0) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
try {
tessellator.setTranslation((-MathHelper.floor_double(entity.posX)) - 0.5F, (-MathHelper.floor_double(entity.posY)) - 0.5F, (-MathHelper.floor_double(entity.posZ)) - 0.5F);
RenderUtility.getBlockRenderer().renderBlockByRenderType(block, MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ));
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
} catch (Exception e) {
ICBMClassic.INSTANCE.logger().error("Unexpected error while rendering EntityBlock[" + entity + "] with data [" + block + ":" + entity.metadata + "] forcing to render as stone to prevent additional errors.", e);
entity.block = Blocks.stone;
//Hacky way of clearing current draw state
tessellator.isDrawing = false;
tessellator.startDrawingQuads();
tessellator.isDrawing = false;
}
} else {
RenderUtility.renderCube(0, 0, 0, 1, 1, 1, block, null, entity.metadata);
}
//GL11.glEnable(GL11.GL_LIGHTING);
} catch (Exception e) {
ICBMClassic.INSTANCE.logger().error("Unexpected error while rendering EntityBlock[" + entity + "] with data [" + block + ":" + entity.metadata + "]", e);
}
GL11.glPopMatrix();
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.
the class ClientProxy method spawnParticle.
@Override
public void spawnParticle(String name, World world, IPos3D position, double motionX, double motionY, double motionZ, float red, float green, float blue, float scale, double distance) {
EntityFX fx = null;
if (name.equals("smoke")) {
fx = new FXSmoke(world, new Pos(position), red, green, blue, scale, distance);
} else if (name.equals("missile_smoke")) {
fx = (new FXSmoke(world, new Pos(position), red, green, blue, scale, distance)).setAge(100);
} else if (name.equals("portal")) {
fx = new FXEnderPortalPartical(world, new Pos(position), red, green, blue, scale, distance);
} else if (name.equals("antimatter")) {
fx = new FXAntimatterPartical(world, new Pos(position), red, green, blue, scale, distance);
} else if (name.equals("digging")) {
fx = new EntityDiggingFX(world, position.x(), position.y(), position.z(), motionX, motionY, motionZ, Block.getBlockById((int) red), 0, (int) green);
fx.multipleParticleScaleBy(blue);
} else if (name.equals("shockwave")) {
//fx = new FXShockWave(world, new Pos(position), red, green, blue, scale, distance);
}
if (fx != null) {
fx.motionX = motionX;
fx.motionY = motionY;
fx.motionZ = motionZ;
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
}
Aggregations