Files
ChunkAPI/src/main/java/com/falsepattern/chunk/internal/vanilla/BlocklightManager.java
T
2023-12-13 16:34:22 +01:00

49 lines
1.7 KiB
Java

/*
* Copyright (c) 2023 FalsePattern
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/
* or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
*/
package com.falsepattern.chunk.internal.vanilla;
import com.falsepattern.chunk.api.ChunkDataManager;
import com.falsepattern.chunk.api.ArrayUtil;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
public class BlocklightManager extends NibbleManager implements ChunkDataManager.SectionNBTDataManager {
@Override
protected NibbleArray getNibbleArray(ExtendedBlockStorage ebs) {
return ebs.getBlocklightArray();
}
@Override
public String id() {
return "blocklight";
}
@Override
public boolean sectionPrivilegedAccess() {
return true;
}
@Override
public void writeSectionToNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
section.setByteArray("BlockLight", ebs.getBlocklightArray().data);
}
@Override
public void readSectionFromNBT(Chunk chunk, ExtendedBlockStorage ebs, NBTTagCompound section) {
ebs.setBlocklightArray(new NibbleArray(section.getByteArray("BlockLight"), 4));
}
@Override
public void cloneSection(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
from.setBlocklightArray(ArrayUtil.copyArray(from.getBlocklightArray(), to.getBlocklightArray()));
}
}