示例#1
0
  @Override
  public boolean renderWorldBlock(
      IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {

    IIcon soulariumIcon = EnderIO.blockSoulFuser.getIcon(ForgeDirection.EAST.ordinal(), 0);
    override = renderer.overrideBlockTexture;

    // Horrible hack to get the MC lighting engine to set the correct values for me
    if (renderer != null && world != null) {
      renderer.setOverrideBlockTexture(IconUtil.blankTexture);
      renderer.renderStandardBlock(Blocks.stone, x, y, z);
      renderer.setOverrideBlockTexture(null);
    }
    BoundingBox bb;

    Tessellator.instance.addTranslation(x, y, z);

    bb = BoundingBox.UNIT_CUBE.scale(0.85, 0.85, 0.85);
    setIcons(soulariumIcon, soulariumIcon, ForgeDirection.NORTH);
    CubeRenderer.render(bb, icons, true);

    float slabWidth = 0.15f;
    bb = BoundingBox.UNIT_CUBE.scale(1, slabWidth, 1);
    bb = bb.translate(0, 0.5f - (slabWidth / 2), 0);
    setIcons(
        soulariumIcon,
        EnderIO.blockSoulFuser.getIcon(ForgeDirection.UP.ordinal(), 0),
        ForgeDirection.UP);
    CubeRenderer.render(bb, icons, true);

    bb = BoundingBox.UNIT_CUBE.scale(1, slabWidth, 1);
    bb = bb.translate(0, -0.5f + (slabWidth / 2), 0);
    setIcons(soulariumIcon, soulariumIcon, ForgeDirection.NORTH);

    CubeRenderer.render(bb, icons, true);

    IIcon endermanIcon;
    int facing = ForgeDirection.SOUTH.ordinal();

    if (world == null || !(world.getTileEntity(x, y, z) instanceof TileSoulBinder)) {
      endermanIcon = EnderIO.blockSoulFuser.endermanSkullIcon;
    } else {
      TileSoulBinder sb = (TileSoulBinder) world.getTileEntity(x, y, z);
      facing = sb.facing;
      endermanIcon =
          sb.isActive()
              ? EnderIO.blockSoulFuser.endermanSkullIconOn
              : EnderIO.blockSoulFuser.endermanSkullIcon;
    }

    renderSkull(forFacing(ForgeDirection.SOUTH, facing), soulariumIcon, endermanIcon);
    renderSkull(
        forFacing(ForgeDirection.WEST, facing),
        soulariumIcon,
        EnderIO.blockSoulFuser.skeletonSkullIcon);
    renderSkull(
        forFacing(ForgeDirection.NORTH, facing),
        soulariumIcon,
        EnderIO.blockSoulFuser.zombieSkullIcon);
    renderSkull(
        forFacing(ForgeDirection.EAST, facing),
        soulariumIcon,
        EnderIO.blockSoulFuser.creeperSkullIcon);

    Tessellator.instance.addTranslation(-x, -y, -z);

    return true;
  }
示例#2
0
  private void addConnectors(List<CollidableComponent> result) {

    if (conduits.isEmpty()) {
      return;
    }

    for (IConduit con : conduits) {
      boolean b = con.haveCollidablesChangedSinceLastCall();
      collidablesDirty = collidablesDirty || b;
      connectorsDirty = connectorsDirty || b;
    }

    if (!connectorsDirty && !cachedConnectors.isEmpty()) {
      result.addAll(cachedConnectors);
      return;
    }

    cachedConnectors.clear();

    // TODO: What an unholly mess!
    List<CollidableComponent> coreBounds = new ArrayList<CollidableComponent>();
    for (IConduit con : conduits) {
      addConduitCores(coreBounds, con);
    }
    cachedConnectors.addAll(coreBounds);
    result.addAll(coreBounds);

    // 1st algorithm
    List<CollidableComponent> conduitsBounds = new ArrayList<CollidableComponent>();
    for (IConduit con : conduits) {
      conduitsBounds.addAll(con.getCollidableComponents());
      addConduitCores(conduitsBounds, con);
    }

    Set<Class<IConduit>> collidingTypes = new HashSet<Class<IConduit>>();
    for (CollidableComponent conCC : conduitsBounds) {
      for (CollidableComponent innerCC : conduitsBounds) {
        if (!InsulatedRedstoneConduit.COLOR_CONTROLLER_ID.equals(innerCC.data)
            && !InsulatedRedstoneConduit.COLOR_CONTROLLER_ID.equals(conCC.data)
            && conCC != innerCC
            && conCC.bound.intersects(innerCC.bound)) {
          collidingTypes.add((Class<IConduit>) conCC.conduitType);
        }
      }
    }

    // TODO: Remove the core geometries covered up by this as no point in rendering these
    if (!collidingTypes.isEmpty()) {
      List<CollidableComponent> colCores = new ArrayList<CollidableComponent>();
      for (Class<IConduit> c : collidingTypes) {
        IConduit con = getConduit(c);
        if (con != null) {
          addConduitCores(colCores, con);
        }
      }

      BoundingBox bb = null;
      for (CollidableComponent cBB : colCores) {
        if (bb == null) {
          bb = cBB.bound;
        } else {
          bb = bb.expandBy(cBB.bound);
        }
      }
      if (bb != null) {
        bb = bb.scale(1.05, 1.05, 1.05);
        CollidableComponent cc =
            new CollidableComponent(
                null, bb, ForgeDirection.UNKNOWN, ConduitConnectorType.INTERNAL);
        result.add(cc);
        cachedConnectors.add(cc);
      }
    }

    // 2nd algorithm
    for (IConduit con : conduits) {

      if (con.hasConnections()) {
        List<CollidableComponent> cores = new ArrayList<CollidableComponent>();
        addConduitCores(cores, con);
        if (cores.size() > 1) {
          BoundingBox bb = cores.get(0).bound;
          float area = bb.getArea();
          for (CollidableComponent cc : cores) {
            bb = bb.expandBy(cc.bound);
          }
          if (bb.getArea() > area * 1.5f) {
            bb = bb.scale(1.05, 1.05, 1.05);
            CollidableComponent cc =
                new CollidableComponent(
                    null, bb, ForgeDirection.UNKNOWN, ConduitConnectorType.INTERNAL);
            result.add(cc);
            cachedConnectors.add(cc);
          }
        }
      }
    }

    // Merge all internal conduit connectors into one box
    BoundingBox conBB = null;
    for (int i = 0; i < result.size(); i++) {
      CollidableComponent cc = result.get(i);
      if (cc.conduitType == null && cc.data == ConduitConnectorType.INTERNAL) {
        conBB = conBB == null ? cc.bound : conBB.expandBy(cc.bound);
        result.remove(i);
        i--;
        cachedConnectors.remove(cc);
      }
    }

    if (conBB != null) {
      CollidableComponent cc =
          new CollidableComponent(
              null, conBB, ForgeDirection.UNKNOWN, ConduitConnectorType.INTERNAL);
      result.add(cc);
      cachedConnectors.add(cc);
    }

    // External Connectors
    EnumSet<ForgeDirection> externalDirs = EnumSet.noneOf(ForgeDirection.class);
    for (IConduit con : conduits) {
      Set<ForgeDirection> extCons = con.getExternalConnections();
      if (extCons != null) {
        for (ForgeDirection dir : extCons) {
          if (con.getConnectionMode(dir) != ConnectionMode.DISABLED) {
            externalDirs.add(dir);
          }
        }
      }
    }
    for (ForgeDirection dir : externalDirs) {
      BoundingBox bb = ConduitGeometryUtil.instance.getExternalConnectorBoundingBox(dir);
      CollidableComponent cc =
          new CollidableComponent(null, bb, dir, ConduitConnectorType.EXTERNAL);
      result.add(cc);
      cachedConnectors.add(cc);
    }

    connectorsDirty = false;
  }
示例#3
0
 private void renderSkull(ForgeDirection face, IIcon soulariumIcon, IIcon faceIcon) {
   BoundingBox bb;
   bb = scaledBB.translate(ForgeDirectionOffsets.offsetScaled(face, 0.5 - skullScale / 2));
   setIcons(soulariumIcon, faceIcon, face);
   CubeRenderer.render(bb, icons, true);
 }