Modulo() приватный Метод

private Modulo ( int x, int mod ) : int
x int
mod int
Результат int
Пример #1
0
        public void SetBlock(int x, int y, int z, Block block)
        {
            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);
            var sectionIndex = y >> 4;

            var success = Sections[sectionIndex].SetBlock(x, y & 15, z, block);

            // Palette dynamic sizing
            if (!success)
            {
                var oldSection = Sections[sectionIndex];
                var bpb        = oldSection.BitsPerBlock;
                bpb += 1;
                var newSection = new ChunkSection(bpb, sectionIndex);
                for (int sx = 0; sx < 16; sx++)
                {
                    for (int sy = 0; sy < 16; sy++)
                    {
                        for (int sz = 0; sz < 16; sz++)
                        {
                            // Seems to be the safest way to do this. A bit expensive, though...
                            newSection.SetBlock(sx, sy, sz, oldSection.GetBlock(sx, sy, sz));
                        }
                    }
                }

                Sections[sectionIndex] = newSection;
                SetBlock(x, y, z, block);
            }
        }
Пример #2
0
        public Block GetBlock(int x, int y, int z)
        {
            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);

            return(Sections[y >> 4].GetBlock(x, y & 15, z));
        }
Пример #3
0
        public void Load(string regionFile)
        {
            var regionNbt = new NbtFile();

            try
            {
                regionNbt.LoadFromFile(regionFile);
            }
            catch (Exception)
            {
                File.Delete(regionFile);
                File.Move(regionFile + ".bak", regionFile);
                regionNbt.LoadFromFile(regionFile);
            }
            finally
            {
                File.Delete(regionFile + ".bak");
            }

            NbtCompound regionCompound = regionNbt.RootTag;
            var         chunksNbt      = regionCompound["Chunks"] as NbtList;

            foreach (var chunkNbt in chunksNbt)
            {
                var chunk = GetChunkFromNbt((NbtCompound)chunkNbt);
                var index = (NumericsHelper.Modulo(chunk.X, cubicRegionSize), NumericsHelper.Modulo(chunk.Z, cubicRegionSize));
                LoadedChunks[index.Item1, index.Item2] = chunk;
            }
            regionNbt      = null;
            regionCompound = null;
            GC.Collect();
            IsDirty = false;
        }
Пример #4
0
    public void SetBlockEntity(int x, int y, int z, NbtCompound tileEntityData)
    {
        x = NumericsHelper.Modulo(x, 16);
        z = NumericsHelper.Modulo(z, 16);
        var value = (short)((x << 8) | (z << 4) | y);

        this.BlockEntities[value] = tileEntityData;
    }
Пример #5
0
    public NbtCompound GetBlockEntity(int x, int y, int z)
    {
        x = NumericsHelper.Modulo(x, 16);
        z = NumericsHelper.Modulo(z, 16);
        var value = (short)((x << 8) | (z << 4) | y);

        return(this.BlockEntities.GetValueOrDefault(value));
    }
Пример #6
0
        public BlockMeta GetBlockMeta(int x, int y, int z)
        {
            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);
            var value = (short)((x << 8) | (z << 4) | y);

            return(this.BlockMetaStore.GetValueOrDefault(value));
        }
Пример #7
0
        public void SetBlockMeta(int x, int y, int z, BlockMeta meta)
        {
            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);
            var value = (short)((x << 8) | (z << 4) | y);

            this.BlockMetaStore[value] = meta;
        }
Пример #8
0
        public void SetBlock(int x, int y, int z, Block block)
        {
            SetBlockStateId(x, y, z, block.StateId);

            x = NumericsHelper.Modulo(x, 16);
            z = NumericsHelper.Modulo(z, 16);

            Sections[y >> 4].SetBlock(x, y & 15, z, block);
        }
Пример #9
0
    public void SetBiome(int x, int y, int z, Biomes biome)
    {
        int i = SectionIndex(y);

        x = NumericsHelper.Modulo(x, 16);
        y = (y + 64) % 16 / 4;
        z = NumericsHelper.Modulo(z, 16);

        Sections[i].SetBiome(x, y, z, biome);
    }
Пример #10
0
    public Biomes GetBiome(int x, int y, int z)
    {
        var i = SectionIndex(y);

        x = NumericsHelper.Modulo(x, 16);
        z = NumericsHelper.Modulo(z, 16);
        y = (y + 64) % 16 / 4;

        return(Sections[i].GetBiome(x, y, z));
    }
Пример #11
0
    public Block GetBlock(int x, int y, int z)
    {
        var i = SectionIndex(y);

        x = NumericsHelper.Modulo(x, 16);
        y = NumericsHelper.Modulo(y, 16);
        z = NumericsHelper.Modulo(z, 16);

        return(Sections[i].GetBlock(x, y, z));
    }
Пример #12
0
    public void SetBlock(int x, int y, int z, Block block)
    {
        int i = SectionIndex(y);

        x = NumericsHelper.Modulo(x, 16);
        y = NumericsHelper.Modulo(y, 16);
        z = NumericsHelper.Modulo(z, 16);

        Sections[i].SetBlock(x, y, z, block);
    }