Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. @Override
  2. public int[] interpolateLight(IWorld world, int x, int y){
  3. IGameInstance game = RockBottomAPI.getGame();
  4.  
  5. if(game.isLightDebug()){
  6. return new int[]{Constants.MAX_LIGHT, Constants.MAX_LIGHT, Constants.MAX_LIGHT, Constants.MAX_LIGHT};
  7. }
  8. else if(!game.getSettings().smoothLighting){
  9. int light = world.getCombinedLight(x, y);
  10. return new int[]{light, light, light, light};
  11. }
  12. else{
  13. Direction[] dirs = Direction.SURROUNDING_INCLUDING_NONE;
  14. byte[] lightAround = new byte[dirs.length];
  15. for(int i = 0; i < dirs.length; i++){
  16. Direction dir = dirs[i];
  17. if(world.isPosLoaded(x+dir.x, y+dir.y)){
  18. lightAround[i] = world.getCombinedLight(x+dir.x, y+dir.y);
  19. }
  20. }
  21.  
  22. int[] light = new int[4];
  23. light[Image.TOP_LEFT] = (lightAround[0]+lightAround[8]+lightAround[1]+lightAround[2])/4;
  24. light[Image.TOP_RIGHT] = (lightAround[0]+lightAround[2]+lightAround[3]+lightAround[4])/4;
  25. light[Image.BOTTOM_RIGHT] = (lightAround[0]+lightAround[4]+lightAround[5]+lightAround[6])/4;
  26. light[Image.BOTTOM_LEFT] = (lightAround[0]+lightAround[6]+lightAround[7]+lightAround[8])/4;
  27. return light;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement