private void renderGlow(
      TileEntityChromaLamp te, double par2, double par4, double par6, float par8) {
    ElementTagCompound tag = te.getColors();
    Tessellator v5 = Tessellator.instance;
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    BlendMode.ADDITIVEDARK.apply();
    ReikaTextureHelper.bindTexture(ChromatiCraft.class, "Textures/clouds/bubble.png");
    int tick = te.getTicksExisted();
    double s = 0.3875;
    double h = 0.875;

    for (CrystalElement e : tag.elementSet()) {
      GL11.glPushMatrix();
      double ang = Math.toRadians(map[e.ordinal()]);
      double ang2 = e.ordinal() * 22.5;
      double vu = Math.cos(ang);
      double vv = Math.sin(ang);
      int alpha = Math.max(0, (int) (255 * Math.sin(Math.toRadians(ang2 + tick + par8))));
      double u = (vu * (tick) % 32) / 32D;
      double v = (vv * (tick) % 32) / 32D;
      double du = 1 + u;
      double dv = 1 + v;
      int color = ReikaColorAPI.mixColors(e.getColor(), 0, alpha / 255F);
      v5.startDrawingQuads();
      v5.setColorOpaque_I(color);
      v5.setBrightness(240);
      v5.addVertexWithUV(0.5 - s, h, 0.5 - s, u, dv);
      v5.addVertexWithUV(0.5 + s, h, 0.5 - s, du, dv);
      v5.addVertexWithUV(0.5 + s, 0, 0.5 - s, du, v);
      v5.addVertexWithUV(0.5 - s, 0, 0.5 - s, u, v);

      v5.addVertexWithUV(0.5 - s, 0, 0.5 + s, du, v);
      v5.addVertexWithUV(0.5 + s, 0, 0.5 + s, u, v);
      v5.addVertexWithUV(0.5 + s, h, 0.5 + s, u, dv);
      v5.addVertexWithUV(0.5 - s, h, 0.5 + s, du, dv);

      v5.addVertexWithUV(0.5 + s, h, 0.5 - s, u, dv);
      v5.addVertexWithUV(0.5 + s, h, 0.5 + s, du, dv);
      v5.addVertexWithUV(0.5 + s, 0, 0.5 + s, du, v);
      v5.addVertexWithUV(0.5 + s, 0, 0.5 - s, u, v);

      v5.addVertexWithUV(0.5 - s, 0, 0.5 - s, du, v);
      v5.addVertexWithUV(0.5 - s, 0, 0.5 + s, u, v);
      v5.addVertexWithUV(0.5 - s, h, 0.5 + s, u, dv);
      v5.addVertexWithUV(0.5 - s, h, 0.5 - s, du, dv);
      v5.draw();
      GL11.glPopMatrix();
    }
    BlendMode.DEFAULT.apply();
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
  }
 private void renderCrystal(int posX, int posY) {
   float mod = 2000F;
   int tick = (int) ((System.currentTimeMillis() / (double) mod) % 16);
   CrystalElement e1 = CrystalElement.elements[tick];
   CrystalElement e2 = CrystalElement.elements[(tick + 1) % 16];
   float mix = (float) (System.currentTimeMillis() % (double) mod) / mod;
   mix = Math.min(mix * 2, 1);
   int c1 = ((CrystalBlock) ChromaBlocks.CRYSTAL.getBlockInstance()).getTintColor(e1.ordinal());
   int c2 = ((CrystalBlock) ChromaBlocks.CRYSTAL.getBlockInstance()).getTintColor(e2.ordinal());
   int color = ReikaColorAPI.mixColors(c2, c1, mix);
   CrystalRenderer.staticColor = color;
   this.drawBlockRender(
       posX, posY, ChromaBlocks.CRYSTAL.getBlockInstance(), CrystalElement.WHITE.ordinal());
   CrystalRenderer.staticColor = -1;
 }
  @Override
  protected void writeSyncTag(NBTTagCompound NBT) {
    super.writeSyncTag(NBT);

    NBT.setInteger("color", color.ordinal());
    NBT.setBoolean("multi", hasMultiblock);
    NBT.setInteger("energy", energy);
    NBT.setBoolean("enhance", enhanced);
  }
 @Override
 public ImmutableTriple<Double, Double, Double> getTargetRenderOffset(CrystalElement e) {
   double ang = Math.toRadians(e.ordinal() * 22.5D);
   double r = 1.5;
   double dx = r * Math.sin(ang);
   double dy = 0.55;
   double dz = r * Math.cos(ang);
   return new ImmutableTriple(dx, dy, dz);
 }
 public void setColor(CrystalElement e) {
   if (worldObj.isRemote) return;
   color = e;
   BlockArray runes = this.getRuneLocations(worldObj, xCoord, yCoord, zCoord);
   for (int i = 0; i < runes.getSize(); i++) {
     Coordinate c = runes.getNthBlock(i);
     if (c.getBlock(worldObj) == ChromaBlocks.RUNE.getBlockInstance())
       worldObj.setBlockMetadataWithNotify(c.xCoord, c.yCoord, c.zCoord, color.ordinal(), 3);
   }
 }
  @Override
  public void writeEntityToNBT(NBTTagCompound nbt) {
    super.writeEntityToNBT(nbt);

    if (color != null) nbt.setInteger("color", color.ordinal());

    nbt.setBoolean("dodrops", doDrops);
    nbt.setBoolean("pylon", isPylonSpawn);

    nbt.setBoolean("isdead", isDead);
  }
Ejemplo n.º 7
0
 @Override
 protected int doTick(TileEntity te, FluidStack fs) {
   int dye = fs.tag != null ? fs.tag.getInteger("berries") : 0;
   CrystalElement e = dye > 0 ? CrystalElement.elements[fs.tag.getInteger("element")] : null;
   AxisAlignedBB box = ReikaAABBHelper.getBlockAABB(te.xCoord, te.yCoord, te.zCoord);
   List<EntityItem> li = te.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
   boolean flag = false;
   for (EntityItem ei : li) {
     ItemStack is = ei.getEntityItem();
     if (!te.worldObj.isRemote
         && rand.nextInt(5) == 0
         && dye < TileEntityChroma.BERRY_SATURATION
         && ChromaItems.BERRY.matchWith(is)
         && (e == null || is.getItemDamage() == e.ordinal())) {
       e = CrystalElement.elements[is.getItemDamage()];
       if (fs.tag == null) fs.tag = new NBTTagCompound();
       fs.tag.setInteger("element", e.ordinal());
       while (dye < TileEntityChroma.BERRY_SATURATION && is.stackSize > 0) {
         dye = fs.tag.getInteger("berries") + 1;
         fs.tag.setInteger("berries", dye);
         is.stackSize--;
       }
       if (is.stackSize <= 0) ei.setDead();
       flag = true;
     } else if (e != null
         && is.getItemDamage() == e.ordinal()
         && ChromaItems.SHARD.matchWith(is)
         && dye == TileEntityChroma.BERRY_SATURATION) {
       boolean done = false;
       for (int i = 0; i < ACCEL_FACTOR && !done; i++) {
         done = ItemCrystalShard.tickShardCharging(ei, e, te.xCoord, te.yCoord, te.zCoord);
       }
       if (!te.worldObj.isRemote && done) {
         fs.tag = null;
         return 200;
       }
     }
   }
   if (flag && e != null) fs.tag.setInteger("renderColor", BlockActiveChroma.getColor(e, dye));
   return 0;
 }
 @Override
 public void writeSpawnData(ByteBuf buf) {
   buf.writeInt(color != null ? color.ordinal() : -1);
 }