/
minecraftbackup
/
AnarchyExploitFixes
Обзор
Документация
Войти
/
minecraftbackup
/
AnarchyExploitFixes
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
shared/src/main/java/me/xginko/aef/utils/ChunkUtil.java
62 строки
2 KB
Ginko
2.7.2 release (#233)
13 авг 2024, 08:21
Не верифицирован
13 авг 2024, 08:21
d20da6e
Код
Авторство
О чём код?
package me.xginko.aef.utils; import com.cryptomorin.xseries.XMaterial; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.util.NumberConversions; public class ChunkUtil { private static final boolean SET_FORCE_LOADED_AVAILABLE, GET_INHABITED_TIME_AVAILABLE; static { SET_FORCE_LOADED_AVAILABLE = Crafty.hasMethod(Chunk.class, "setForceLoaded", boolean.class); GET_INHABITED_TIME_AVAILABLE = Crafty.hasMethod(Chunk.class, "getInhabitedTime"); } public static boolean canSetChunksForceLoaded() { return SET_FORCE_LOADED_AVAILABLE; } public static void setForceLoaded(Chunk chunk, boolean forced) { if (SET_FORCE_LOADED_AVAILABLE) { chunk.setForceLoaded(forced); } } public static boolean canGetInhabitedTime() { return GET_INHABITED_TIME_AVAILABLE; } public static long getInhabitedTime(Chunk chunk) { return GET_INHABITED_TIME_AVAILABLE ? chunk.getInhabitedTime() : 0L; } public static void createBedrockLayer(Chunk chunk, int y) { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { if (chunk.getBlock(x, y, z).getType() != XMaterial.BEDROCK.parseMaterial()) { // prevent physics to avoid loading nearby chunks which causes infinite chunk loading loops chunk.getBlock(x, y, z).setType(XMaterial.BEDROCK.parseMaterial(), false); } } } } public static double getChunkDistanceSquared(Chunk chunk1, Chunk chunk2) { return NumberConversions.square(chunk1.getX() - chunk2.getX()) + NumberConversions.square(chunk1.getZ() - chunk2.getZ()); } public static double getChunkDistanceSquared(Chunk chunk, Location location) { return NumberConversions.square(chunk.getX() - (location.getBlockX() >> 4)) + NumberConversions.square(chunk.getZ() - (location.getBlockZ() >> 4)); } public static double getChunkDistanceSquared(Location location1, Location location2) { return NumberConversions.square((location1.getBlockX() >> 4) - (location2.getBlockX() >> 4)) + NumberConversions.square((location1.getBlockX() >> 4) - (location2.getBlockZ() >> 4)); } }