Esempio n. 1
0
        internal void ExchangeBlockAt(IWorldAccessor world, BlockPos pos)
        {
            world.BlockAccessor.ExchangeBlock(BlockId, pos);

            BlockEntity      be   = world.BlockAccessor.GetBlockEntity(pos);
            BEBehaviorMPBase bemp = be?.GetBehavior <BEBehaviorMPBase>();

            if (bemp != null)
            {
                bemp.SetOrientations();
                bemp.Shape = Shape;
                be.MarkDirty();
            }
        }
Esempio n. 2
0
        public override void OnBlockPlaced(IWorldAccessor world, BlockPos blockPos, ItemStack byItemStack)
        {
            base.OnBlockPlaced(world, blockPos, byItemStack);
            BlockEntity be = world.BlockAccessor.GetBlockEntity(blockPos);

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

                be.FromTreeAtributes(byItemStack.Attributes, world);
                be.MarkDirty(true);
            }
        }
Esempio n. 3
0
        private void PlaceFarmland(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, ITreeAttribute treeAttributes)
        {
            int      id  = slot.Itemstack.Attributes.GetInt("farmId");
            BlockPos pos = blockSel.Position.AddCopy(blockSel.Face);

            byEntity.World.BlockAccessor.SetBlock(id, pos);
            BlockEntity blockEntity = byEntity.World.BlockAccessor.GetBlockEntity(pos);

            if (blockEntity is BlockEntityFarmland)
            {
                treeAttributes.SetInt("posx", pos.X);
                treeAttributes.SetInt("posy", pos.Y);
                treeAttributes.SetInt("posz", pos.Z);
                blockEntity.FromTreeAttributes(treeAttributes, byEntity.World);
                blockEntity.MarkDirty();
            }
            slot.Itemstack.Attributes.RemoveAttribute("farmland");
            slot.Itemstack.Attributes.RemoveAttribute("farmId");
        }