use of net.minecraft.world.chunk.IChunk in project minecolonies by Minecolonies.
the class ColonyDeathpoints method tryCreatingWaypoint.
@Nullable
private static Waypoint tryCreatingWaypoint(@NotNull final Journeymap jmap, @NotNull final IColonyView colony, @NotNull final BlockPos pos) {
final ChunkPos chunkPos = new ChunkPos(pos);
final IChunk chunk = colony.getWorld().getChunk(chunkPos.x, chunkPos.z, ChunkStatus.FULL, false);
return (chunk == null) ? null : tryCreatingWaypoint(jmap, colony, chunk, pos);
}
use of net.minecraft.world.chunk.IChunk in project ChocolateQuestRepoured by TeamChocoQuest.
the class ServerProtectedRegionManager method getProtectedRegionsAt.
@Override
public List<ProtectedRegion> getProtectedRegionsAt(BlockPos pos) {
// load chunk which also loads all associated protected regions
IChunk ichunk = this.world.getChunk(pos);
if (!(ichunk instanceof Chunk)) {
return Collections.emptyList();
}
Chunk chunk = (Chunk) ichunk;
LazyOptional<CapabilityProtectedRegionData> lOpCap = chunk.getCapability(CapabilityProtectedRegionDataProvider.PROTECTED_REGION_DATA, null);
if (!lOpCap.isPresent()) {
return Collections.emptyList();
}
List<ProtectedRegion> list = new ArrayList<>();
lOpCap.ifPresent((cap) -> {
cap.removeIf(uuid -> {
ProtectedRegionContainer container = this.protectedRegions.get(uuid);
if (container != null && container.protectedRegion.isInsideProtectedRegion(pos)) {
list.add(container.protectedRegion);
}
return container == null;
});
});
return list;
}
use of net.minecraft.world.chunk.IChunk in project dynmap by webbukkit.
the class DynmapExpCommand method registerEvents.
private void registerEvents() {
// To trigger rendering.
onblockchange = core.isTrigger("blockupdate");
onchunkpopulate = core.isTrigger("chunkpopulate");
onchunkgenerate = core.isTrigger("chunkgenerate");
onblockchange_with_id = core.isTrigger("blockupdate-with-id");
if (onblockchange_with_id)
onblockchange = true;
if ((worldTracker == null) && (onblockchange || onchunkpopulate || onchunkgenerate)) {
worldTracker = new WorldTracker();
MinecraftForge.EVENT_BUS.register(worldTracker);
}
// Prime the known full chunks
if (onchunkgenerate && (server.getWorlds() != null)) {
for (ServerWorld world : server.getWorlds()) {
ForgeWorld fw = getWorld(world);
if (fw == null)
continue;
Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = world.getChunkProvider().chunkManager.immutableLoadedChunks;
for (Entry<Long, ChunkHolder> k : chunks.long2ObjectEntrySet()) {
long key = k.getKey().longValue();
ChunkHolder ch = k.getValue();
IChunk c = null;
try {
c = ch.func_219302_f().getNow(null);
} catch (Exception x) {
}
if (c == null)
continue;
ChunkStatus cs = c.getStatus();
ChunkPos pos = ch.getPosition();
if (cs == ChunkStatus.FULL) {
// Cooked?
// Add it as known
addKnownChunk(fw, pos);
}
}
}
}
}
use of net.minecraft.world.chunk.IChunk in project Mekanism by mekanism.
the class TransporterPathfinder method getPaths.
private static List<Destination> getPaths(LogisticalTransporterBase start, TransporterStack stack, TransitRequest request, int min) {
InventoryNetwork network = start.getTransmitterNetwork();
if (network == null) {
return Collections.emptyList();
}
Long2ObjectMap<IChunk> chunkMap = new Long2ObjectOpenHashMap<>();
List<AcceptorData> acceptors = network.calculateAcceptors(request, stack, chunkMap);
List<Destination> paths = new ArrayList<>();
for (AcceptorData data : acceptors) {
Destination path = getPath(network, data, start, stack, min, chunkMap);
if (path != null) {
paths.add(path);
}
}
Collections.sort(paths);
return paths;
}
use of net.minecraft.world.chunk.IChunk in project Mekanism by mekanism.
the class TransporterPathfinder method getIdlePath.
public static Pair<List<BlockPos>, Path> getIdlePath(LogisticalTransporterBase start, TransporterStack stack) {
InventoryNetwork network = start.getTransmitterNetwork();
if (network == null) {
return null;
}
if (stack.homeLocation != null) {
Long2ObjectMap<IChunk> chunkMap = new Long2ObjectOpenHashMap<>();
Pathfinder p = new Pathfinder(new DestChecker() {
@Override
public boolean isValid(TransporterStack stack, Direction side, TileEntity tile) {
return TransporterUtils.canInsert(tile, stack.color, stack.itemStack, side, true);
}
}, network, start.getTileWorld(), stack.homeLocation, start.getTilePos(), stack);
p.find(chunkMap);
List<BlockPos> path = p.getPath();
if (path.size() >= 2) {
return Pair.of(path, Path.HOME);
}
stack.homeLocation = null;
}
IdlePath d = new IdlePath(network, start.getTilePos(), stack);
Destination dest = d.find();
if (dest == null) {
return null;
}
return Pair.of(dest.getPath(), dest.getPathType());
}
Aggregations