net.minecraft.util.math.ChunkPos Java Examples

The following examples show how to use net.minecraft.util.math.ChunkPos. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void markSchematicChunkForRenderUpdate(BlockPos pos)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();
        long key = ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4);

        if (schematicChunks.containsKey(key) && clientChunks.containsKey(key))
        {
            RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
            rg.markBlockRangeForRenderUpdate(pos.getX() - 1, pos.getY() - 1, pos.getZ() - 1,pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
        }
    }
}
 
Example #2
Source File: ChunkLoading.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean loadChunkForcedWithTicket(Ticket ticket, int dimension, int chunkX, int chunkZ, int unloadDelay)
{
    if (ticket == null)
    {
        EnderUtilities.logger.warn("loadChunkForcedWithTicket(): ticket == null");
        return false;
    }

    ForgeChunkManager.forceChunk(ticket, new ChunkPos(chunkX, chunkZ));
    if (unloadDelay > 0)
    {
        //System.out.println("loadChunkForcedWithTicket() adding timeout: " + unloadDelay);
        this.addChunkTimeout(ticket, dimension, chunkX, chunkZ, unloadDelay);
    }

    return this.loadChunkWithoutForce(dimension, chunkX, chunkZ);
}
 
Example #3
Source File: SchematicPlacementManager.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
void addTouchedChunksFor(SchematicPlacement placement, boolean updateOverlay)
{
    if (placement.matchesRequirement(RequiredEnabled.PLACEMENT_ENABLED))
    {
        Set<ChunkPos> chunks = placement.getTouchedChunks();

        for (ChunkPos pos : chunks)
        {
            if (this.schematicsTouchingChunk.containsEntry(pos, placement) == false)
            {
                this.schematicsTouchingChunk.put(pos, placement);
                this.updateTouchedBoxesInChunk(pos);
            }

            this.chunksToUnload.remove(pos);
        }

        this.markChunksForRebuild(chunks);

        if (updateOverlay)
        {
            this.updateOverlayRendererIfEnabled(placement);
        }
    }
}
 
Example #4
Source File: TaskCountBlocksBase.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void countBlocksInChunk(ChunkPos pos)
{
    BlockPos.MutableBlockPos posMutable = new BlockPos.MutableBlockPos();

    for (IntBoundingBox bb : this.getBoxesInChunk(pos))
    {
        final int startX = bb.minX;
        final int startY = bb.minY;
        final int startZ = bb.minZ;
        final int endX = bb.maxX;
        final int endY = bb.maxY;
        final int endZ = bb.maxZ;

        for (int y = startY; y <= endY; ++y)
        {
            for (int z = startZ; z <= endZ; ++z)
            {
                for (int x = startX; x <= endX; ++x)
                {
                    posMutable.setPos(x, y, z);
                    this.countAtPosition(posMutable);
                }
            }
        }
    }
}
 
Example #5
Source File: ChunkLoading.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void ticketsLoaded(List<Ticket> tickets, World world)
{
    for (Ticket ticket : tickets)
    {
        //System.out.println("void ticketsLoaded(): looping tickets");
        if (ticket != null)
        {
            for (ChunkPos chunk : ticket.getChunkList())
            {
                //System.out.println("void ticketsLoaded(): forcing chunk: " + chunk + " in dimension: " + ticket.world.provider.getDimensionId());
                ForgeChunkManager.forceChunk(ticket, chunk);
            }
        }
    }
}
 
Example #6
Source File: WorldMana.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
public float getManaInfluence(World world, BlockPos pos) {
    ChunkPos chunkPos = new ChunkPos(pos);
    float mana = 0.0f;
    for (int dx = -4 ; dx <= 4 ; dx++) {
        for (int dz = -4 ; dz <= 4 ; dz++) {
            ChunkPos cp = new ChunkPos(chunkPos.x + dx, chunkPos.z + dz);
            ManaSphere sphere = getOrCreateSphereAt(world, cp);
            if (sphere.getRadius() > 0) {
                double distanceSq = pos.distanceSq(sphere.getCenter());
                if (distanceSq < sphere.getRadius() * sphere.getRadius()) {
                    double distance = Math.sqrt(distanceSq);
                    mana += (sphere.getRadius() - distance) / sphere.getRadius();
                }
            }
        }
    }
    return mana;
}
 
Example #7
Source File: WorldMana.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
public float getManaStrength(World world, BlockPos pos) {
    ChunkPos chunkPos = new ChunkPos(pos);
    float mana = 0.0f;
    for (int dx = -4 ; dx <= 4 ; dx++) {
        for (int dz = -4 ; dz <= 4 ; dz++) {
            ChunkPos cp = new ChunkPos(chunkPos.x + dx, chunkPos.z + dz);
            ManaSphere sphere = getOrCreateSphereAt(world, cp);
            if (sphere.getRadius() > 0) {
                double distanceSq = pos.distanceSq(sphere.getCenter());
                if (distanceSq < sphere.getRadius() * sphere.getRadius()) {
                    double distance = Math.sqrt(distanceSq);
                    double influence = (sphere.getRadius() - distance) / sphere.getRadius();
                    mana += influence * sphere.getCurrentMana();
                }
            }
        }
    }
    return mana;
}
 
Example #8
Source File: WorldMana.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
private void growMana(World world) {
    for (Map.Entry<ChunkPos, ManaSphere> entry : spheres.entrySet()) {
        ManaSphere sphere = entry.getValue();
        if (sphere.getRadius() > 0) {
            if (world.isBlockLoaded(sphere.getCenter())) {
                float currentMana = sphere.getCurrentMana();
                currentMana += .01f;
                if (currentMana >= 5) {
                    currentMana = 5;
                }
                sphere.setCurrentMana(currentMana);
                markDirty();
            }
        }
    }
}
 
Example #9
Source File: WorldMana.java    From YouTubeModdingTutorial with MIT License 6 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    NBTTagList list = new NBTTagList();
    for (Map.Entry<ChunkPos, ManaSphere> entry : spheres.entrySet()) {
        NBTTagCompound sphereNBT = new NBTTagCompound();
        ChunkPos pos = entry.getKey();
        ManaSphere sphere = entry.getValue();
        sphereNBT.setInteger("cx", pos.x);
        sphereNBT.setInteger("cz", pos.z);
        sphereNBT.setInteger("posx", sphere.getCenter().getX());
        sphereNBT.setInteger("posy", sphere.getCenter().getY());
        sphereNBT.setInteger("posz", sphere.getCenter().getZ());
        sphereNBT.setFloat("radius", sphere.getRadius());
        sphereNBT.setFloat("mana", sphere.getCurrentMana());
        list.appendTag(sphereNBT);
    }
    compound.setTag("spheres", list);

    return compound;
}
 
Example #10
Source File: ImplShipChunkClaims.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
private void injectChunkIntoWorld(int x, int z, Chunk chunk) {
    ChunkProviderServer provider = (ChunkProviderServer) this.getWorldObj().getChunkProvider();
    chunk.dirty = true;
    // claimedChunks[x - getgetOwnedChunks().getMinX()][z - getgetOwnedChunks().getMinZ()] = chunk;
    loadedChunksMap.put(ChunkPos.asLong(x, z), chunk);

    provider.loadedChunks.put(ChunkPos.asLong(x, z), chunk);

    chunk.onLoad();

    PlayerChunkMap map = ((WorldServer) this.getWorldObj()).getPlayerChunkMap();

    PlayerChunkMapEntry entry = new PlayerChunkMapEntry(map, x, z);

    long i = PlayerChunkMap.getIndex(x, z);
    // TODO: In future we need to do better to account for concurrency.
    map.entryMap.put(i, entry);
    map.entries.add(entry);

    entry.sentToPlayers = true;
    // TODO: In future we need to do better to account for concurrency.
    entry.players = Collections.unmodifiableList(shipHolder.getWatchingPlayers());
}
 
Example #11
Source File: PositionUtils.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static Set<ChunkPos> getTouchedChunksForBoxes(Collection<? extends Box> boxes)
{
    Set<ChunkPos> set = new HashSet<>();

    for (Box box : boxes)
    {
        final int boxXMin = Math.min(box.getPos1().getX(), box.getPos2().getX()) >> 4;
        final int boxZMin = Math.min(box.getPos1().getZ(), box.getPos2().getZ()) >> 4;
        final int boxXMax = Math.max(box.getPos1().getX(), box.getPos2().getX()) >> 4;
        final int boxZMax = Math.max(box.getPos1().getZ(), box.getPos2().getZ()) >> 4;

        for (int cz = boxZMin; cz <= boxZMax; ++cz)
        {
            for (int cx = boxXMin; cx <= boxXMax; ++cx)
            {
                set.add(new ChunkPos(cx, cz));
            }
        }
    }

    return set;
}
 
Example #12
Source File: TaskPasteSchematicPerChunkBase.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void addPlacement(SchematicPlacement placement, LayerRange range)
{
    Set<ChunkPos> touchedChunks = placement.getTouchedChunks();

    for (ChunkPos pos : touchedChunks)
    {
        int count = 0;

        for (IntBoundingBox box : placement.getBoxesWithinChunk(pos.x, pos.z).values())
        {
            box = range.getClampedBox(box);

            if (box != null)
            {
                this.boxesInChunks.put(pos, box);
                ++count;
            }
        }

        if (count > 0)
        {
            this.individualChunks.add(pos);
            this.onChunkAddedForHandling(pos, placement);
        }
    }
}
 
Example #13
Source File: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void markSchematicChunksForRenderUpdate(ChunkPos chunkPos)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();
        long key = ChunkPos.asLong(chunkPos.x, chunkPos.z);

        if (schematicChunks.containsKey(key) && clientChunks.containsKey(key))
        {
            RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
            rg.markBlockRangeForRenderUpdate((chunkPos.x << 4) - 1,   0, (chunkPos.z << 4) - 1,
                                             (chunkPos.x << 4) + 1, 255, (chunkPos.z << 4) + 1);
        }
    }
}
 
Example #14
Source File: TaskSaveSchematic.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected boolean processChunk(ChunkPos pos)
{
    ImmutableMap<String, IntBoundingBox> volumes = PositionUtils.getBoxesWithinChunk(pos.x, pos.z, this.subRegions);
    SchematicCreationUtils.takeBlocksFromWorldWithinChunk(this.schematic, this.world, pos.x, pos.z, volumes, this.subRegions);

    if (this.takeEntities)
    {
        SchematicCreationUtils.takeEntitiesFromWorldWithinChunk(this.schematic, this.world, pos.x, pos.z, volumes, this.subRegions, this.existingEntities, this.origin);
    }

    return true;
}
 
Example #15
Source File: ChunkLoading.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public DimChunkCoordTimeout(Ticket ticket, int dimension, ChunkPos cc, int timeout)
{
    this.ticket = ticket;
    this.dimension = dimension;
    this.chunkCoords = cc;
    this.timeout = timeout;
    this.timeoutFresh = timeout;
}
 
Example #16
Source File: CarpetSettings.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void changeSpawnSize(int size)
{
    ServerWorld overworld = CarpetServer.minecraft_server.getWorld(DimensionType.OVERWORLD);
    if (overworld != null) {
        ChunkPos centerChunk = new ChunkPos(new BlockPos(
                overworld.getLevelProperties().getSpawnX(),
                overworld.getLevelProperties().getSpawnY(),
                overworld.getLevelProperties().getSpawnZ()
        ));
        SpawnChunks.changeSpawnChunks(overworld.getChunkManager(), centerChunk, size);
    }
}
 
Example #17
Source File: TickableWorldPipeNet.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void addPipeNetToChunk(ChunkPos chunkPos, T pipeNet) {
    super.addPipeNetToChunk(chunkPos, pipeNet);
    if (isChunkLoaded(chunkPos)) {
        List<ChunkPos> loadedChunks = getOrCreateChunkListForPipeNet(pipeNet);
        if (loadedChunks.isEmpty()) {
            this.tickingPipeNets.add(pipeNet);
        }
        loadedChunks.add(chunkPos);
    }
}
 
Example #18
Source File: CraftWorld.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public boolean regenerateChunk(int x, int z) {
    if (!unloadChunk0(x, z, false)) {
        return false;
    }

    final long chunkKey = ChunkPos.asLong(x, z);
    world.getChunkProvider().droppedChunksSet.remove(chunkKey);

    net.minecraft.world.chunk.Chunk chunk = null;

    chunk = world.getChunkProvider().chunkGenerator.generateChunk(x, z);
    PlayerChunkMapEntry playerChunk = world.getPlayerChunkMap().getEntry(x, z);
    if (playerChunk != null) {
        playerChunk.chunk = chunk;
    }

    if (chunk != null) {
        world.getChunkProvider().id2ChunkMap.put(chunkKey, chunk);

        chunk.onLoad();
        chunk.populateCB(world.getChunkProvider(), world.getChunkProvider().chunkGenerator, true);

        refreshChunk(x, z);
    }

    return chunk != null;
}
 
Example #19
Source File: PositionUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public int compare(ChunkPos pos1, ChunkPos pos2)
{
    double dist1 = this.distanceSq(pos1);
    double dist2 = this.distanceSq(pos2);

    if (dist1 == dist2)
    {
        return 0;
    }

    return dist1 < dist2 == this.closestFirst ? -1 : 1;
}
 
Example #20
Source File: WorldMana.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
    NBTTagList list = nbt.getTagList("spheres", Constants.NBT.TAG_COMPOUND);
    for (int i = 0 ; i < list.tagCount() ; i++) {
        NBTTagCompound sphereNBT = list.getCompoundTagAt(i);
        ChunkPos pos = new ChunkPos(sphereNBT.getInteger("cx"), sphereNBT.getInteger("cz"));
        ManaSphere sphere = new ManaSphere(
                new BlockPos(sphereNBT.getInteger("posx"), sphereNBT.getInteger("posy"), sphereNBT.getInteger("posz")),
                sphereNBT.getFloat("radius"));
        sphere.setCurrentMana(sphereNBT.getFloat("mana"));
        spheres.put(pos, sphere);
    }
}
 
Example #21
Source File: TaskCountBlocksBase.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void countBlocksInChunkRespectingLayerRange(ChunkPos pos, LayerRange range)
{
    EnumFacing.Axis axis = range.getAxis();
    BlockPos.MutableBlockPos posMutable = new BlockPos.MutableBlockPos();

    for (IntBoundingBox bb : this.getBoxesInChunk(pos))
    {
        final int startX = axis == EnumFacing.Axis.X ? Math.max(bb.minX, range.getLayerMin()) : bb.minX;
        final int startY = axis == EnumFacing.Axis.Y ? Math.max(bb.minY, range.getLayerMin()) : bb.minY;
        final int startZ = axis == EnumFacing.Axis.Z ? Math.max(bb.minZ, range.getLayerMin()) : bb.minZ;
        final int endX = axis == EnumFacing.Axis.X ? Math.min(bb.maxX, range.getLayerMax()) : bb.maxX;
        final int endY = axis == EnumFacing.Axis.Y ? Math.min(bb.maxY, range.getLayerMax()) : bb.maxY;
        final int endZ = axis == EnumFacing.Axis.Z ? Math.min(bb.maxZ, range.getLayerMax()) : bb.maxZ;

        for (int y = startY; y <= endY; ++y)
        {
            for (int z = startZ; z <= endZ; ++z)
            {
                for (int x = startX; x <= endX; ++x)
                {
                    posMutable.setPos(x, y, z);
                    this.countAtPosition(posMutable);
                }
            }
        }
    }
}
 
Example #22
Source File: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void updateBetweenX(int minX, int maxX)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        final int xMin = Math.min(minX, maxX);
        final int xMax = Math.max(minX, maxX);
        final int cxMin = (xMin >> 4);
        final int cxMax = (xMax >> 4);
        RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();

        for (Chunk chunk : schematicChunks.values())
        {
            // Only mark chunks that are actually rendered (if the schematic world contains more chunks)
            if (chunk.x >= cxMin && chunk.x <= cxMax && chunk.isEmpty() == false &&
                clientChunks.containsKey(ChunkPos.asLong(chunk.x, chunk.z)))
            {
                minX = Math.max( chunk.x << 4      , xMin);
                maxX = Math.min((chunk.x << 4) + 15, xMax);
                rg.markBlockRangeForRenderUpdate(minX, 0, (chunk.z << 4), maxX, 255, (chunk.z << 4) + 15);
            }
        }
    }
}
 
Example #23
Source File: SchematicWorldRenderingNotifier.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void updateBetweenZ(int minZ, int maxZ)
{
    World world = SchematicWorldHandler.getSchematicWorld();

    if (world != null)
    {
        final int zMin = Math.min(minZ, maxZ);
        final int zMax = Math.max(minZ, maxZ);
        final int czMin = (zMin >> 4);
        final int czMax = (zMax >> 4);
        RenderGlobal rg = LitematicaRenderer.getInstance().getWorldRenderer();
        Long2ObjectMap<Chunk> schematicChunks = ((IMixinChunkProviderClient) (Object) world.getChunkProvider()).getLoadedChunks();
        Long2ObjectMap<Chunk> clientChunks = ((IMixinChunkProviderClient) (Object) Minecraft.getMinecraft().world.getChunkProvider()).getLoadedChunks();

        for (Chunk chunk : schematicChunks.values())
        {
            // Only mark chunks that are actually rendered (if the schematic world contains more chunks)
            if (chunk.z >= czMin && chunk.z <= czMax && chunk.isEmpty() == false &&
                clientChunks.containsKey(ChunkPos.asLong(chunk.x, chunk.z)))
            {
                minZ = Math.max( chunk.z << 4      , zMin);
                maxZ = Math.min((chunk.z << 4) + 15, zMax);
                rg.markBlockRangeForRenderUpdate((chunk.x << 4), 0, minZ, (chunk.x << 4) + 15, 255, maxZ);
            }
        }
    }
}
 
Example #24
Source File: WorldMana.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
private ManaSphere getOrCreateSphereAt(World world, ChunkPos cp) {
    ManaSphere sphere = spheres.get(cp);
    if (sphere == null) {
        BlockPos center = cp.getBlock(8, ManaSphere.getRandomYOffset(world.getSeed(), cp.x, cp.z), 8);
        float radius = 0;
        if (ManaSphere.isCenterChunk(world.getSeed(), cp.x, cp.z)) {
            radius = ManaSphere.getRadius(world.getSeed(), cp.x, cp.z);
        }
        sphere = new ManaSphere(center, radius);
        spheres.put(cp, sphere);
        markDirty();
    }
    return sphere;
}
 
Example #25
Source File: TickableWorldPipeNet.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onChunkLoaded(Chunk chunk) {
    ChunkPos chunkPos = chunk.getPos();
    List<T> pipeNetsInThisChunk = this.pipeNetsByChunk.get(chunkPos);
    for (T pipeNet : pipeNetsInThisChunk) {
        List<ChunkPos> loadedChunks = getOrCreateChunkListForPipeNet(pipeNet);
        if (loadedChunks.isEmpty()) {
            this.tickingPipeNets.add(pipeNet);
        }
        loadedChunks.add(chunkPos);
    }
}
 
Example #26
Source File: PipeNet.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void ensureRemovedFromChunk(BlockPos nodePos) {
    ChunkPos chunkPos = new ChunkPos(nodePos);
    int newValue = this.ownedChunks.compute(chunkPos, (pos, old) -> old == null ? 0 : old - 1);
    if (newValue == 0) {
        this.ownedChunks.remove(chunkPos);
        if (isValid()) {
            this.worldData.removePipeNetFromChunk(chunkPos, this);
        }
    }
}
 
Example #27
Source File: SchematicPlacementManager.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onClientChunkUnload(int chunkX, int chunkZ)
{
    if (Configs.Generic.LOAD_ENTIRE_SCHEMATICS.getBooleanValue() == false)
    {
        WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld();

        if (worldSchematic != null)
        {
            this.unloadSchematicChunk(worldSchematic, chunkX, chunkZ);
            this.chunksToRebuild.add(new ChunkPos(chunkX, chunkZ));
        }
    }
}
 
Example #28
Source File: TaskBase.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void updateInfoHudLinesMissingChunks(Set<ChunkPos> requiredChunks)
{
    List<String> hudLines = new ArrayList<>();
    EntityPlayer player = this.mc.player;

    if (player != null && requiredChunks.isEmpty() == false)
    {
        List<ChunkPos> list = new ArrayList<>();
        list.addAll(requiredChunks);
        PositionUtils.CHUNK_POS_COMPARATOR.setReferencePosition(new BlockPos(player.getPositionVector()));
        PositionUtils.CHUNK_POS_COMPARATOR.setClosestFirst(true);
        Collections.sort(list, PositionUtils.CHUNK_POS_COMPARATOR);

        String pre = GuiBase.TXT_WHITE + GuiBase.TXT_BOLD;
        String title = StringUtils.translate("litematica.gui.label.missing_chunks", this.name, requiredChunks.size());
        hudLines.add(String.format("%s%s%s", pre, title, GuiBase.TXT_RST));

        int maxLines = Math.min(list.size(), Configs.InfoOverlays.INFO_HUD_MAX_LINES.getIntegerValue());

        for (int i = 0; i < maxLines; ++i)
        {
            ChunkPos pos = list.get(i);
            hudLines.add(String.format("cx: %5d, cz: %5d (x: %d, z: %d)", pos.x, pos.z, pos.x << 4, pos.z << 4));
        }
    }

    this.infoHudLines = hudLines;
}
 
Example #29
Source File: PositionUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private double distanceSq(ChunkPos pos)
{
    double dx = (double) (pos.x << 4) - this.posReference.getX();
    double dz = (double) (pos.z << 4) - this.posReference.getZ();

    return dx * dx + dz * dz;
}
 
Example #30
Source File: HallowedChunkGenerator.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public void populateEntities(ChunkRegion region) {
	int centreX = region.getCenterChunkX();
	int centreZ = region.getCenterChunkZ();
	Biome biome = region.getBiome((new ChunkPos(centreX, centreZ)).getCenterBlockPos());
	ChunkRandom chunkRandom = new ChunkRandom();
	chunkRandom.setSeed(region.getSeed(), centreX << 4, centreZ << 4);
	SpawnHelper.populateEntities(region, biome, centreX, centreZ, chunkRandom);
}