Ejemplo n.º 1
0
        public override void OnServerGameTick(IWorldAccessor world, BlockPos pos, object extra = null)
        {
            // We cannot call the base method, otherwise we'll destroy the chiseled block
            // base.OnServerGameTick(world, pos, extra);

            if (extra is string && (string)extra == "melt")
            {
                BlockEntityMicroBlock bec = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityMicroBlock;

                if (this == snowCovered3)
                {
                    world.BlockAccessor.ExchangeBlock(snowCovered2.Id, pos);
                    bec.SnowLevel = 0;
                    bec.MarkDirty(true);
                }
                else if (this == snowCovered2)
                {
                    world.BlockAccessor.ExchangeBlock(snowCovered1.Id, pos);
                    bec.SnowLevel = 0;
                    bec.MarkDirty(true);
                }
                else if (this == snowCovered1)
                {
                    world.BlockAccessor.ExchangeBlock(notSnowCovered.Id, pos);
                    bec.SnowLevel = 0;
                    bec.MarkDirty(true);
                }
            }
        }
Ejemplo n.º 2
0
        public override bool CanAttachBlockAt(IBlockAccessor world, Block block, BlockPos pos, BlockFacing blockFace, Cuboidi attachmentArea = null)
        {
            BlockEntityMicroBlock be = world.GetBlockEntity(pos) as BlockEntityMicroBlock;

            if (be != null)
            {
                return(be.CanAttachBlockAt(blockFace, attachmentArea));
            }

            return(base.CanAttachBlockAt(world, block, pos, blockFace));
        }
Ejemplo n.º 3
0
        public override string GetPlacedBlockName(IWorldAccessor world, BlockPos pos)
        {
            BlockEntityMicroBlock be = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityMicroBlock;

            if (be != null)
            {
                return(be.BlockName);
            }

            return(base.GetPlacedBlockName(world, pos));
        }
Ejemplo n.º 4
0
        public override bool DoEmitSideAoByFlag(IBlockAccessor blockAccessor, BlockPos pos, int flag)
        {
            BlockEntityMicroBlock bec = blockAccessor.GetBlockEntity(pos) as BlockEntityMicroBlock;

            if (bec == null)
            {
                return(base.DoEmitSideAoByFlag(blockAccessor, pos, flag));
            }

            return(bec.DoEmitSideAoByFlag(flag));
        }
Ejemplo n.º 5
0
        public override Cuboidf[] GetCollisionBoxes(IBlockAccessor blockAccessor, BlockPos pos)
        {
            BlockEntityMicroBlock bec = blockAccessor.GetBlockEntity(pos) as BlockEntityMicroBlock;

            if (bec != null)
            {
                Cuboidf[] selectionBoxes = bec.GetCollisionBoxes(blockAccessor, pos);

                return(selectionBoxes);
            }

            return(base.GetSelectionBoxes(blockAccessor, pos));
        }
Ejemplo n.º 6
0
        public override void GetDecal(IWorldAccessor world, BlockPos pos, ITexPositionSource decalTexSource, ref MeshData decalModelData, ref MeshData blockModelData)
        {
            BlockEntityMicroBlock be = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityMicroBlock;

            if (be != null)
            {
                blockModelData = be.Mesh;
                decalModelData = be.CreateDecalMesh(decalTexSource);
                return;
            }

            base.GetDecal(world, pos, decalTexSource, ref decalModelData, ref blockModelData);
        }
Ejemplo n.º 7
0
        public override void OnNeighbourBlockChange(IWorldAccessor world, BlockPos pos, BlockPos neibpos)
        {
            // We cannot call the base method, otherwise we'll destroy the chiseled block
            //base.OnNeighbourBlockChange(world, pos, neibpos);

            if (pos.X == neibpos.X && pos.Z == neibpos.Z && pos.Y + 1 == neibpos.Y && world.BlockAccessor.GetBlock(neibpos).Id != 0)
            {
                BlockEntityMicroBlock bec = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityMicroBlock;
                if (bec.SnowLevel > 0)
                {
                    world.BlockAccessor.ExchangeBlock(notSnowCovered.Id, pos);
                    bec.SnowLevel = 0;
                    bec.MarkDirty(true);
                }
            }
        }
Ejemplo n.º 8
0
        public override int GetColorWithoutTint(ICoreClientAPI capi, BlockPos pos)
        {
            BlockEntityMicroBlock be = capi.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityMicroBlock;

            if (be?.MaterialIds != null && be.MaterialIds.Length > 0)
            {
                Block block = capi.World.GetBlock(be.MaterialIds[0]);
                if (block is BlockMicroBlock)
                {
                    return(0);                          // Prevent-chisel-ception. Happened to WQP, not sure why
                }
                return(block.GetColor(capi, pos));
            }

            return(base.GetColorWithoutTint(capi, pos));
        }
Ejemplo n.º 9
0
        public override ItemStack OnPickBlock(IWorldAccessor world, BlockPos pos)
        {
            BlockEntityMicroBlock bec = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityMicroBlock;

            if (bec == null)
            {
                return(null);
            }

            TreeAttribute tree = new TreeAttribute();

            bec.ToTreeAttributes(tree);
            tree.RemoveAttribute("posx");
            tree.RemoveAttribute("posy");
            tree.RemoveAttribute("posz");
            tree.RemoveAttribute("snowcuboids");

            return(new ItemStack(notSnowCovered.Id, EnumItemClass.Block, 1, tree, world));
        }
Ejemplo n.º 10
0
        public override void OnBlockPlaced(IWorldAccessor world, BlockPos blockPos, ItemStack byItemStack)
        {
            base.OnBlockPlaced(world, blockPos, byItemStack);

            BlockEntityMicroBlock be = world.BlockAccessor.GetBlockEntity(blockPos) as BlockEntityMicroBlock;

            if (be != null && byItemStack != null)
            {
                ITreeAttribute tree = byItemStack.Attributes.Clone();
                tree.SetInt("posx", blockPos.X);
                tree.SetInt("posy", blockPos.Y);
                tree.SetInt("posz", blockPos.Z);

                be.FromTreeAttributes(tree, world);
                be.MarkDirty(true);

                if (world.Side == EnumAppSide.Client)
                {
                    be.RegenMesh();
                }

                be.RegenSelectionBoxes(null);
            }
        }
Ejemplo n.º 11
0
        public override int GetLightAbsorption(IWorldChunk chunk, BlockPos pos)
        {
            BlockEntityMicroBlock bec = chunk?.GetLocalBlockEntityAtBlockPos(pos) as BlockEntityMicroBlock;

            return(bec?.GetLightAbsorption() ?? 0);
        }