Flywheel/src/main/java/com/jozufozu/flywheel/util/ChunkUtil.java
Jozsef 608204ee0a Crash fix and refactor
- Check that sectionY is within the bounds of the chunk's section array, fixes #2
 - Refactor usages of Tile and Entity InstanceManagers to refer to the base class InstanceManager<>
2021-07-02 13:12:33 -07:00

18 lines
424 B
Java

package com.jozufozu.flywheel.util;
import javax.annotation.Nullable;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkSection;
public class ChunkUtil {
public static boolean isValidSection(@Nullable Chunk chunk, int sectionY) {
if (chunk == null) return false;
// TODO: 1.17
ChunkSection[] sections = chunk.getSections();
return sectionY >= 0 && sectionY < sections.length;
}
}