public void optimize() { if (sectionPalettes != null) { return; } char[][] arrays = getCombinedIdArrays(); char lastChar = Character.MAX_VALUE; for (int layer = 0; layer < 16; layer++) { if (getCount(layer) > 0) { if (sectionPalettes == null) { sectionPalettes = new BlockStateContainer[16]; } BlockStateContainer palette = new BlockStateContainer(); char[] blocks = getIdArray(layer); for (int y = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { char combinedId = blocks[FaweCache.CACHE_J[y][z][x]]; if (combinedId > 1) { palette.set(x, y, z, Block.getBlockById(combinedId >> 4).getStateFromMeta(combinedId & 0xF)); } } } } } } }
public ExtendedBlockStorage(int y, boolean storeSkylight) { this.yBase = y; this.data = new BlockStateContainer(); this.blocklightArray = new NibbleArray(); if (storeSkylight) { this.skylightArray = new NibbleArray(); } }
public void optimize() { if (sectionPalettes != null) { return; } char[][] arrays = getCombinedIdArrays(); char lastChar = Character.MAX_VALUE; for (int layer = 0; layer < 16; layer++) { if (getCount(layer) > 0) { if (sectionPalettes == null) { sectionPalettes = new BlockStateContainer[16]; } BlockStateContainer palette = new BlockStateContainer(); char[] blocks = getIdArray(layer); int index = 0; for (int y = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { char combinedId = blocks[index++]; if (combinedId > 1) { palette.set(x, y, z, Block.getBlockById(combinedId >> 4).getStateFromMeta(combinedId & 0xF)); } } } } } } }
public BlockStateContainer getData() { return this.data; }
@Redirect(method = "extractChunkData", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/BlockStateContainer;write(Lnet/minecraft/network/PacketBuffer;)V")) public void writeModified(BlockStateContainer storage, PacketBuffer buffer, PacketBuffer methodbuffer, Chunk chunk, boolean aboolean, int anunknownint){ ((InternalBlockStateContainer)storage).writeModified(buffer); }
@Redirect(method = "calculateChunkSize", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/BlockStateContainer;getSerializedSize()I")) public int caclulateModifiedSize(BlockStateContainer blockStateContainer, Chunk chunk, boolean p_189556_2_, int p_189556_3_){ ((InternalChunk) chunk).obFuscate(); InternalBlockStateContainer container = (InternalBlockStateContainer) blockStateContainer; return container.modifiedSize(); }
public void setPalette(ExtendedBlockStorage section, BlockStateContainer palette) throws NoSuchFieldException, IllegalAccessException { Field fieldSection = ExtendedBlockStorage.class.getDeclaredField("data"); fieldSection.setAccessible(true); fieldSection.set(section, palette); }
@Override public int getOpacity(ExtendedBlockStorage section, int x, int y, int z) { BlockStateContainer dataPalette = section.getData(); IBlockState ibd = dataPalette.get(x & 15, y & 15, z & 15); return ibd.getLightOpacity(); }
@Override public int getBrightness(ExtendedBlockStorage section, int x, int y, int z) { BlockStateContainer dataPalette = section.getData(); IBlockState ibd = dataPalette.get(x & 15, y & 15, z & 15); return ibd.getLightValue(); }
@Override public int getOpacityBrightnessPair(ExtendedBlockStorage section, int x, int y, int z) { BlockStateContainer dataPalette = section.getData(); IBlockState ibd = dataPalette.get(x & 15, y & 15, z & 15); return MathMan.pair16(ibd.getLightOpacity(), ibd.getLightValue()); }