MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / ChunkCacheOF

Class ChunkCacheOF

src/main/java/net/optifine/override/ChunkCacheOF.java:17–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15import net.optifine.util.ArrayCache;
16
17public class ChunkCacheOF implements IBlockAccess
18{
19 private final ChunkCache chunkCache;
20 private final int posX;
21 private final int posY;
22 private final int posZ;
23 private final int sizeX;
24 private final int sizeY;
25 private final int sizeZ;
26 private final int sizeXY;
27 private int[] combinedLights;
28 private IBlockState[] blockStates;
29 private final int arraySize;
30 private final boolean dynamicLights = Config.isDynamicLights();
31 private static final ArrayCache cacheCombinedLights = new ArrayCache(Integer.TYPE, 16);
32 private static final ArrayCache cacheBlockStates = new ArrayCache(IBlockState.class, 16);
33
34 public ChunkCacheOF(ChunkCache chunkCache, BlockPos posFromIn, BlockPos posToIn, int subIn)
35 {
36 this.chunkCache = chunkCache;
37 int i = posFromIn.getX() - subIn >> 4;
38 int j = posFromIn.getY() - subIn >> 4;
39 int k = posFromIn.getZ() - subIn >> 4;
40 int l = posToIn.getX() + subIn >> 4;
41 int i1 = posToIn.getY() + subIn >> 4;
42 int j1 = posToIn.getZ() + subIn >> 4;
43 this.sizeX = l - i + 1 << 4;
44 this.sizeY = i1 - j + 1 << 4;
45 this.sizeZ = j1 - k + 1 << 4;
46 this.sizeXY = this.sizeX * this.sizeY;
47 this.arraySize = this.sizeX * this.sizeY * this.sizeZ;
48 this.posX = i << 4;
49 this.posY = j << 4;
50 this.posZ = k << 4;
51 }
52
53 private int getPositionIndex(BlockPos pos)
54 {
55 int i = pos.getX() - this.posX;
56
57 if (i >= 0 && i < this.sizeX)
58 {
59 int j = pos.getY() - this.posY;
60
61 if (j >= 0 && j < this.sizeY)
62 {
63 int k = pos.getZ() - this.posZ;
64 return k >= 0 && k < this.sizeZ ? k * this.sizeXY + j * this.sizeX + i : -1;
65 }
66 else
67 {
68 return -1;
69 }
70 }
71 else
72 {
73 return -1;
74 }

Callers

nothing calls this directly

Calls 1

isDynamicLightsMethod · 0.95

Tested by

no test coverage detected