示例#1
0
  @Override
  @Method(modid = "appliedenergistics2")
  public boolean canConnectToExternal(ForgeDirection dir, boolean ignoreDisabled) {
    World world = getBundle().getWorld();
    BlockCoord pos = getLocation();
    TileEntity te =
        world.getTileEntity(pos.x + dir.offsetX, pos.y + dir.offsetY, pos.z + dir.offsetZ);

    if (te instanceof TileConduitBundle) {
      return false;
    }

    // because the AE2 API doesn't allow an easy query like "which side can connect to an ME cable"
    // it needs this mess
    if (te instanceof IPartHost) {
      IPart part = ((IPartHost) te).getPart(dir.getOpposite());
      if (part == null) {
        part = ((IPartHost) te).getPart(ForgeDirection.UNKNOWN);
        return part != null;
      }
      if (part.getExternalFacingNode() != null) {
        return true;
      }
      String name = part.getClass().getSimpleName();
      return "PartP2PTunnelME".equals(name)
          || "PartQuartzFiber".endsWith(name)
          || "PartToggleBus".equals(name)
          || "PartInvertedToggleBus".equals(name);
    } else if (te instanceof IGridHost) {
      IGridNode node = ((IGridHost) te).getGridNode(dir.getOpposite());
      if (node == null) {
        node = ((IGridHost) te).getGridNode(ForgeDirection.UNKNOWN);
      }
      if (node != null) {
        return node.getGridBlock().getConnectableSides().contains(dir.getOpposite());
      }
    }
    return false;
  }
  @Override
  public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    if (item == null) {
      return;
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_LIGHTING);

    if (AEConfig.instance.isFeatureEnabled(AEFeature.AlphaPass)
        && item.getItem() instanceof IAlphaPassItem
        && ((IAlphaPassItem) item.getItem()).useAlphaPass(item)) {
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
      GL11.glDisable(GL11.GL_ALPHA_TEST);
      GL11.glEnable(GL11.GL_BLEND);
    } else {
      GL11.glAlphaFunc(GL11.GL_GREATER, 0.4f);
      GL11.glEnable(GL11.GL_ALPHA_TEST);
      GL11.glDisable(GL11.GL_BLEND);
    }

    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
      GL11.glTranslatef(-0.2f, -0.1f, -0.3f);
    }

    if (type == ItemRenderType.ENTITY) {
      GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
      GL11.glScalef(0.8f, 0.8f, 0.8f);
      GL11.glTranslatef(-0.8f, -0.87f, -0.7f);
    }

    if (type == ItemRenderType.INVENTORY) {
      GL11.glTranslatef(0.0f, -0.1f, 0.0f);
    }

    GL11.glTranslated(0.2, 0.3, 0.1);
    GL11.glScaled(1.2, 1.2, 1.);

    GL11.glColor4f(1, 1, 1, 1);
    Tessellator.instance.setColorOpaque_F(1, 1, 1);
    Tessellator.instance.setBrightness(14 << 20 | 14 << 4);

    BusRenderHelper.INSTANCE.setBounds(0, 0, 0, 1, 1, 1);
    BusRenderHelper.INSTANCE.setTexture(null);
    BusRenderHelper.INSTANCE.setInvColor(0xffffff);
    this.getRenderer().blockAccess = ClientHelper.proxy.getWorld();

    BusRenderHelper.INSTANCE.setOrientation(
        ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH);

    this.getRenderer().uvRotateBottom =
        this.getRenderer().uvRotateEast =
            this.getRenderer().uvRotateNorth =
                this.getRenderer().uvRotateSouth =
                    this.getRenderer().uvRotateTop = this.getRenderer().uvRotateWest = 0;
    this.getRenderer().useInventoryTint = false;
    this.getRenderer().overrideBlockTexture = null;

    if (item.getItem() instanceof IFacadeItem) {
      final IFacadeItem fi = (IFacadeItem) item.getItem();
      final IFacadePart fp = fi.createPartFromItemStack(item, ForgeDirection.SOUTH);

      if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        GL11.glRotatef(160.0f, 0.0f, 1.0f, 0.0f);
        GL11.glTranslated(-0.4, 0.1, -1.6);
      }

      if (fp != null) {
        fp.renderInventory(BusRenderHelper.INSTANCE, this.getRenderer());
      }
    } else {
      final IPart ip = this.getRenderer(item, (IPartItem) item.getItem());

      if (ip != null) {
        if (type == ItemRenderType.ENTITY) {
          final int depth = ip.cableConnectionRenderTo();
          GL11.glTranslatef(0.0f, 0.0f, -0.04f * (8 - depth) - 0.06f);
        }

        ip.renderInventory(BusRenderHelper.INSTANCE, this.getRenderer());
      }
    }

    this.getRenderer().uvRotateBottom =
        this.getRenderer().uvRotateEast =
            this.getRenderer().uvRotateNorth =
                this.getRenderer().uvRotateSouth =
                    this.getRenderer().uvRotateTop = this.getRenderer().uvRotateWest = 0;

    GL11.glPopAttrib();
    GL11.glPopMatrix();
  }