Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int[] lastBlockLightValue;
- private void setCurrentBlockLightValues()
- {
- for(int lx = -1; lx <= 1; lx++)
- {
- for(int ly = -1; ly <= 1; ly++)
- {
- for(int lz = -1; lz <= 1; lz++)
- {
- if(worldObj.getBlockId((int)posX + lx, (int)posY + ly, (int)posZ + lz) != 0) continue;
- int lux = 13;
- if(lx == 0 && ly == 0 && lz == 0)
- {
- lux = 15;
- }
- else if(lx == 0 || ly == 0 || lz == 0)
- {
- lux = 14;
- }
- worldObj.setLightValue(EnumSkyBlock.Block, (int)posX + lx, (int)posY + ly, (int)posZ + lz, lux);
- }
- }
- }
- }
- private void restoreLastBlockLightValues()
- {
- for(int lx = -1; lx <= 1; lx++)
- {
- for(int ly = -1; ly <= 1; ly++)
- {
- for(int lz = -1; lz <= 1; lz++)
- {
- if(worldObj.getBlockId((int)lastTickPosX + lx, (int)lastTickPosY + ly, (int)lastTickPosZ + lz) != 0) continue;
- worldObj.setLightValue(EnumSkyBlock.Block, (int)lastTickPosX + lx, (int)lastTickPosY + ly, (int)lastTickPosZ + lz, lastBlockLightValue[(lz+1)*9+(ly+1)*3+(lx+1)]);
- }
- }
- }
- }
- private void storeCurrentBlockLightValues()
- {
- for(int lx = -1; lx <= 1; lx++)
- {
- for(int ly = -1; ly <= 1; ly++)
- {
- for(int lz = -1; lz <= 1; lz++)
- {
- if(worldObj.getBlockId((int)posX + lx, (int)posY + ly, (int)posZ + lz) != 0) continue;
- lastBlockLightValue[(lz+1)*9+(ly+1)*3+(lx+1)] = worldObj.getBlockLightValue((int)posX + lx, (int)posY + ly, (int)posZ + lz);
- }
- }
- }
- }
- public void setEntityDead()
- {
- isDead = true;
- restoreLastBlockLightValues();
- }
- In the Entity's constructor:
- lastBlockLightValue = new int[27];
- storeCurrentBlockLightValues();
- setCurrentBlockLightValues();
- In the Entity's onUpdate function:
- if((int)posX != (int)lastTickPosX || (int)posY != (int)lastTickPosY || (int)posZ != (int)lastTickPosZ)
- {
- restoreLastBlockLightValues();
- storeCurrentBlockLightValues();
- setCurrentBlockLightValues();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement