Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1.  
  2.     private int[] lastBlockLightValue;
  3.  
  4.     private void setCurrentBlockLightValues()
  5.     {
  6.         for(int lx = -1; lx <= 1; lx++)
  7.         {
  8.             for(int ly = -1; ly <= 1; ly++)
  9.             {
  10.                 for(int lz = -1; lz <= 1; lz++)
  11.                 {
  12.                     if(worldObj.getBlockId((int)posX + lx, (int)posY + ly, (int)posZ + lz) != 0) continue;
  13.                     int lux = 13;
  14.                     if(lx == 0 && ly == 0 && lz == 0)
  15.                     {
  16.                         lux = 15;
  17.                     }
  18.                     else if(lx == 0 || ly == 0 || lz == 0)
  19.                     {
  20.                         lux = 14;
  21.                     }
  22.                     worldObj.setLightValue(EnumSkyBlock.Block, (int)posX + lx, (int)posY + ly, (int)posZ + lz, lux);
  23.                 }
  24.             }
  25.         }
  26.     }
  27.  
  28.     private void restoreLastBlockLightValues()
  29.     {
  30.         for(int lx = -1; lx <= 1; lx++)
  31.         {
  32.             for(int ly = -1; ly <= 1; ly++)
  33.             {
  34.                 for(int lz = -1; lz <= 1; lz++)
  35.                 {
  36.                     if(worldObj.getBlockId((int)lastTickPosX + lx, (int)lastTickPosY + ly, (int)lastTickPosZ + lz) != 0) continue;
  37.                     worldObj.setLightValue(EnumSkyBlock.Block, (int)lastTickPosX + lx, (int)lastTickPosY + ly, (int)lastTickPosZ + lz, lastBlockLightValue[(lz+1)*9+(ly+1)*3+(lx+1)]);
  38.                 }
  39.             }
  40.         }
  41.     }
  42.  
  43.     private void storeCurrentBlockLightValues()
  44.     {
  45.         for(int lx = -1; lx <= 1; lx++)
  46.         {
  47.             for(int ly = -1; ly <= 1; ly++)
  48.             {
  49.                 for(int lz = -1; lz <= 1; lz++)
  50.                 {
  51.                     if(worldObj.getBlockId((int)posX + lx, (int)posY + ly, (int)posZ + lz) != 0) continue;
  52.                     lastBlockLightValue[(lz+1)*9+(ly+1)*3+(lx+1)] = worldObj.getBlockLightValue((int)posX + lx, (int)posY + ly, (int)posZ + lz);
  53.                 }
  54.             }
  55.         }
  56.     }
  57.  
  58.     public void setEntityDead()
  59.     {
  60.         isDead = true;
  61.         restoreLastBlockLightValues();
  62.     }
  63.  
  64. In the Entity's constructor:
  65.  
  66.        lastBlockLightValue = new int[27];
  67.        storeCurrentBlockLightValues();
  68.     setCurrentBlockLightValues();
  69.  
  70. In the Entity's onUpdate function:
  71.  
  72.         if((int)posX != (int)lastTickPosX || (int)posY != (int)lastTickPosY || (int)posZ != (int)lastTickPosZ)
  73.         {
  74.             restoreLastBlockLightValues();
  75.             storeCurrentBlockLightValues();
  76.             setCurrentBlockLightValues();
  77.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement