コード例 #1
0
 /** Update sky and emitted light */
 private final void updateLightLevel() {
   /* Look up transparency for current block */
   BlockTransparency bt = HDTextureMap.getTransparency(blocktypeid);
   if (bt == BlockTransparency.TRANSPARENT) {
     skylevel = mapiter.getBlockSkyLight();
     emitlevel = mapiter.getBlockEmittedLight();
   } else if (HDTextureMap.getTransparency(lastblocktypeid)
       != BlockTransparency.SEMITRANSPARENT) {
     mapiter.unstepPosition(laststep); /* Back up to block we entered on */
     if (mapiter.getY() < 128) {
       emitlevel = mapiter.getBlockEmittedLight();
       skylevel = mapiter.getBlockSkyLight();
     } else {
       emitlevel = 0;
       skylevel = 15;
     }
     mapiter.stepPosition(laststep);
   } else {
     mapiter.unstepPosition(laststep); /* Back up to block we entered on */
     if (mapiter.getY() < 128) {
       mapiter.stepPosition(BlockStep.Y_PLUS); /* Look above */
       emitlevel = mapiter.getBlockEmittedLight();
       skylevel = mapiter.getBlockSkyLight();
       mapiter.stepPosition(BlockStep.Y_MINUS);
     } else {
       emitlevel = 0;
       skylevel = 15;
     }
     mapiter.stepPosition(laststep);
   }
 }
コード例 #2
0
    /**
     * Generate chest block to drive model selection: 0 = single facing west 1 = single facing south
     * 2 = single facing east 3 = single facing north 4 = left side facing west 5 = left side facing
     * south 6 = left side facing east 7 = left side facing north 8 = right side facing west 9 =
     * right side facing south 10 = right side facing east 11 = right side facing north
     *
     * @param mapiter
     * @return
     */
    private int generateChestBlockData(MapIterator mapiter) {
      ChestData cd = ChestData.SINGLE_WEST; /* Default to single facing west */
      /* Check adjacent block IDs */
      int ids[] = {
        mapiter.getBlockTypeIDAt(BlockStep.Z_PLUS), /* To west */
        mapiter.getBlockTypeIDAt(BlockStep.X_PLUS), /* To south */
        mapiter.getBlockTypeIDAt(BlockStep.Z_MINUS), /* To east */
        mapiter.getBlockTypeIDAt(BlockStep.X_MINUS)
      }; /* To north */
      /* First, check if we're a double - see if any adjacent chests */
      if (ids[0] == CHEST_BLKTYPEID) {
          /* Another to west - assume we face south */
        cd = ChestData.RIGHT_SOUTH; /* We're right side */
      } else if (ids[1] == CHEST_BLKTYPEID) {
          /* Another to south - assume west facing */
        cd = ChestData.LEFT_WEST; /* We're left side */
      } else if (ids[2] == CHEST_BLKTYPEID) {
          /* Another to east - assume south facing */
        cd = ChestData.LEFT_SOUTH; /* We're left side */
      } else if (ids[3] == CHEST_BLKTYPEID) {
          /* Another to north - assume west facing */
        cd = ChestData.RIGHT_WEST; /* We're right side */
      } else {
          /* Else, single - build index into lookup table */
        int idx = 0;
        for (int i = 0; i < ids.length; i++) {
          if ((ids[i] != 0)
              && (HDTextureMap.getTransparency(ids[i]) != BlockTransparency.TRANSPARENT)) {
            idx |= (1 << i);
          }
        }
        cd = SINGLE_LOOKUP[idx];
      }

      return cd.ordinal();
    }